diff --git a/kie-examples-api/kie-maven-example/pom.xml b/kie-examples-api/kie-maven-example/pom.xml deleted file mode 100644 index e7054f2fd4..0000000000 --- a/kie-examples-api/kie-maven-example/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - 4.0.0 - - org.kie - kie-examples-api - 6.4.0-SNAPSHOT - - - org.kie - kie-maven-example - Kie maven plugin example - - kjar - - - - org.drools - drools-compiler - - - - - - - - - org.kie - kie-maven-plugin - ${version.org.drools} - - - - - - org.kie - kie-maven-plugin - true - - - - diff --git a/kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/KieMavenPluginExample.java b/kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/KieMavenPluginExample.java deleted file mode 100644 index 5f0aac56b3..0000000000 --- a/kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/KieMavenPluginExample.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -package org.kie.example.api.kiemavenexample; - -import org.kie.api.KieServices; -import org.kie.api.runtime.KieContainer; -import org.kie.api.runtime.KieSession; - -import java.io.PrintStream; - -public class KieMavenPluginExample { - - public void go(PrintStream out) { - KieServices ks = KieServices.Factory.get(); - KieContainer kContainer = ks.getKieClasspathContainer(); - - KieSession kSession = kContainer.newKieSession(); - kSession.setGlobal("out", out); - kSession.insert(new Message("Dave", "Hello, HAL. Do you read me, HAL?")); - kSession.fireAllRules(); - } - - - public static void main(String[] args) { - new KieMavenPluginExample().go(System.out); - } - -} diff --git a/kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/Message.java b/kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/Message.java deleted file mode 100644 index d4ab7373af..0000000000 --- a/kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/Message.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2015 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -package org.kie.example.api.kiemavenexample; - -public class Message { - - private String name; - private String text; - - public Message(String name, String text) { - this.text = text; - this.name = name; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String toString() { - return "Message[name='" + name + "' text='" + text + "'"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((text == null) ? 0 : text.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { return true; } - if (obj == null) { return false; } - if (getClass() != obj.getClass()) { return false; } - Message other = (Message) obj; - if (name == null) { - if (other.name != null) { return false; } - } else if (!name.equals(other.name)) { return false; } - if (text == null) { - if (other.text != null) { return false; } - } else if (!text.equals(other.text)) { return false; } - return true; - } - -} diff --git a/kie-examples-api/kie-maven-example/src/main/resources/META-INF/kmodule.xml b/kie-examples-api/kie-maven-example/src/main/resources/META-INF/kmodule.xml deleted file mode 100644 index 54755519f0..0000000000 --- a/kie-examples-api/kie-maven-example/src/main/resources/META-INF/kmodule.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/kie-examples-api/kie-maven-example/src/main/resources/logback.xml b/kie-examples-api/kie-maven-example/src/main/resources/logback.xml deleted file mode 100644 index ec8db95c8d..0000000000 --- a/kie-examples-api/kie-maven-example/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - %d [%t] %-5p %m%n - - - - - - - - - - - - diff --git a/kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginExampleTest.java b/kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginExampleTest.java deleted file mode 100644 index d6727d174e..0000000000 --- a/kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginExampleTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -package org.kie.example.api.kiemavenexample; - -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import static org.junit.Assert.assertEquals; - -public class KieMavenPluginExampleTest { - - @Test - public void testGo() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - new KieMavenPluginExample().go(ps); - ps.close(); - - String actual = new String(baos.toByteArray()); - String expected = "" + - "Dave: Hello, HAL. Do you read me, HAL?\n" + - "HAL: Dave. I read you.\n"; - assertEquals(expected, actual); - } -} diff --git a/kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginFromFSExampleTest.java b/kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginFromFSExampleTest.java deleted file mode 100644 index 5e13818cc4..0000000000 --- a/kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginFromFSExampleTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2015 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -package org.kie.example.api.kiemavenexample; - -import org.junit.Test; -import org.kie.api.KieServices; -import org.kie.api.builder.KieBuilder; -import org.kie.api.runtime.KieSession; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; - -import static org.junit.Assert.assertEquals; - -public class KieMavenPluginFromFSExampleTest { - - @Test - public void testGo() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - go(ps); - ps.close(); - - String actual = new String(baos.toByteArray()); - if (File.separatorChar == '\\') { - actual = actual.replaceAll("\r\n", "\n"); - } - - String expected = "" + - "Dave: Hello, HAL. Do you read me, HAL?\n" + - "HAL: Dave. I read you.\n"; - - assertEquals(expected, actual); - } - - public void go(PrintStream out) { - String currentFolder = null; - try { - currentFolder = new File(".").getCanonicalPath(); - } catch (IOException e) { - throw new RuntimeException(e); - } - - File rootFolder = null; - if (currentFolder.endsWith("-integration")) { - rootFolder = new File("kie-examples-api/kie-maven-example"); - } else if (currentFolder.endsWith("drools-examples-api")) { - rootFolder = new File("kie-maven-example"); - } else { - rootFolder = new File("."); - } - - KieServices ks = KieServices.Factory.get(); - KieBuilder kieBuilder = ks.newKieBuilder(rootFolder).buildAll(); - - KieSession kSession = ks.newKieContainer(kieBuilder.getKieModule().getReleaseId()).newKieSession(); - kSession.setGlobal("out", out); - kSession.insert(new Message("Dave", "Hello, HAL. Do you read me, HAL?")); - kSession.fireAllRules(); - } -} diff --git a/kie-examples-api/pom.xml b/kie-examples-api/pom.xml deleted file mode 100644 index 5194b5b9b2..0000000000 --- a/kie-examples-api/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - org.drools - droolsjbpm-integration - 6.4.0-SNAPSHOT - - - org.kie - kie-examples-api - Kie API examples - - - - org.kie - kie-api - - - - pom - - kie-maven-example - - - - diff --git a/kie-examples-api/.gitignore b/kie-maven-plugin-example/.gitignore similarity index 100% rename from kie-examples-api/.gitignore rename to kie-maven-plugin-example/.gitignore diff --git a/kie-maven-plugin-example/pom.xml b/kie-maven-plugin-example/pom.xml new file mode 100644 index 0000000000..20824abfbd --- /dev/null +++ b/kie-maven-plugin-example/pom.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + + org.drools + droolsjbpm-integration + 6.4.0-SNAPSHOT + + + org.kie + kie-maven-plugin-example + + kjar + + + + org.drools + drools-core + test + + + org.drools + drools-compiler + test + + + + + + + org.kie + kie-maven-plugin + ${project.version} + true + + + + diff --git a/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Fire.java b/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Fire.java new file mode 100644 index 0000000000..02533b1c0d --- /dev/null +++ b/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Fire.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample.model; + +public class Fire { + + private Room room; + + public Fire() { } + + public Fire(Room room) { + this.room = room; + } + + public Room getRoom() { + return room; + } + + public void setRoom(Room room) { + this.room = room; + } +} diff --git a/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Room.java b/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Room.java new file mode 100644 index 0000000000..222d298d96 --- /dev/null +++ b/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Room.java @@ -0,0 +1,51 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample.model; + +public class Room { + + private String name; + + public Room() { } + + public Room(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Room)) { return false; } + return name.equals(((Room) obj).getName()); + } + + @Override + public String toString() { + return name; + } +} diff --git a/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Sprinkler.java b/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Sprinkler.java new file mode 100644 index 0000000000..55bddc3461 --- /dev/null +++ b/kie-maven-plugin-example/src/main/java/org/kie/sample/model/Sprinkler.java @@ -0,0 +1,60 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample.model; + +public class Sprinkler { + + private Room room; + private boolean on = false; + + public Sprinkler() { } + + public Sprinkler(Room room) { + this.room = room; + } + + public Room getRoom() { + return room; + } + + public void setRoom(Room room) { + this.room = room; + } + + public boolean isOn() { + return on; + } + + public void setOn(boolean on) { + this.on = on; + } + + @Override + public int hashCode() { + return room.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Sprinkler)) { return false; } + return room.equals(((Sprinkler) obj).getRoom()); + } + + @Override + public String toString() { + return "Sprinkler for " + room; + } +} diff --git a/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/alarm.drl b/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/alarm.drl new file mode 100644 index 0000000000..ed11707d75 --- /dev/null +++ b/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/alarm.drl @@ -0,0 +1,18 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample.model +declare Alarm +end \ No newline at end of file diff --git a/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules.drl b/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules.drl new file mode 100644 index 0000000000..2334d0a949 --- /dev/null +++ b/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules.drl @@ -0,0 +1,38 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample + +import java.util.* +import org.kie.sample.model.* + +rule "When there is a fire turn on the sprinkler" +when + $fire: Fire($room : room) + $sprinkler : Sprinkler( room == $room, !on ) +then + modify( $sprinkler ) { setOn( true ) }; + System.out.println( "Turn on the sprinkler for room " + $room.getName() ); +end + +rule "When the fire is gone turn off the sprinkler" +when + $room : Room( ) + $sprinkler : Sprinkler( room == $room, on ) + not Fire( room == $room ) +then + modify( $sprinkler ) { setOn( false ) }; + System.out.println( "Turn off the sprinkler for room " + $room.getName() ); +end diff --git a/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules2.drl b/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules2.drl new file mode 100644 index 0000000000..1d1a3bce3e --- /dev/null +++ b/kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules2.drl @@ -0,0 +1,44 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample + +import java.util.* +import org.kie.sample.model.* + +rule "Raise the alarm when we have one or more fires" +when + exists Fire() +then + insert( new Alarm() ); + System.out.println( "Raise the alarm" ); +end + +rule "Cancel the alarm when all the fires have gone" +when + not Fire() + $alarm : Alarm() +then + retract( $alarm ); + System.out.println( "Cancel the alarm" ); +end + +rule "Status output when things are ok" +when + not Alarm() + not Sprinkler( on == true ) +then + System.out.println( "Everything is ok" ); +end diff --git a/kie-maven-plugin-example/src/main/resources/KBase1/decA.drl b/kie-maven-plugin-example/src/main/resources/KBase1/decA.drl new file mode 100644 index 0000000000..4e4f6bed23 --- /dev/null +++ b/kie-maven-plugin-example/src/main/resources/KBase1/decA.drl @@ -0,0 +1,19 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.test +declare FactA + fieldB: FactB +end \ No newline at end of file diff --git a/kie-maven-plugin-example/src/main/resources/KBase1/decB.drl b/kie-maven-plugin-example/src/main/resources/KBase1/decB.drl new file mode 100644 index 0000000000..361d829aff --- /dev/null +++ b/kie-maven-plugin-example/src/main/resources/KBase1/decB.drl @@ -0,0 +1,19 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.test +declare FactB + fieldA: FactA +end \ No newline at end of file diff --git a/kie-maven-plugin-example/src/main/resources/KBase1/rule.drl b/kie-maven-plugin-example/src/main/resources/KBase1/rule.drl new file mode 100644 index 0000000000..80ecdbf06d --- /dev/null +++ b/kie-maven-plugin-example/src/main/resources/KBase1/rule.drl @@ -0,0 +1,21 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.test +rule R1 when + $fieldA : FactA( $fieldB : fieldB ) + FactB( this == $fieldB, fieldA == $fieldA ) +then +end \ No newline at end of file diff --git a/kie-maven-plugin-example/src/main/resources/META-INF/kmodule.xml b/kie-maven-plugin-example/src/main/resources/META-INF/kmodule.xml new file mode 100644 index 0000000000..2688cea1c2 --- /dev/null +++ b/kie-maven-plugin-example/src/main/resources/META-INF/kmodule.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/kie-maven-plugin-example/src/test/java/org/kie/kproject/KProjectTest.java b/kie-maven-plugin-example/src/test/java/org/kie/kproject/KProjectTest.java new file mode 100644 index 0000000000..2944a5a712 --- /dev/null +++ b/kie-maven-plugin-example/src/test/java/org/kie/kproject/KProjectTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.kproject; + +import org.junit.Ignore; +import org.junit.Test; +import org.kie.api.KieServices; +import org.kie.api.runtime.KieContainer; +import org.kie.api.runtime.KieSession; +import org.kie.api.runtime.rule.FactHandle; +import org.kie.sample.model.Fire; +import org.kie.sample.model.Room; +import org.kie.sample.model.Sprinkler; + +import static org.junit.Assert.assertEquals; + +public class KProjectTest { + + @Test + public void testKJar() throws Exception { + KieServices ks = KieServices.Factory.get(); + KieContainer kContainer = ks.getKieClasspathContainer(); + KieSession kSession = kContainer.newKieSession("FireAlarmKBase.session"); + + Room room = new Room("101"); + kSession.insert(room); + Sprinkler sprinkler = new Sprinkler(room); + kSession.insert(sprinkler); + Fire fire = new Fire(room); + FactHandle fireFH = kSession.insert(fire); + + int rules = kSession.fireAllRules(); + assertEquals(2, rules); + + kSession.delete(fireFH); + rules = kSession.fireAllRules(); + assertEquals(3, rules); + } +} diff --git a/kie-examples-api/kie-maven-example/.gitignore b/kie-maven-plugin/.gitignore similarity index 100% rename from kie-examples-api/kie-maven-example/.gitignore rename to kie-maven-plugin/.gitignore diff --git a/kie-maven-plugin/pom.xml b/kie-maven-plugin/pom.xml new file mode 100644 index 0000000000..9489d1b58e --- /dev/null +++ b/kie-maven-plugin/pom.xml @@ -0,0 +1,218 @@ + + + + 4.0.0 + + org.drools + droolsjbpm-integration + 6.4.0-SNAPSHOT + + + org.kie + kie-maven-plugin + maven-plugin + + KIE :: Maven Plugin + + + + + maven-plugin-plugin + + kie + + + + generated-helpmojo + + helpmojo + + + + generate-descriptor + + descriptor + + + + + + org.codehaus.plexus + plexus-component-metadata + + + + generate-metadata + generate-test-metadata + + + + + + io.takari.maven.plugins + takari-lifecycle-plugin + 1.10.2 + true + + + testProperties + process-test-resources + + testProperties + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + -Xms512m -Xmx1024m -XX:MaxPermSize=1024m + + + + + + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.3 + provided + + + org.codehaus.plexus + plexus-component-annotations + 1.5.5 + + + org.codehaus.plexus + plexus-container-default + 1.5.5 + + + io.takari.maven.plugins + takari-plugin-testing + 2.1.0 + + + io.takari.maven.plugins + takari-plugin-integration-testing + 2.1.0 + pom + + + + + + + org.apache.maven + maven-artifact + + + org.apache.maven + maven-core + + + org.apache.maven + maven-plugin-api + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + test + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + org.codehaus.plexus + plexus-component-annotations + + + org.codehaus.plexus + plexus-classworlds + + + org.codehaus.plexus + plexus-container-default + + + + com.google.protobuf + protobuf-java + + + + + org.drools + drools-core + + + org.drools + drools-compiler + + + org.kie + kie-api + + + org.kie + kie-internal + + + + org.drools + drools-decisiontables + + + org.drools + drools-templates + + + org.drools + drools-scorecards + + + org.drools + drools-pmml + + + org.jbpm + jbpm-bpmn2 + + + + + org.apache.maven + maven-compat + test + + + io.takari.maven.plugins + takari-plugin-testing + test + + + io.takari.maven.plugins + takari-plugin-integration-testing + pom + test + + + ch.qos.logback + logback-classic + test + + + + junit + junit + test + + + diff --git a/kie-maven-plugin/src/main/java/org/kie/maven/plugin/BuildMojo.java b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/BuildMojo.java new file mode 100644 index 0000000000..770a096127 --- /dev/null +++ b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/BuildMojo.java @@ -0,0 +1,179 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.maven.plugin; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DependencyResolutionRequiredException; +import org.apache.maven.artifact.resolver.filter.CumulativeScopeArtifactFilter; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.drools.compiler.compiler.BPMN2ProcessFactory; +import org.drools.compiler.compiler.DecisionTableFactory; +import org.drools.compiler.compiler.PMMLCompilerFactory; +import org.drools.compiler.compiler.ProcessBuilderFactory; +import org.drools.compiler.kie.builder.impl.InternalKieModule; +import org.drools.compiler.kie.builder.impl.KieContainerImpl; +import org.drools.compiler.kie.builder.impl.KieMetaInfoBuilder; +import org.drools.compiler.kie.builder.impl.KieProject; +import org.drools.compiler.kie.builder.impl.ResultsImpl; +import org.drools.compiler.kie.builder.impl.ZipKieModule; +import org.drools.compiler.kproject.ReleaseIdImpl; +import org.drools.compiler.kproject.models.KieModuleModelImpl; +import org.kie.api.KieServices; +import org.kie.api.builder.KieRepository; +import org.kie.api.builder.Message; +import org.kie.api.builder.ReleaseId; +import org.kie.api.builder.model.KieModuleModel; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import static org.drools.compiler.kie.builder.impl.KieBuilderImpl.setDefaultsforEmptyKieModule; + +/** + * This goal builds the drools file belonging to the kproject. + * + * @goal build + * @phase compile + */ +public class BuildMojo extends AbstractMojo { + + /** + * Directory containing the generated JAR. + * + * @parameter default-value="${project.build.outputDirectory}" + * @required + */ + private File outputDirectory; + + /** + * Project sourceFolder folder. + * + * @parameter default-value="src/main/resources" + * @required + */ + private File sourceFolder; + + /** + * @parameter default-value="${project}" + * @required + */ + private MavenProject project; + + public void execute() throws MojoExecutionException, MojoFailureException { + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + + List kmoduleDeps = new ArrayList(); + + try { + Set urls = new HashSet(); + for (String element : project.getCompileClasspathElements()) { + urls.add(new File(element).toURI().toURL()); + } + + project.setArtifactFilter(new CumulativeScopeArtifactFilter(Arrays.asList("compile", "runtime"))); + for (Artifact artifact : project.getArtifacts()) { + File file = artifact.getFile(); + if (file != null) { + urls.add(file.toURI().toURL()); + KieModuleModel depModel = getDependencyKieModel(file); + if (depModel != null) { + ReleaseId releaseId = new ReleaseIdImpl(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); + kmoduleDeps.add(new ZipKieModule(releaseId, depModel, file)); + } + } + } + urls.add(outputDirectory.toURI().toURL()); + + ClassLoader projectClassLoader = URLClassLoader.newInstance(urls.toArray(new URL[0]), + Thread.currentThread().getContextClassLoader()); + + Thread.currentThread().setContextClassLoader(projectClassLoader); + + BPMN2ProcessFactory.loadProvider(projectClassLoader); + DecisionTableFactory.loadProvider(projectClassLoader); + ProcessBuilderFactory.loadProvider(projectClassLoader); + PMMLCompilerFactory.loadProvider(projectClassLoader); + + } catch (DependencyResolutionRequiredException e) { + throw new RuntimeException(e); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + + KieServices ks = KieServices.Factory.get(); + + try { + KieRepository kr = ks.getRepository(); + InternalKieModule kModule = (InternalKieModule)kr.addKieModule(ks.getResources().newFileSystemResource(sourceFolder)); + for (InternalKieModule kmoduleDep : kmoduleDeps) { + kModule.addKieDependency(kmoduleDep); + } + + KieContainerImpl kContainer = (KieContainerImpl) ks.newKieContainer(kModule.getReleaseId()); + + KieProject kieProject = kContainer.getKieProject(); + ResultsImpl messages = kieProject.verify(); + + List errors = messages.filterMessages(Message.Level.ERROR); + if (!errors.isEmpty()) { + for (Message error : errors) { + getLog().error(error.toString()); + } + throw new MojoFailureException("Build failed!"); + } else { + new KieMetaInfoBuilder(new DiskResourceStore(outputDirectory), (InternalKieModule)kModule).writeKieModuleMetaInfo(); + } + } finally { + Thread.currentThread().setContextClassLoader(contextClassLoader); + } + getLog().info("KieModule successfully built!"); + } + + private KieModuleModel getDependencyKieModel(File jar) { + ZipFile zipFile = null; + try { + zipFile = new ZipFile( jar ); + ZipEntry zipEntry = zipFile.getEntry( KieModuleModelImpl.KMODULE_JAR_PATH ); + if (zipEntry != null) { + KieModuleModel kieModuleModel = KieModuleModelImpl.fromXML(zipFile.getInputStream(zipEntry)); + setDefaultsforEmptyKieModule(kieModuleModel); + return kieModuleModel; + } + } catch ( Exception e ) { + } finally { + if (zipFile != null) { + try { + zipFile.close(); + } catch (IOException e) { + } + } + } + return null; + } +} diff --git a/kie-maven-plugin/src/main/java/org/kie/maven/plugin/DiskResourceStore.java b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/DiskResourceStore.java new file mode 100644 index 0000000000..cc49cdb8f0 --- /dev/null +++ b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/DiskResourceStore.java @@ -0,0 +1,98 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.maven.plugin; + +import org.drools.compiler.commons.jci.stores.ResourceStore; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.drools.core.util.IoUtils.readBytesFromInputStream; + +public class DiskResourceStore implements ResourceStore { + private final File root; + + public DiskResourceStore(File root) { + this.root = root; + } + + @Override + public void write(String pResourceName, byte[] pResourceData) { + write(pResourceName, pResourceData, false); + } + + @Override + public void write(String pResourceName, byte[] pResourceData, boolean createFolder) { + File file = new File(getFilePath(pResourceName)); + if (createFolder) { + File dir = file.getParentFile(); + if (!dir.exists()) { + dir.mkdirs(); + } + } + + FileOutputStream fos = null; + try { + fos = new FileOutputStream(file); + fos.write(pResourceData); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { } + } + } + } + + @Override + public byte[] read(String pResourceName) { + FileInputStream fis = null; + try { + fis = new FileInputStream(getFilePath(pResourceName)); + return readBytesFromInputStream(fis); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { } + } + } + } + + @Override + public void remove(String pResourceName) { + File file = new File(getFilePath(pResourceName)); + if (file.exists()) { + file.delete(); + } + } + + private String getFilePath(String pResourceName) { + return root.getAbsolutePath() + File.separator + pResourceName; + } +} diff --git a/kie-maven-plugin/src/main/java/org/kie/maven/plugin/IncludeProjectDependenciesComponentConfigurator.java b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/IncludeProjectDependenciesComponentConfigurator.java new file mode 100644 index 0000000000..a86ba4eb18 --- /dev/null +++ b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/IncludeProjectDependenciesComponentConfigurator.java @@ -0,0 +1,97 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.maven.plugin; + +import org.codehaus.classworlds.ClassRealm; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.configurator.AbstractComponentConfigurator; +import org.codehaus.plexus.component.configurator.ComponentConfigurationException; +import org.codehaus.plexus.component.configurator.ComponentConfigurator; +import org.codehaus.plexus.component.configurator.ConfigurationListener; +import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter; +import org.codehaus.plexus.component.configurator.converters.special.ClassRealmConverter; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.logging.console.ConsoleLogger; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * A custom ComponentConfigurator which adds the project's runtime classpath elements + * to the + */ +@Component(role=ComponentConfigurator.class, hint="include-project-dependencies") +public class IncludeProjectDependenciesComponentConfigurator extends AbstractComponentConfigurator { + + private static final Logger LOGGER = new ConsoleLogger(Logger.LEVEL_DEBUG, "Configurator"); + + public void configureComponent( Object component, PlexusConfiguration configuration, + ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, + ConfigurationListener listener ) + throws ComponentConfigurationException { + + addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm); + + converterLookup.registerConverter( new ClassRealmConverter( containerRealm ) ); + + ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); + + converter.processConfiguration( converterLookup, component, containerRealm.getClassLoader(), configuration, + expressionEvaluator, listener ); + } + + private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { + List runtimeClasspathElements; + try { + //noinspection unchecked + runtimeClasspathElements = (List) expressionEvaluator.evaluate("${project.runtimeClasspathElements}"); + } catch (ExpressionEvaluationException e) { + throw new ComponentConfigurationException("There was a problem evaluating: ${project.runtimeClasspathElements}", e); + } + + // Add the project dependencies to the ClassRealm + final URL[] urls = buildURLs(runtimeClasspathElements); + for (URL url : urls) { + containerRealm.addConstituent(url); + } + } + + private URL[] buildURLs(List runtimeClasspathElements) throws ComponentConfigurationException { + // Add the projects classes and dependencies + List urls = new ArrayList(runtimeClasspathElements.size()); + for (String element : runtimeClasspathElements) { + try { + final URL url = new File(element).toURI().toURL(); + urls.add(url); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Added to project class loader: " + url); + } + } catch (MalformedURLException e) { + throw new ComponentConfigurationException("Unable to access project dependency: " + element, e); + } + } + + // Add the plugin's dependencies (so Trove stuff works if Trove isn't on + return urls.toArray(new URL[urls.size()]); + } + +} diff --git a/kie-maven-plugin/src/main/java/org/kie/maven/plugin/SerializeMojo.java b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/SerializeMojo.java new file mode 100644 index 0000000000..014a9e8cf1 --- /dev/null +++ b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/SerializeMojo.java @@ -0,0 +1,93 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.maven.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.drools.core.util.DroolsStreamUtils; +import org.kie.api.KieBase; +import org.kie.api.KieServices; +import org.kie.api.builder.Message; +import org.kie.api.builder.Results; +import org.kie.api.runtime.KieContainer; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.List; + +/** + * Compiles and serializes knowledge packages. + */ +@Mojo(name = "serialize", + requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, + requiresProject = true, + defaultPhase = LifecyclePhase.COMPILE, + configurator = "include-project-dependencies") +public class SerializeMojo extends AbstractMojo { + + /** + * KnowledgeBases to serialize + */ + @Parameter(property = "kie.kiebases",required = true) + private List kiebases; + + /** + * Output folder + */ + @Parameter(property = "kie.resDirectory", defaultValue = "${project.basedir}/src/main/res/raw" ) + private String resDirectory; + + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + try { + File outputFolder = new File(resDirectory); + outputFolder.mkdirs(); + + KieServices ks = KieServices.Factory.get(); + KieContainer kc = ks.newKieClasspathContainer(); + Results messages = kc.verify(); + + List warnings = messages.getMessages(Message.Level.WARNING); + for (Message warning : warnings) { + getLog().warn(warning.toString()); + } + List errors = messages.getMessages(Message.Level.ERROR); + if (!errors.isEmpty()) { + for (Message error : errors) { + getLog().error(error.toString()); + } + throw new MojoFailureException("Build failed!"); + } + + for(String kbase : kiebases) { + KieBase kb = kc.getKieBase(kbase); + getLog().info("Writing KBase: " + kbase); + File file = new File(outputFolder, kbase.replace('.', '_').toLowerCase()); + FileOutputStream out = new FileOutputStream(file); + DroolsStreamUtils.streamOut(out, kb.getKiePackages()); + out.close(); + } + } catch (Exception e) { + throw new MojoExecutionException("error", e); + } + } +} diff --git a/kie-maven-plugin/src/main/java/org/kie/maven/plugin/TouchResourcesMojo.java b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/TouchResourcesMojo.java new file mode 100644 index 0000000000..7986925e17 --- /dev/null +++ b/kie-maven-plugin/src/main/java/org/kie/maven/plugin/TouchResourcesMojo.java @@ -0,0 +1,92 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.maven.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.drools.core.util.DroolsStreamUtils; +import org.kie.api.KieBase; +import org.kie.api.KieServices; +import org.kie.api.builder.Message; +import org.kie.api.builder.Results; +import org.kie.api.io.ResourceType; +import org.kie.api.runtime.KieContainer; +import org.kie.internal.builder.KnowledgeBuilder; +import org.kie.internal.builder.KnowledgeBuilderConfiguration; +import org.kie.internal.builder.KnowledgeBuilderError; +import org.kie.internal.builder.KnowledgeBuilderFactory; +import org.kie.internal.definition.KnowledgePackage; +import org.kie.internal.io.ResourceFactory; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.Collection; +import java.util.List; +import java.util.Properties; + +/** + * Compiles and serializes knowledge packages. + * @author kedzie + * + */ +@Mojo(name = "touch", + requiresProject = true, + defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class TouchResourcesMojo extends AbstractMojo { + + /** + * DRL rule package + */ + @Parameter(property = "kie.ruleFiles",required = true) + private List ruleFiles; + + /** + * KnowledgeBases to serialize + */ + @Parameter(property = "kie.kiebases",required = true) + private List kiebases; + + /** + * Output folder + */ + @Parameter(property = "kie.resDirectory", defaultValue = "${project.basedir}/res/raw" ) + private String resDirectory; + + @Parameter(defaultValue = "${project}", required = true, readonly = true) + private MavenProject project; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + try { + File outputFolder = new File(resDirectory); + outputFolder.mkdirs(); + + for(String kbase : kiebases) { + getLog().info("Touching KBase: " + kbase); + File file = new File(outputFolder, kbase.replace('.', '_').toLowerCase()); + file.createNewFile(); + } + } catch (Exception e) { + throw new MojoExecutionException("error", e); + } + } +} diff --git a/kie-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/kie-maven-plugin/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 0000000000..a6d8019b5c --- /dev/null +++ b/kie-maven-plugin/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,37 @@ + + + + + + org.apache.maven.lifecycle.mapping.LifecycleMapping + kjar + org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping + + + org.apache.maven.plugins:maven-resources-plugin:resources + org.apache.maven.plugins:maven-compiler-plugin:compile,org.kie:kie-maven-plugin:build + org.apache.maven.plugins:maven-resources-plugin:testResources + org.apache.maven.plugins:maven-compiler-plugin:testCompile + org.apache.maven.plugins:maven-surefire-plugin:test + org.apache.maven.plugins:maven-jar-plugin:jar + org.apache.maven.plugins:maven-install-plugin:install + org.apache.maven.plugins:maven-deploy-plugin:deploy + + + + + + org.apache.maven.artifact.handler.ArtifactHandler + kjar + org.apache.maven.artifact.handler.DefaultArtifactHandler + + kjar + jar + jar + java + + + + + + \ No newline at end of file diff --git a/kie-maven-plugin/src/test/java/org/kie/maven/plugin/BuildMojoIntegrationTest.java b/kie-maven-plugin/src/test/java/org/kie/maven/plugin/BuildMojoIntegrationTest.java new file mode 100644 index 0000000000..d31f473591 --- /dev/null +++ b/kie-maven-plugin/src/test/java/org/kie/maven/plugin/BuildMojoIntegrationTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.maven.plugin; + +import io.takari.maven.testing.executor.MavenExecutionResult; +import io.takari.maven.testing.executor.MavenRuntime; +import org.junit.Test; + +import java.io.File; + +public class BuildMojoIntegrationTest extends KieMavenPluginBaseIntegrationTest { + + public BuildMojoIntegrationTest(MavenRuntime.MavenRuntimeBuilder builder) throws Exception { + super(builder); + } + + @Test + public void testCleanInstallWithAllSupportedResourceTypes() throws Exception { + File basedir = resources.getBasedir("kjar-2-all-resources"); + MavenExecutionResult result = mavenRuntime + .forProject(basedir) + .execute("clean", "install"); + result.assertErrorFreeLog(); + } + +} + diff --git a/kie-maven-plugin/src/test/java/org/kie/maven/plugin/KieMavenPluginBaseIntegrationTest.java b/kie-maven-plugin/src/test/java/org/kie/maven/plugin/KieMavenPluginBaseIntegrationTest.java new file mode 100644 index 0000000000..83182f6877 --- /dev/null +++ b/kie-maven-plugin/src/test/java/org/kie/maven/plugin/KieMavenPluginBaseIntegrationTest.java @@ -0,0 +1,38 @@ +/* + * Copyright 2015 JBoss by Red Hat + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.maven.plugin; + +import io.takari.maven.testing.TestResources; +import io.takari.maven.testing.executor.MavenRuntime; +import io.takari.maven.testing.executor.MavenVersions; +import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; +import org.junit.Rule; +import org.junit.runner.RunWith; + +@RunWith(MavenJUnitTestRunner.class) +@MavenVersions({"3.0.5", "3.2.3"}) +abstract public class KieMavenPluginBaseIntegrationTest { + + @Rule + public final TestResources resources = new TestResources(); + + public final MavenRuntime mavenRuntime; + + public KieMavenPluginBaseIntegrationTest(MavenRuntime.MavenRuntimeBuilder builder) throws Exception { + this.mavenRuntime = builder.forkedBuilder().withCliOptions("-X").build(); + } + +} diff --git a/kie-maven-plugin/src/test/java/org/kie/maven/plugin/SerializeMojoIntegrationTest.java b/kie-maven-plugin/src/test/java/org/kie/maven/plugin/SerializeMojoIntegrationTest.java new file mode 100644 index 0000000000..a42d87ada9 --- /dev/null +++ b/kie-maven-plugin/src/test/java/org/kie/maven/plugin/SerializeMojoIntegrationTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015 JBoss by Red Hat + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.maven.plugin; + +import io.takari.maven.testing.executor.MavenExecutionResult; +import io.takari.maven.testing.executor.MavenRuntime; +import org.junit.Ignore; +import org.junit.Test; + +import java.io.File; + +@Ignore("The test takes insane amount of time (minutes) to complete, because the serialization takes into account" + + "also huge amount of DRLs coming from drools-pmml. Will be investigated and fixed by psiroky.") +public class SerializeMojoIntegrationTest extends KieMavenPluginBaseIntegrationTest { + + public SerializeMojoIntegrationTest(MavenRuntime.MavenRuntimeBuilder builder) throws Exception { + super(builder); + } + + @Test + public void testCleanInstallWithSerialize() throws Exception { + File basedir = resources.getBasedir("kjar-1-with-serialize"); + MavenExecutionResult result = mavenRuntime + .forProject(basedir) + .execute("clean", "install"); + result.assertErrorFreeLog(); + } + +} diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/pom.xml b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/pom.xml new file mode 100644 index 0000000000..b718a76c96 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/pom.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + + org.kie + kie-maven-plugin-test-kjar-1 + 1.0.0.Final + + kjar + + + + + org.drools + drools-bom + + ${it-plugin.version} + import + pom + + + + + + + org.drools + drools-core + test + + + org.drools + drools-compiler + test + + + junit + junit + 4.12 + + + + + + + org.kie + kie-maven-plugin + ${it-plugin.version} + true + + + serialize + + serialize + + compile + + + KBase1 + + ${project.build.outputDirectory} + + + + + + + diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Fire.java b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Fire.java new file mode 100644 index 0000000000..d01f76a266 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Fire.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.sample.model; + +public class Fire { + + private Room room; + + public Fire() { } + + public Fire(Room room) { + this.room = room; + } + + public Room getRoom() { + return room; + } + + public void setRoom(Room room) { + this.room = room; + } +} diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Room.java b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Room.java new file mode 100644 index 0000000000..76bfb013b2 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Room.java @@ -0,0 +1,51 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.sample.model; + +public class Room { + + private String name; + + public Room() { } + + public Room(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Room)) { return false; } + return name.equals(((Room) obj).getName()); + } + + @Override + public String toString() { + return name; + } +} diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Sprinkler.java b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Sprinkler.java new file mode 100644 index 0000000000..b783e9dec7 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Sprinkler.java @@ -0,0 +1,60 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.sample.model; + +public class Sprinkler { + + private Room room; + private boolean on = false; + + public Sprinkler() { } + + public Sprinkler(Room room) { + this.room = room; + } + + public Room getRoom() { + return room; + } + + public void setRoom(Room room) { + this.room = room; + } + + public boolean isOn() { + return on; + } + + public void setOn(boolean on) { + this.on = on; + } + + @Override + public int hashCode() { + return room.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Sprinkler)) { return false; } + return room.equals(((Sprinkler) obj).getRoom()); + } + + @Override + public String toString() { + return "Sprinkler for " + room; + } +} diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/alarm.drl b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/alarm.drl new file mode 100644 index 0000000000..ed11707d75 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/alarm.drl @@ -0,0 +1,18 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample.model +declare Alarm +end \ No newline at end of file diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules.drl b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules.drl new file mode 100644 index 0000000000..2334d0a949 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules.drl @@ -0,0 +1,38 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample + +import java.util.* +import org.kie.sample.model.* + +rule "When there is a fire turn on the sprinkler" +when + $fire: Fire($room : room) + $sprinkler : Sprinkler( room == $room, !on ) +then + modify( $sprinkler ) { setOn( true ) }; + System.out.println( "Turn on the sprinkler for room " + $room.getName() ); +end + +rule "When the fire is gone turn off the sprinkler" +when + $room : Room( ) + $sprinkler : Sprinkler( room == $room, on ) + not Fire( room == $room ) +then + modify( $sprinkler ) { setOn( false ) }; + System.out.println( "Turn off the sprinkler for room " + $room.getName() ); +end diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules2.drl b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules2.drl new file mode 100644 index 0000000000..1d1a3bce3e --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules2.drl @@ -0,0 +1,44 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.sample + +import java.util.* +import org.kie.sample.model.* + +rule "Raise the alarm when we have one or more fires" +when + exists Fire() +then + insert( new Alarm() ); + System.out.println( "Raise the alarm" ); +end + +rule "Cancel the alarm when all the fires have gone" +when + not Fire() + $alarm : Alarm() +then + retract( $alarm ); + System.out.println( "Cancel the alarm" ); +end + +rule "Status output when things are ok" +when + not Alarm() + not Sprinkler( on == true ) +then + System.out.println( "Everything is ok" ); +end diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decA.drl b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decA.drl new file mode 100644 index 0000000000..4e4f6bed23 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decA.drl @@ -0,0 +1,19 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.test +declare FactA + fieldB: FactB +end \ No newline at end of file diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decB.drl b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decB.drl new file mode 100644 index 0000000000..361d829aff --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decB.drl @@ -0,0 +1,19 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.test +declare FactB + fieldA: FactA +end \ No newline at end of file diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/rule.drl b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/rule.drl new file mode 100644 index 0000000000..80ecdbf06d --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/rule.drl @@ -0,0 +1,21 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +package org.kie.test +rule R1 when + $fieldA : FactA( $fieldB : fieldB ) + FactB( this == $fieldB, fieldA == $fieldA ) +then +end \ No newline at end of file diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/META-INF/kmodule.xml b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/META-INF/kmodule.xml new file mode 100644 index 0000000000..a7b3bbbcca --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/META-INF/kmodule.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/test/java/org/kie/kproject/KProjectTest.java b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/test/java/org/kie/kproject/KProjectTest.java new file mode 100644 index 0000000000..770f55ea26 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/test/java/org/kie/kproject/KProjectTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2015 JBoss Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.kproject; + +import org.junit.Ignore; +import org.junit.Test; +import org.kie.api.KieServices; +import org.kie.api.runtime.KieContainer; +import org.kie.api.runtime.KieSession; +import org.kie.api.runtime.rule.FactHandle; +import org.kie.sample.model.Fire; +import org.kie.sample.model.Room; +import org.kie.sample.model.Sprinkler; + +import static org.junit.Assert.assertEquals; + +public class KProjectTest { + + @Test + public void testKJar() throws Exception { + KieServices ks = KieServices.Factory.get(); + KieContainer kContainer = ks.getKieClasspathContainer(); + KieSession kSession = kContainer.newKieSession("FireAlarmKBase.session"); + + Room room = new Room("101"); + kSession.insert(room); + Sprinkler sprinkler = new Sprinkler(room); + kSession.insert(sprinkler); + Fire fire = new Fire(room); + FactHandle fireFH = kSession.insert(fire); + + int rules = kSession.fireAllRules(); + assertEquals(2, rules); + + kSession.delete(fireFH); + rules = kSession.fireAllRules(); + assertEquals(3, rules); + } +} diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/pom.xml b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/pom.xml new file mode 100644 index 0000000000..7e3ea93491 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/pom.xml @@ -0,0 +1,23 @@ + + + + 4.0.0 + + org.kie + kie-maven-plugin-test-kjar-1 + 1.0.0.Final + + kjar + + + + + org.kie + kie-maven-plugin + ${it-plugin.version} + true + + + + diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/java/org/kie/maven/testing/Person.java b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/java/org/kie/maven/testing/Person.java new file mode 100644 index 0000000000..af07e24315 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/java/org/kie/maven/testing/Person.java @@ -0,0 +1,33 @@ +/* + * Copyright 2015 JBoss by Red Hat + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.maven.plugin.test; + +public class Person { + private int id; + + public Person(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dsl.dsl b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dsl.dsl new file mode 100644 index 0000000000..34f345ec34 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dsl.dsl @@ -0,0 +1 @@ +[*][]hello=System.out.println("Hello world!"); diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dslr.dslr b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dslr.dslr new file mode 100644 index 0000000000..b9346ec33c --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dslr.dslr @@ -0,0 +1,10 @@ +package org.jboss.qa.brms.bre.functional + +expander sample.dsl + + +rule "simple" + when + then + hello +end diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable-template.txls b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable-template.txls new file mode 100644 index 0000000000..a6503512ad Binary files /dev/null and b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable-template.txls differ diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable.xls b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable.xls new file mode 100644 index 0000000000..e37ac6de47 Binary files /dev/null and b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable.xls differ diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-pmml.pmml b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-pmml.pmml new file mode 100644 index 0000000000..563755fccc --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-pmml.pmml @@ -0,0 +1,43 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-process.bpmn2 b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-process.bpmn2 new file mode 100644 index 0000000000..f98ab1ef0b --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-process.bpmn2 @@ -0,0 +1,57 @@ + + + + + + + + + R5/PT1S + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kie-examples-api/kie-maven-example/src/main/resources/kiemavenexample/Hal1.drl b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-rules.drl similarity index 61% rename from kie-examples-api/kie-maven-example/src/main/resources/kiemavenexample/Hal1.drl rename to kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-rules.drl index ddad155fa0..1d24a8c2ea 100644 --- a/kie-examples-api/kie-maven-example/src/main/resources/kiemavenexample/Hal1.drl +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-rules.drl @@ -13,20 +13,14 @@ * limitations under the License. */ -package org.kie.example.api.kiemavenexample +package org.kie.maven.plugin.test -import org.kie.example.api.kiemavenexample.Message - -global java.io.PrintStream out - -rule "rule 1" when - m : Message( ) +rule R1 when + $str : String() then - out.println( m.getName() + ": " + m.getText() ); end -rule "rule 2" when - Message( text == "Hello, HAL. Do you read me, HAL?" ) +rule R2 when + $obj : Object() then - insert( new Message("HAL", "Dave. I read you." ) ); end \ No newline at end of file diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-scorecard.sxls b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-scorecard.sxls new file mode 100644 index 0000000000..3f46fe8c4c Binary files /dev/null and b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-scorecard.sxls differ diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-template.drt b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-template.drt new file mode 100644 index 0000000000..230b23c1e0 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-template.drt @@ -0,0 +1,19 @@ +template header +age +type +log + +package org.drools.examples.templates; + +global java.util.List list; + +template "cheesefans" + +rule "Cheese fans_@{row.rowNumber}" + when + Person(age == @{age}) + Cheese(type == "@{type}") + then + list.add("@{log}"); +end +end template diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-xmlrule.xml b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-xmlrule.xml new file mode 100644 index 0000000000..5b6bc68818 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-xmlrule.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/META-INF/kmodule.xml b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/META-INF/kmodule.xml new file mode 100644 index 0000000000..ad114bd871 --- /dev/null +++ b/kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/META-INF/kmodule.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9eafcce584..833d23bcb4 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,10 @@ kie-identity-session-provider + kie-maven-plugin + + drools-benchmark drools-simulator drools-rhq-plugin @@ -57,7 +61,6 @@ kie-infinispan drools-jboss-integration kie-server-parent - kie-examples-api jbpm-process-svg drools-osgi kie-performance-kit