Skip to content

Instantly share code, notes, and snippets.

@alfanick
Last active December 29, 2015 18:39
Show Gist options
  • Save alfanick/7712567 to your computer and use it in GitHub Desktop.
Save alfanick/7712567 to your computer and use it in GitHub Desktop.
Ant do droolsa
Config do drools do anta. Koniec z eclipse, tworzy jarke do dwukliku, pliki możecie wrzucić do środka i korzystać z Class::getResource().
Założenia:
- w lib/ znajduja się wasze dodatkowe jarki, w lib/drools koniecznie (!) znajdują się jarki droolsa, musicie je gdzieś znaleźć, może być symlink do nich
- do lib musicie też skopiować magiczny plik z eclipse/plugins - org.eclipse.jdt.core_3.9.1.v20130905-0837.jar
- w src są pliki źródłowe
- nazwa klasy z mainem to com.sample.DroolsTest - można zmienić - linia #8
- w katalogu src/main/rules są pliki drl, kopiowane do jarki
- w katalogu rsc są wasze różne pliki - u mnie yaml z pytaniami, można zmienić, linie #31-33, quite obvious
- w linii #2 można zmienić nazwę projektu, zbudowana jarka jest w build/jar i zawiera wszystko co potrzebne
To taki javowy make, tlyko wpisujecie ant i śmiga :)
<?xml version="1.0" encoding="UTF-8"?>
<project name="NAZWAPROJEKTU" basedir="." default="main">
<property name="src.dir" value="src" />
<property name="lib.dir" value="lib/" />
<property name="build.dir" value="build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="jar.dir" value="${build.dir}/jar" />
<property name="main-class" value="com.sample.DroolsTest" />
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
<include name="drools/*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="compile">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}">
<classpath refid="classpath" />
</javac>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<fileset dir="${src.dir}/main/rules">
<include name="**/*.drl" />
</fileset>
<metainf dir="" includes="*.conf" />
<fileset dir="rsc/" >
<include name="*.yaml" />
</fileset>
<zipfileset excludes="META-INF/**/*" src="lib/org.eclipse.jdt.core_3.9.1.v20130905-0837.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/antlr-runtime.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/drools-compiler.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/drools-core.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/drools-decisiontables.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/drools-jsr94.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/drools-templates.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/droolsjbpm-ide-common.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/guvnor-api.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/jbpm-bpmn2.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/jbpm-flow-builder.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/jbpm-flow.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/jsr94.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/junit.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/jxl.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/knowledge-api.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/knowledge-internal-api.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/mvel2.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/slf4j-api.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/xmlpull.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/xpp3_min.jar" />
<zipfileset excludes="META-INF/**/*" src="lib/drools/xstream.jar" />
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true">
<classpath>
<path refid="classpath" />
<path location="${jar.dir}/${ant.project.name}.jar" />
</classpath>
</java>
</target>
<target name="clean-build" depends="clean,jar" />
<target name="main" depends="clean,run" />
</project>
drools.dialect.default = java
drools.dialect.java = org.drools.rule.builder.dialect.java.JavaDialectConfiguration
drools.dialect.java.compiler = ECLIPSE
drools.dialect.mvel = org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration
drools.dialect.mvel.strict = true
drools.dialect.mvel.langLevel = 4
drools.accumulate.function.average = org.drools.base.accumulators.AverageAccumulateFunction
drools.accumulate.function.max = org.drools.base.accumulators.MaxAccumulateFunction
drools.accumulate.function.min = org.drools.base.accumulators.MinAccumulateFunction
drools.accumulate.function.count = org.drools.base.accumulators.CountAccumulateFunction
drools.accumulate.function.sum = org.drools.base.accumulators.SumAccumulateFunction
drools.accumulate.function.collectList = org.drools.base.accumulators.CollectListAccumulateFunction
drools.accumulate.function.collectSet = org.drools.base.accumulators.CollectSetAccumulateFunction
drools.evaluator.coincides = org.drools.base.evaluators.CoincidesEvaluatorDefinition
drools.evaluator.before = org.drools.base.evaluators.BeforeEvaluatorDefinition
drools.evaluator.after = org.drools.base.evaluators.AfterEvaluatorDefinition
drools.evaluator.meets = org.drools.base.evaluators.MeetsEvaluatorDefinition
drools.evaluator.metby = org.drools.base.evaluators.MetByEvaluatorDefinition
drools.evaluator.overlaps = org.drools.base.evaluators.OverlapsEvaluatorDefinition
drools.evaluator.overlappedby = org.drools.base.evaluators.OverlappedByEvaluatorDefinition
drools.evaluator.during = org.drools.base.evaluators.DuringEvaluatorDefinition
drools.evaluator.includes = org.drools.base.evaluators.IncludesEvaluatorDefinition
drools.evaluator.starts = org.drools.base.evaluators.StartsEvaluatorDefinition
drools.evaluator.startedby = org.drools.base.evaluators.StartedByEvaluatorDefinition
drools.evaluator.finishes = org.drools.base.evaluators.FinishesEvaluatorDefinition
drools.evaluator.finishedby = org.drools.base.evaluators.FinishedByEvaluatorDefinition
#drools.evaluator.equality = org.drools.base.evaluators.EqualityEvaluatorsDefinition
#drools.evaluator.comparable = org.drools.base.evaluators.ComparableEvaluatorsDefinition
#drools.evaluator.set = org.drools.base.evaluators.SetEvaluatorsDefinition
#drools.evaluator.matches = org.drools.base.evaluators.MatchesEvaluatorsDefinition
#drools.evaluator.soundslike = org.drools.base.evaluators.SoundslikeEvaluatorsDefinition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment