[jboss-svn-commits] JBL Code SVN: r18939 - in labs/jbossrules/trunk/drools-ant/src: test/resources and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 13 16:31:42 EDT 2008
Author: fmeyer
Date: 2008-03-13 16:31:42 -0400 (Thu, 13 Mar 2008)
New Revision: 18939
Modified:
labs/jbossrules/trunk/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java
labs/jbossrules/trunk/drools-ant/src/test/resources/DroolsAntTask.xml
Log:
JBRULES-1327 added the binformat option on drools-ant
Modified: labs/jbossrules/trunk/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java
===================================================================
--- labs/jbossrules/trunk/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java 2008-03-13 20:29:58 UTC (rev 18938)
+++ labs/jbossrules/trunk/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java 2008-03-13 20:31:42 UTC (rev 18939)
@@ -38,6 +38,7 @@
import org.drools.lang.dsl.DSLMappingFile;
import org.drools.lang.dsl.DefaultExpander;
import org.drools.lang.dsl.DefaultExpanderResolver;
+import org.drools.rule.Package;
import java.io.*;
@@ -53,10 +54,14 @@
public static String RULEFLOWFILEEXTENSION = ".rfm";
public static String DSLFILEEXTENSION = ".dslr";
public static String XLSFILEEXTENSION = ".xls";
+
+ public static String PACKAGEBINFORMAT = "package";
private File srcdir;
private File toFile;
private Path classpath;
+
+ private String binformat;
/**
@@ -89,8 +94,7 @@
/**
* Classpath to use, by reference, when compiling the rulebase
*
- * @param r
- * a reference to an existing classpath
+ * @param a reference to an existing classpath
*/
public void setClasspathref(Reference r) {
createClasspath().setRefid(r);
@@ -148,16 +152,20 @@
// gets the package
org.drools.rule.Package pkg = builder.getPackage();
+
+ // creates the rulebase
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- // creates the rulebase
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-
- // adds the package
- ruleBase.addPackage(pkg);
-
- // serialize the rule base to the destination file
- serializeRulebase(ruleBase);
-
+ // adds the package
+ ruleBase.addPackage(pkg);
+
+
+ if (PACKAGEBINFORMAT.equals( binformat ) ) {
+ serializeObject( pkg );
+ } else {
+ // serialize the rule base to the destination file
+ serializeObject(ruleBase);
+ }
} catch (Exception e) {
throw new BuildException("RuleBaseTask failed: " + e.getMessage(),
e);
@@ -167,19 +175,19 @@
}
}
}
-
+
/**
* @param ruleBase
* @throws FileNotFoundException
* @throws IOException
*/
- private void serializeRulebase(RuleBase ruleBase)
+ private void serializeObject(Object object)
throws FileNotFoundException, IOException {
ObjectOutputStream outstream = null;
try {
FileOutputStream fout = new FileOutputStream(toFile);
outstream = new ObjectOutputStream(fout);
- outstream.writeObject(ruleBase);
+ outstream.writeObject(object);
} finally {
if (outstream != null) {
outstream.close();
@@ -370,4 +378,12 @@
return fileNames;
}
+ public void setBinformat(String binformat) {
+ this.binformat = binformat;
+ }
+
+ public String getBinformat() {
+ return binformat;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-ant/src/test/resources/DroolsAntTask.xml
===================================================================
--- labs/jbossrules/trunk/drools-ant/src/test/resources/DroolsAntTask.xml 2008-03-13 20:29:58 UTC (rev 18938)
+++ labs/jbossrules/trunk/drools-ant/src/test/resources/DroolsAntTask.xml 2008-03-13 20:31:42 UTC (rev 18939)
@@ -1,9 +1,9 @@
<project default="rules">
<!-- Uncomment this for Maven Runner -->
- <property name="eclipsepath" value=""/>
+ <property name="eclipsepath" value=""/>
<!-- Uncomment this for Eclipse Runner -->
- <!-- <property name="eclipsepath" value="../../../"/> -->
+ <!-- <property name="eclipsepath" value="../../../"/> -->
<path id="cheese.classpath">
<pathelement location="${eclipsepath}lib/cheese.jar"/>
@@ -16,7 +16,7 @@
<pathelement location="target"/>
</path>
- <taskdef name="rulebase" classname="org.drools.contrib.DroolsCompilerAntTask" classpathref="drools.classpath" />
+ <taskdef name="compiler" classname="org.drools.contrib.DroolsCompilerAntTask" classpathref="drools.classpath" />
<taskdef name="analytics" classname="org.drools.contrib.DroolsAnalyticsAntTask" classpathref="drools.classpath" />
@@ -31,17 +31,17 @@
<target name="dslRules" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/rules"
- tofile="${eclipsepath}target/cheese.rules"
- classpathref="cheese.classpath" >
-
+ tofile="${eclipsepath}target/cheese.rules.dpkg"
+ classpathref="cheese.classpath"
+ binformat="package" >
<include name="*.dslr" />
- </rulebase>
+ </compiler>
</target>
<target name="rules" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/rules"
tofile="${eclipsepath}target/cheese.rules"
classpathref="cheese.classpath" >
@@ -49,27 +49,27 @@
<include name="*.brl" />
<include name="*.xml" />
<include name="*.dslr" />
- </rulebase>
+ </compiler>
</target>
<target name="rulesnopackagefile" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/packagefiletest/emptydir"
tofile="${eclipsepath}target/cheese.rules"
classpathref="cheese.classpath" >
<include name="*.drl" />
<include name="*.brl" />
- </rulebase>
+ </compiler>
</target>
<target name="rulesmanypackagefile" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/packagefiletest"
tofile="${eclipsepath}target/cheese.rules"
classpathref="cheese.classpath" >
<include name="*.drl" />
<include name="*.brl" />
- </rulebase>
+ </compiler>
</target>
</project>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list