diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/acme-planner/classpath.txt | 44 | ||||
-rw-r--r-- | module/ri-engine/classpath.txt | 44 | ||||
-rw-r--r-- | module/ri-engine/pom.xml | 24 | ||||
-rw-r--r-- | module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java | 53 | ||||
-rw-r--r-- | module/ri-engine/src/test/java/io/trygvis/rules/engine/WireguardTestMain.java | 19 | ||||
-rw-r--r-- | module/ri-wireguard/src/main/resources/logback.xml | 2 |
6 files changed, 67 insertions, 119 deletions
diff --git a/module/acme-planner/classpath.txt b/module/acme-planner/classpath.txt index 3aadd88..0d4a2e7 100644 --- a/module/acme-planner/classpath.txt +++ b/module/acme-planner/classpath.txt @@ -1,5 +1,4 @@ io.trygvis.rules-sandbox:acme-planner:1.0-SNAPSHOT:jar -aopalliance:aopalliance:1.0:jar ch.obermuhlner:big-math:2.0.0:jar ch.qos.logback:logback-classic:1.2.3:jar ch.qos.logback:logback-core:1.2.3:jar @@ -12,9 +11,7 @@ com.github.virtuald:curvesapi:1.06:jar com.google.code.findbugs:annotations:3.0.1:jar com.google.errorprone:error_prone_annotations:2.1.3:jar com.google.guava:guava:25.0-jre:jar -com.google.inject:guice:4.0:jar com.google.j2objc:j2objc-annotations:1.1:jar -com.google.protobuf:protobuf-java:3.6.1:jar com.google.re2j:re2j:1.2:jar com.googlecode.java-ipv6:java-ipv6:0.17:jar com.hubspot.jinjava:jinjava:2.5.6:jar @@ -29,42 +26,17 @@ info.picocli:picocli:4.6.1:jar io.trygvis.rules-sandbox:ri-engine:1.0-SNAPSHOT:jar jakarta.activation:jakarta.activation-api:1.2.2:jar jakarta.xml.bind:jakarta.xml.bind-api:2.3.3:jar -javax.annotation:jsr250-api:1.0:jar -javax.enterprise:cdi-api:1.0:jar -javax.inject:javax.inject:1:jar org.antlr:antlr-runtime:3.5.2:jar -org.apache.ant:ant:1.9.15:jar -org.apache.ant:ant-launcher:1.9.15:jar org.apache.commons:commons-collections4:4.4:jar org.apache.commons:commons-compress:1.19:jar org.apache.commons:commons-lang3:3.10:jar org.apache.commons:commons-math3:3.4.1:jar -org.apache.httpcomponents:httpclient:4.5.12:jar -org.apache.httpcomponents:httpcore:4.4.13:jar -org.apache.maven:maven-aether-provider:3.3.9:jar -org.apache.maven:maven-artifact:3.3.9:jar -org.apache.maven:maven-builder-support:3.3.9:jar -org.apache.maven:maven-compat:3.3.9:jar -org.apache.maven:maven-core:3.3.9:jar -org.apache.maven:maven-model:3.3.9:jar -org.apache.maven:maven-model-builder:3.3.9:jar -org.apache.maven:maven-plugin-api:3.3.9:jar -org.apache.maven:maven-repository-metadata:3.3.9:jar -org.apache.maven:maven-settings:3.3.9:jar -org.apache.maven:maven-settings-builder:3.3.9:jar -org.apache.maven.wagon:wagon-http:3.0.0:jar -org.apache.maven.wagon:wagon-http-shared:3.0.0:jar -org.apache.maven.wagon:wagon-provider-api:3.0.0:jar org.apache.poi:poi:4.1.2:jar org.apache.poi:poi-ooxml:4.1.2:jar org.apache.poi:poi-ooxml-schemas:4.1.2:jar org.apache.xmlbeans:xmlbeans:3.1.0:jar org.checkerframework:checker-compat-qual:2.0.0:jar org.codehaus.mojo:animal-sniffer-annotations:1.14:jar -org.codehaus.plexus:plexus-classworlds:2.5.2:jar -org.codehaus.plexus:plexus-component-annotations:1.6:jar -org.codehaus.plexus:plexus-interpolation:1.21:jar -org.codehaus.plexus:plexus-utils:3.0.22:jar org.drools:drools-canonical-model:7.48.0.Final:jar org.drools:drools-compiler:7.48.0.Final:jar org.drools:drools-core:7.48.0.Final:jar @@ -76,24 +48,12 @@ org.drools:drools-model-compiler:7.48.0.Final:jar org.drools:drools-mvel:7.48.0.Final:jar org.drools:drools-mvel-compiler:7.48.0.Final:jar org.drools:drools-mvel-parser:7.48.0.Final:jar -org.drools:drools-serialization-protobuf:7.48.0.Final:jar org.drools:drools-templates:7.48.0.Final:jar -org.eclipse.aether:aether-api:1.1.0:jar -org.eclipse.aether:aether-connector-basic:1.1.0:jar -org.eclipse.aether:aether-impl:1.1.0:jar -org.eclipse.aether:aether-spi:1.1.0:jar -org.eclipse.aether:aether-transport-file:1.1.0:jar -org.eclipse.aether:aether-transport-http:1.1.0:jar -org.eclipse.aether:aether-transport-wagon:1.1.0:jar -org.eclipse.aether:aether-util:1.1.0:jar -org.eclipse.sisu:org.eclipse.sisu.inject:0.3.2:jar -org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.2:jar org.glassfish.jaxb:jaxb-runtime:2.3.3:jar org.glassfish.jaxb:txw2:2.3.3:jar org.javassist:javassist:3.24.1-GA:jar org.jsoup:jsoup:1.10.3:jar org.kie:kie-api:7.48.0.Final:jar -org.kie:kie-ci:7.48.0.Final:jar org.kie:kie-internal:7.48.0.Final:jar org.kie:kie-memory-compiler:7.48.0.Final:jar org.kie.kogito:drools-compiler:1.1.0.Final:jar @@ -105,7 +65,6 @@ org.kie.kogito:kogito-drools-model:1.1.0.Final:jar org.kie.kogito:kogito-internal:1.1.0.Final:jar org.kie.kogito:kogito-services:1.1.0.Final:jar org.kie.soup:kie-soup-commons:7.48.0.Final:jar -org.kie.soup:kie-soup-maven-integration:7.48.0.Final:jar org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar org.kie.soup:kie-soup-project-datamodel-api:7.48.0.Final:jar org.kie.soup:kie-soup-project-datamodel-commons:7.48.0.Final:jar @@ -116,10 +75,7 @@ org.optaplanner:optaplanner-persistence-common:8.1.0.Final:jar org.optaplanner:optaplanner-persistence-jackson:8.1.0.Final:jar org.optaplanner:optaplanner-spring-boot-autoconfigure:8.1.0.Final:jar org.optaplanner:optaplanner-spring-boot-starter:8.1.0.Final:jar -org.slf4j:jcl-over-slf4j:1.7.30:jar org.slf4j:slf4j-api:1.7.30:jar -org.sonatype.plexus:plexus-cipher:1.7:jar -org.sonatype.plexus:plexus-sec-dispatcher:1.3:jar org.springframework:spring-aop:5.2.7.RELEASE:jar org.springframework:spring-beans:5.2.7.RELEASE:jar org.springframework:spring-context:5.2.7.RELEASE:jar diff --git a/module/ri-engine/classpath.txt b/module/ri-engine/classpath.txt index 580eec1..ce43f01 100644 --- a/module/ri-engine/classpath.txt +++ b/module/ri-engine/classpath.txt @@ -1,5 +1,4 @@ io.trygvis.rules-sandbox:ri-engine:1.0-SNAPSHOT:jar -aopalliance:aopalliance:1.0:jar ch.obermuhlner:big-math:2.0.0:jar ch.qos.logback:logback-classic:1.2.3:jar ch.qos.logback:logback-core:1.2.3:jar @@ -11,9 +10,7 @@ com.github.virtuald:curvesapi:1.06:jar com.google.code.findbugs:annotations:3.0.1:jar com.google.errorprone:error_prone_annotations:2.1.3:jar com.google.guava:guava:25.0-jre:jar -com.google.inject:guice:4.0:jar com.google.j2objc:j2objc-annotations:1.1:jar -com.google.protobuf:protobuf-java:3.6.1:jar com.google.re2j:re2j:1.2:jar com.googlecode.java-ipv6:java-ipv6:0.17:jar com.hubspot.jinjava:jinjava:2.5.6:jar @@ -23,42 +20,17 @@ commons-codec:commons-codec:1.14:jar commons-io:commons-io:2.8.0:jar commons-net:commons-net:3.3:jar info.picocli:picocli:4.6.1:jar -javax.annotation:jsr250-api:1.0:jar -javax.enterprise:cdi-api:1.0:jar -javax.inject:javax.inject:1:jar org.antlr:antlr-runtime:3.5.2:jar -org.apache.ant:ant:1.9.15:jar -org.apache.ant:ant-launcher:1.9.15:jar org.apache.commons:commons-collections4:4.4:jar org.apache.commons:commons-compress:1.19:jar org.apache.commons:commons-lang3:3.10:jar org.apache.commons:commons-math3:3.6.1:jar -org.apache.httpcomponents:httpclient:4.5.12:jar -org.apache.httpcomponents:httpcore:4.4.13:jar -org.apache.maven:maven-aether-provider:3.3.9:jar -org.apache.maven:maven-artifact:3.3.9:jar -org.apache.maven:maven-builder-support:3.3.9:jar -org.apache.maven:maven-compat:3.3.9:jar -org.apache.maven:maven-core:3.3.9:jar -org.apache.maven:maven-model:3.3.9:jar -org.apache.maven:maven-model-builder:3.3.9:jar -org.apache.maven:maven-plugin-api:3.3.9:jar -org.apache.maven:maven-repository-metadata:3.3.9:jar -org.apache.maven:maven-settings:3.3.9:jar -org.apache.maven:maven-settings-builder:3.3.9:jar -org.apache.maven.wagon:wagon-http:3.0.0:jar -org.apache.maven.wagon:wagon-http-shared:3.0.0:jar -org.apache.maven.wagon:wagon-provider-api:3.0.0:jar org.apache.poi:poi:4.1.2:jar org.apache.poi:poi-ooxml:4.1.2:jar org.apache.poi:poi-ooxml-schemas:4.1.2:jar org.apache.xmlbeans:xmlbeans:3.1.0:jar org.checkerframework:checker-compat-qual:2.0.0:jar org.codehaus.mojo:animal-sniffer-annotations:1.14:jar -org.codehaus.plexus:plexus-classworlds:2.5.2:jar -org.codehaus.plexus:plexus-component-annotations:1.6:jar -org.codehaus.plexus:plexus-interpolation:1.21:jar -org.codehaus.plexus:plexus-utils:3.0.22:jar org.drools:drools-compiler:7.48.0.Final:jar org.drools:drools-core:7.48.0.Final:jar org.drools:drools-core-dynamic:7.48.0.Final:jar @@ -66,35 +38,19 @@ org.drools:drools-core-reflective:7.48.0.Final:jar org.drools:drools-decisiontables:7.48.0.Final:jar org.drools:drools-ecj:7.48.0.Final:jar org.drools:drools-mvel:7.48.0.Final:jar -org.drools:drools-serialization-protobuf:7.48.0.Final:jar org.drools:drools-templates:7.48.0.Final:jar -org.eclipse.aether:aether-api:1.1.0:jar -org.eclipse.aether:aether-connector-basic:1.1.0:jar -org.eclipse.aether:aether-impl:1.1.0:jar -org.eclipse.aether:aether-spi:1.1.0:jar -org.eclipse.aether:aether-transport-file:1.1.0:jar -org.eclipse.aether:aether-transport-http:1.1.0:jar -org.eclipse.aether:aether-transport-wagon:1.1.0:jar -org.eclipse.aether:aether-util:1.1.0:jar -org.eclipse.sisu:org.eclipse.sisu.inject:0.3.2:jar -org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.2:jar org.javassist:javassist:3.24.1-GA:jar org.jsoup:jsoup:1.10.3:jar org.kie:kie-api:7.48.0.Final:jar -org.kie:kie-ci:7.48.0.Final:jar org.kie:kie-internal:7.48.0.Final:jar org.kie:kie-memory-compiler:7.48.0.Final:jar org.kie.soup:kie-soup-commons:7.48.0.Final:jar -org.kie.soup:kie-soup-maven-integration:7.48.0.Final:jar org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar org.kie.soup:kie-soup-project-datamodel-api:7.48.0.Final:jar org.kie.soup:kie-soup-project-datamodel-commons:7.48.0.Final:jar org.kie.soup:kie-soup-xstream:7.48.0.Final:jar org.mvel:mvel2:2.4.11.Final:jar -org.slf4j:jcl-over-slf4j:1.7.30:jar org.slf4j:slf4j-api:1.7.30:jar -org.sonatype.plexus:plexus-cipher:1.7:jar -org.sonatype.plexus:plexus-sec-dispatcher:1.3:jar org.yaml:snakeyaml:1.26:jar xmlpull:xmlpull:1.1.3.1:jar xpp3:xpp3_min:1.1.4c:jar diff --git a/module/ri-engine/pom.xml b/module/ri-engine/pom.xml index d17f83e..c667145 100644 --- a/module/ri-engine/pom.xml +++ b/module/ri-engine/pom.xml @@ -17,6 +17,26 @@ <artifactId>ri-engine</artifactId> <dependencies> + + <dependency> + <groupId>io.trygvis.rules-sandbox.module</groupId> + <artifactId>ri-base</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.trygvis.rules-sandbox.module</groupId> + <artifactId>ri-wireguard</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.trygvis.rules-sandbox.module</groupId> + <artifactId>acme</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.drools</groupId> <artifactId>drools-core</artifactId> @@ -33,10 +53,6 @@ <groupId>org.drools</groupId> <artifactId>drools-templates</artifactId> </dependency> - <dependency> - <groupId>org.kie</groupId> - <artifactId>kie-ci</artifactId> - </dependency> <dependency> <groupId>ch.qos.logback</groupId> diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java index e5b9606..f73419a 100644 --- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java +++ b/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java @@ -2,11 +2,10 @@ package io.trygvis.rules.engine; import org.drools.core.audit.WorkingMemoryConsoleLogger; import org.kie.api.KieServices; -import org.kie.api.builder.Message; -import org.kie.api.builder.Message.Level; -import org.kie.api.builder.ReleaseId; import org.kie.api.event.rule.AgendaEventListener; import org.kie.api.event.rule.RuleRuntimeEventListener; +import org.kie.api.io.Resource; +import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,6 +13,8 @@ import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; public class Engine implements Closeable { private final Logger logger = LoggerFactory.getLogger(getClass()); @@ -28,36 +29,36 @@ public class Engine implements Closeable { logger.info("services = {}", services); - ReleaseId releaseId = null; - for (File path : (modules == null ? new File[0] : modules)) { - logger.info("New KieBuilder: {}", path); + var kieRepository = services.getRepository(); + logger.info("kieRepository.getDefaultReleaseId() = {}", kieRepository.getDefaultReleaseId()); + KieContainer container; + if (modules != null && modules.length > 0) { + List<Resource> resources = new ArrayList<>(); + for (File path : modules) { + if (!path.exists()) { + logger.warn("Module path does not exist: {}", path.getAbsolutePath()); + continue; + } -// var kieBuilder = services.newKieBuilder(fileSystem); - var kieBuilder = services.newKieBuilder(path); - logger.info("Building module"); - kieBuilder.buildAll(); + logger.info("New KieBuilder: {}, file={}, directory={}", path, path.isFile(), path.isDirectory()); - logger.info("Module built!"); - - var results = kieBuilder.getResults(); - - for (Message message : results.getMessages(Level.INFO, Level.WARNING, Level.ERROR)) { -// logger.info("{} {}", message.getLevel(), message.getText()); - logger.info(message.toString()); + var resource = services.getResources().newFileSystemResource(path); + logger.info("resource.getResourceType() = {}", resource.getResourceType()); + resources.add(resource); } - var module = kieBuilder.getKieModule(); - releaseId = module.getReleaseId(); - logger.info("module.getReleaseId() = {}", releaseId); - logger.info("module.getClass() = {}", module.getClass()); - } + var module = kieRepository.addKieModule(resources.get(0), resources.subList(1, resources.size()).toArray(new Resource[0])); + logger.info("module.getReleaseId() = {}", module.getReleaseId()); + var rId = module.getReleaseId(); - logger.info("Creating classpath container"); -// var container = services.getKieClasspathContainer(); - var container = services.newKieContainer(releaseId); + logger.info("Creating classpath container, releaseId=" + rId); + container = services.newKieContainer(rId); + } else { + container = services.getKieClasspathContainer(); + } - logger.info("Creating KieBase"); + logger.info("Creating KieBase \"{}\"", name); logger.info("Available kie base names: {}", container.getKieBaseNames()); var kieBase = container.getKieBase(name); diff --git a/module/ri-engine/src/test/java/io/trygvis/rules/engine/WireguardTestMain.java b/module/ri-engine/src/test/java/io/trygvis/rules/engine/WireguardTestMain.java new file mode 100644 index 0000000..20aeffa --- /dev/null +++ b/module/ri-engine/src/test/java/io/trygvis/rules/engine/WireguardTestMain.java @@ -0,0 +1,19 @@ +package io.trygvis.rules.engine; + +import io.trygvis.rules.engine.cli.RunCommand; + +import java.io.File; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class WireguardTestMain { + public static void main(String[] args) throws Exception { + var c = new RunCommand(); + c.name = "acme"; + c.input = new File("acme.yaml"); + c.outputState = new File("out/acme/wireguard.yaml"); + c.agendaGroups = new String[]{"init", "generate"}; + c.generatedOutput = new File("acme-wireguard"); + assertEquals(0, c.call()); + } +} diff --git a/module/ri-wireguard/src/main/resources/logback.xml b/module/ri-wireguard/src/main/resources/logback.xml index 354003d..66ae905 100644 --- a/module/ri-wireguard/src/main/resources/logback.xml +++ b/module/ri-wireguard/src/main/resources/logback.xml @@ -6,7 +6,7 @@ </appender> <logger name="org.apache.http" level="WARN"/> - <root level="debug"> + <root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> |