0

I am doing a sample hello world maven project using drools version 6.0.0.Final. Below is the build of my pom file, i have specified the kie-maven-plugin but i can notice that this plugin couldnt get executed. Is there anything i am missing here.

<build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.kie</groupId>
                <artifactId>kie-maven-plugin</artifactId>
                <version>${kieVersion}</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
        </build>
vashishth
  • 2,751
  • 4
  • 38
  • 68
  • 1
    When you say that something's not working, it's usually a good idea to provide error messages and the like. We're not mind readers. Going by your example, you're a long way from having a working pom.xml. I'm not sure whether there are any decent tutorials around yet, but you could take a look at some of the examples here: https://github.com/droolsjbpm/drools/blob/master/drools-examples/pom.xml – Steve Jun 05 '14 at 14:46
  • There is no error. Only thing is in my maven console i can see that kie-maven plugin is not get executed. And in built jar there are not compiled code for rule artifacts. Rule artifacts only get complied when i deploy that jar file. That why i was asking if anyone has used this plug in before. – vashishth Jun 09 '14 at 05:36
  • Assuming that you mean DRL and other such code, then those don't get compiled until runtime when you load them into a knowledge base. You won't see any compiled artifacts in any jars. – Steve Jun 10 '14 at 09:37
  • But is possible to pre-compile the drools rules before deploying into container and this kie-maven-plugin is to do the pre-compilation as per the redhat brms docs. – vashishth Jun 11 '14 at 05:41
  • From what I could gather from the mailing list recently, it doesn't actually do any pre-compilation of artifacts before packaging them in a jar at the moment. Maybe newer versions will... – Steve Jun 11 '14 at 08:19

4 Answers4

1

Your config looks ok, but you might hit some missing plugin dependencies.

Using the latest version of the kie-maven-plugin (6.0.3-redhat-4) it does pre-compile the drl/xls etc.. rules inside the module into the jar. You can find the precompiled content in the jar if you crack it open - yourmodule-version.jar/META-INF/defaultKieBase/kbase.cache.

You should also see, as maven is building, the kie-maven-plugins "build" output on the console - just to check it is executing.

mallen
  • 51
  • 3
1

I know it is an old question, but did you specify the correct packaging?

<project xmlns="http://maven.apache.org/POM/4.0.0" >
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foo</groupId>
    <artifactId>fighting</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>kjar</packaging>

Together with using the kie-maven plugin?

raphaëλ
  • 6,393
  • 2
  • 29
  • 35
  • no i didn't use the packaging kjar. Is it necessary to use packaging kjar, since i am having existing project which have packaging as jar and i need to add rule files to the same plugin, i cannot change the packaging also. – vashishth Oct 14 '14 at 14:32
  • But you want drools to build a kjar (i mean you want the precompiled rules etc). This sounds you don't want a normal jar but a kjar (which is a jar with drools specifics in the META-INF folder) – raphaëλ Oct 14 '14 at 15:39
  • I may presented my requirement wrongly, but in my scenario i have jar not kjar, and in that very same project i needed to add the drools files, and by reading document i though that just by adding the kie-plugin it will compile my rule artifacts. So is it compulsory to have kjar for precompiling drools artifacts ?? – vashishth Oct 14 '14 at 18:53
  • It is still a jar (same extenstion) just with some drools extras in the archive which should not bother other usage of the jar file. – raphaëλ Oct 14 '14 at 19:45
1

Got the same problem with 6.3.0. Here is the code I'm using to activate the drools compilation :

<plugin>
    <groupId>org.kie</groupId>
    <artifactId>kie-maven-plugin</artifactId>
    <version>6.3.0.Final-redhat-9</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <id>brms-rules-compilation</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>build</goal>
            </goals>
            <inherited>false</inherited>
            <configuration>
            </configuration>
        </execution>
    </executions>
</plugin>

I had to specifically tell Maven to execute the build goal during generate-resources phase to get a plugin console output :

[INFO] --- kie-maven-plugin:6.3.0.Final-redhat-9:build (brms-rules-compilation) @ myProject ---
[main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - Adding KieModule from resource [.....]
Wis
  • 705
  • 1
  • 11
  • 34
0

This is quite an old topic but I just had the same issue, and found nothing to help me. In my case, it was not a configuration error, but a rule synthax error.

I had something like :

when $a : A(status == Status.OK, $val = val)

Instead of :

when $a : A(status == OK, $val : val)

Changing the " = " to " : " fixed it. I don't know why it refered to KIE though.

Thoomsi
  • 1
  • 3