From d5a6b52d506db7eee09e8665e9c661fab952dc80 Mon Sep 17 00:00:00 2001 From: Petr Siroky Date: Fri, 11 Sep 2015 16:50:54 +0200 Subject: [PATCH] [BZ-1257739] move kie-maven-plugin from drools repo + add deps to enable building of all resources OOTB * added all the optional deps for user experience. The plugin is now able to build every supported resource type * using takari libs for plugin testing. See http://takari.io/book/70-testing.html for more info * removed the "unit" test and using only integration tests as they can be spawned in own JVM to eliminate dependency clashes * remove redundant example --- kie-examples-api/kie-maven-example/pom.xml | 45 ---- .../KieMavenPluginExample.java | 41 ---- .../example/api/kiemavenexample/Message.java | 72 ------ .../src/main/resources/META-INF/kmodule.xml | 5 - .../src/main/resources/logback.xml | 20 -- .../KieMavenPluginExampleTest.java | 40 ---- .../KieMavenPluginFromFSExampleTest.java | 76 ------ kie-examples-api/pom.xml | 29 --- .../.gitignore | 0 kie-maven-plugin-example/pom.xml | 40 ++++ .../main/java/org/kie/sample/model/Fire.java | 35 +++ .../main/java/org/kie/sample/model/Room.java | 51 ++++ .../java/org/kie/sample/model/Sprinkler.java | 60 +++++ .../main/resources/FireAlarmKBase/alarm.drl | 18 ++ .../main/resources/FireAlarmKBase/rules.drl | 38 +++ .../main/resources/FireAlarmKBase/rules2.drl | 44 ++++ .../src/main/resources/KBase1/decA.drl | 19 ++ .../src/main/resources/KBase1/decB.drl | 19 ++ .../src/main/resources/KBase1/rule.drl | 21 ++ .../src/main/resources/META-INF/kmodule.xml | 9 + .../java/org/kie/kproject/KProjectTest.java | 52 +++++ .../.gitignore | 0 kie-maven-plugin/pom.xml | 218 ++++++++++++++++++ .../java/org/kie/maven/plugin/BuildMojo.java | 179 ++++++++++++++ .../kie/maven/plugin/DiskResourceStore.java | 98 ++++++++ ...jectDependenciesComponentConfigurator.java | 97 ++++++++ .../org/kie/maven/plugin/SerializeMojo.java | 93 ++++++++ .../kie/maven/plugin/TouchResourcesMojo.java | 92 ++++++++ .../resources/META-INF/plexus/components.xml | 37 +++ .../plugin/BuildMojoIntegrationTest.java | 40 ++++ .../KieMavenPluginBaseIntegrationTest.java | 38 +++ .../plugin/SerializeMojoIntegrationTest.java | 42 ++++ .../projects/kjar-1-with-serialize/pom.xml | 69 ++++++ .../main/java/org/kie/sample/model/Fire.java | 35 +++ .../main/java/org/kie/sample/model/Room.java | 51 ++++ .../java/org/kie/sample/model/Sprinkler.java | 60 +++++ .../main/resources/FireAlarmKBase/alarm.drl | 18 ++ .../main/resources/FireAlarmKBase/rules.drl | 38 +++ .../main/resources/FireAlarmKBase/rules2.drl | 44 ++++ .../src/main/resources/KBase1/decA.drl | 19 ++ .../src/main/resources/KBase1/decB.drl | 19 ++ .../src/main/resources/KBase1/rule.drl | 21 ++ .../src/main/resources/META-INF/kmodule.xml | 9 + .../java/org/kie/kproject/KProjectTest.java | 52 +++++ .../projects/kjar-2-all-resources/pom.xml | 23 ++ .../java/org/kie/maven/testing/Person.java | 33 +++ .../resources/AllResourceTypes/simple-dsl.dsl | 1 + .../AllResourceTypes/simple-dslr.dslr | 10 + .../simple-dtable-template.txls | Bin 0 -> 68096 bytes .../AllResourceTypes/simple-dtable.xls | Bin 0 -> 11264 bytes .../AllResourceTypes/simple-pmml.pmml | 43 ++++ .../AllResourceTypes/simple-process.bpmn2 | 57 +++++ .../AllResourceTypes/simple-rules.drl | 16 +- .../AllResourceTypes/simple-scorecard.sxls | Bin 0 -> 29184 bytes .../AllResourceTypes/simple-template.drt | 19 ++ .../AllResourceTypes/simple-xmlrule.xml | 21 ++ .../src/main/resources/META-INF/kmodule.xml | 9 + pom.xml | 5 +- 58 files changed, 2000 insertions(+), 340 deletions(-) delete mode 100644 kie-examples-api/kie-maven-example/pom.xml delete mode 100644 kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/KieMavenPluginExample.java delete mode 100644 kie-examples-api/kie-maven-example/src/main/java/org/kie/example/api/kiemavenexample/Message.java delete mode 100644 kie-examples-api/kie-maven-example/src/main/resources/META-INF/kmodule.xml delete mode 100644 kie-examples-api/kie-maven-example/src/main/resources/logback.xml delete mode 100644 kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginExampleTest.java delete mode 100644 kie-examples-api/kie-maven-example/src/test/java/org/kie/example/api/kiemavenexample/KieMavenPluginFromFSExampleTest.java delete mode 100644 kie-examples-api/pom.xml rename {kie-examples-api => kie-maven-plugin-example}/.gitignore (100%) create mode 100644 kie-maven-plugin-example/pom.xml create mode 100644 kie-maven-plugin-example/src/main/java/org/kie/sample/model/Fire.java create mode 100644 kie-maven-plugin-example/src/main/java/org/kie/sample/model/Room.java create mode 100644 kie-maven-plugin-example/src/main/java/org/kie/sample/model/Sprinkler.java create mode 100644 kie-maven-plugin-example/src/main/resources/FireAlarmKBase/alarm.drl create mode 100644 kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules.drl create mode 100644 kie-maven-plugin-example/src/main/resources/FireAlarmKBase/rules2.drl create mode 100644 kie-maven-plugin-example/src/main/resources/KBase1/decA.drl create mode 100644 kie-maven-plugin-example/src/main/resources/KBase1/decB.drl create mode 100644 kie-maven-plugin-example/src/main/resources/KBase1/rule.drl create mode 100644 kie-maven-plugin-example/src/main/resources/META-INF/kmodule.xml create mode 100644 kie-maven-plugin-example/src/test/java/org/kie/kproject/KProjectTest.java rename {kie-examples-api/kie-maven-example => kie-maven-plugin}/.gitignore (100%) create mode 100644 kie-maven-plugin/pom.xml create mode 100644 kie-maven-plugin/src/main/java/org/kie/maven/plugin/BuildMojo.java create mode 100644 kie-maven-plugin/src/main/java/org/kie/maven/plugin/DiskResourceStore.java create mode 100644 kie-maven-plugin/src/main/java/org/kie/maven/plugin/IncludeProjectDependenciesComponentConfigurator.java create mode 100644 kie-maven-plugin/src/main/java/org/kie/maven/plugin/SerializeMojo.java create mode 100644 kie-maven-plugin/src/main/java/org/kie/maven/plugin/TouchResourcesMojo.java create mode 100644 kie-maven-plugin/src/main/resources/META-INF/plexus/components.xml create mode 100644 kie-maven-plugin/src/test/java/org/kie/maven/plugin/BuildMojoIntegrationTest.java create mode 100644 kie-maven-plugin/src/test/java/org/kie/maven/plugin/KieMavenPluginBaseIntegrationTest.java create mode 100644 kie-maven-plugin/src/test/java/org/kie/maven/plugin/SerializeMojoIntegrationTest.java create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/pom.xml create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Fire.java create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Room.java create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/java/org/kie/sample/model/Sprinkler.java create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/alarm.drl create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules.drl create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/FireAlarmKBase/rules2.drl create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decA.drl create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/decB.drl create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/KBase1/rule.drl create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/main/resources/META-INF/kmodule.xml create mode 100644 kie-maven-plugin/src/test/projects/kjar-1-with-serialize/src/test/java/org/kie/kproject/KProjectTest.java create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/pom.xml create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/java/org/kie/maven/testing/Person.java create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dsl.dsl create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dslr.dslr create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable-template.txls create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-dtable.xls create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-pmml.pmml create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-process.bpmn2 rename kie-examples-api/kie-maven-example/src/main/resources/kiemavenexample/Hal1.drl => kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-rules.drl (61%) create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-scorecard.sxls create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-template.drt create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/AllResourceTypes/simple-xmlrule.xml create mode 100644 kie-maven-plugin/src/test/projects/kjar-2-all-resources/src/main/resources/META-INF/kmodule.xml 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 0000000000000000000000000000000000000000..a6503512adccb5853e8041a67d4394f190232251 GIT binary patch literal 68096 zcmeI1e{fXQ702(}?7{{D`2hu$A1KQW-cVk&7cf_0QRobew8t_??D$5 ziA2iX4gPU2aSQoLgS$E(DhIRngC6NZh&rtZh|I3lc6clRA?GB9hw2%4BY~K8oCvl z34I2-4f-tfIq37y?a&?2ozN_3Hgp#>2f7=oh3cTW&^%~9v;bNN-2>eV-3Kj#?uWhr zErymrOQB`Za_EcD3TP#?3VHzg67(SS5cDwgW#|#;QRp$~E70T6YA6b=f$E{PPz+iJ zt%o*14bT(NlTahH5o&^(p-s?cs0C_;+Mq4aSD~*#PeEIuuS46Q?a&VBY3LbfC$s`B zHKS$(BX7dC#n!-qJeN_(n9Nkqr&{LqBA@b?E2Ht5z~xxc@l5_6_5)BE)YtqUisJ)q z{?j;V{?nF3^Pjf5FoE(guHu72=9j}x(Iwwr`_CdH4hK)#ym$w`M{%V=Zp@E1)<>k4 zdA1Kxk8*R47sPW$!0dyD-m;l&#`wV6s|K7x);#X%6r~K zdu%w?p82`0^B3!xiTl*=Q6}-sx0911s}OSo zuFD&-or(LVJN`Ni9LhbO>RIY|X3xe4E6jeno8P-|>B1Fr7mp7PGC#t|P2CxLzus^D zm589()N&$1ega_q=koJY$9gM&DL=K^TluTkzaLB^G`!@J;ym4Pi0AsJUcx`)68>qI z@R#@M57``uxJ$YX?fT>Vc%B=Z-5-}T@NciF4hO?Q6MT6X< zZo5g)wyM3%ZmZh|*=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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 0000000000000000000000000000000000000000..3f46fe8c4c492a25e6e0270aa8bad41ed6c17e0f GIT binary patch literal 29184 zcmeHQ3vgW5S^n>8C9N#SmSkCe%h&I>B1^LC;MkHZIkqDCF|zaM)Wu#)D|@l5)vQ*o zJyR0}$S~7{(%K~%5<@9zXdb1_i=-U_b_Qr*Mk!25CM0-D%A}bx<(0Gyv?N`=@0@%0 zKKAa_ZVHqPdo^eGp8x)@^Pm6x=RfD(yZWoYtbg+hPc8nA_>SFDAwS91NRlp8EW%!hAt}?ve&M zFTX06TPqjs5PGd4cSgDt-mj_8mFja2J`H(Z(Y&D`Tcug913xC8AsK{M8$A-2QAx^4 zN#pbX8b-~Gnl{=Pb-`^hq(feynIlpVqhr5eupWYbwX7bf$7aKj z9ie(eXT-RU{toAHU7|8u=>bgx^`L+34%L(x9W!FwJOhRyopx)DAd8)Lx7NZqYk6th z@>2tzZ1rs*4{AEg)*}z2Il5FT(X+C0^~zP7SFLJ2zG3IF^>*dhhUVxB%nwUF*FQFx z82-2yX{A)lG6$)p)yoHUvRVgKSNgGh+$_|O$VO=sIZjnJnzm+E_1Jm^IJRM@1z5Rd zCGxOan?5Jk zCRU=|l%{-9mcS^36D=!`>6Y%aD#x~{b~Z=X$RlFBdWQ7+If_?k|X^w7^ zFUi_`%mA(my++u^CDFF6xzh!*^gZqY($WNU9XHuGkEy;f-Sn`LZm7c3eUqc; zm&fIne8Eu4E5>4x2ZwlAJI8LjJfZr@R=~#3>EHl7ly4%o@%Xna`XP5*GYPLmUBQ27 zUns-1B|exPNNdpF?IYsj^Q?6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9ho ze^hK{_<`h5IyI3R$(Vc34<$yG4pYsIKmYZfmyIs)oBFfs?>u?wn+CUn%17A(Web!o zP_{tX0%Z%7El{>V*#cz?lr2!UK-mIi3up_3t^XshzWnNymL+wUAHe#5^N+s5_5Yuv zaIMev|9%wSU_Fe&hYapS;hO#g3fKFmQFz049EJM;_P)TwIJfr!^g4a6q6fI(cQY81 zhH{*T;gmS1s-8oX*%m6d7>IsHDt%_+bRv+b`Hc;zG90)u!JlyA41 zc-4cy^~IkXDCKC9O7%cCrO=Pe7(Yd>sZTup9&p(IFOZk+fb=wef#9Ul<4gc{I0&y& z+u?ar_i3e=S*X@ZhM# b1N|xdum)ew)xWk@nm#)|K>J%L*pmNWKt&fi literal 0 HcmV?d00001 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