OpenL Tablets Maven plugin expects the following directory structure:
|- your-project/ Project root folder | |- pom.xml Maven project file | | | |- src/ | | | | | | | | |- main/ | | | | | | | |- java/ Java sources | | | | | | | |- resources/ Java resources | | | | | | | |- openl/ OpenL Tablets project that contains resources such as rules and configurations | | | | | | | | | |- rules.xml OpenL Tablets project descriptor | | | | |- rules/ | | | | | |- MyRules.xlsx File with rules | | | | | | | | |- test/ Tests run upon build generation | | | | | | | |- openl/ OpenL Tablets project for testing rules | | | | | | | | | |- rules.xml Descriptor that contains dependency on the tested OpenL Tablets project | | | | |- rules/ | | | | | |- MyTest.xlsx File with OpenL Tablets tests
Note that OpenL Tablets-related resources are located in the src/main/openl
directory. It can be changed to fit user needs by modifying the sourceDirectory
parameter in Maven plugin configuration.
The test directory contains tests run on Maven plugin upon build generation but not included in the target project.
Note: It is not recommended to put OpenL Tablets-related resources to the src/main/resources
folder. In this case, OpenL Tablets resources will be inside the JAR file alongside with the compiled Java classes, which most probably is not what is expected in production.
The simplest way to create an OpenL Tablets artifact is as follows:
<!-- <packaging>openl-jar</packaging> Packaging in a jar file. --> <packaging>openl</packaging> <!-- Packaging in a zip file. --> [...] <build> [...] <plugins> [...] <plugin> <groupId>org.openl.rules</groupId> <artifactId>openl-maven-plugin</artifactId> <version>${org.openl.version}</version> <extensions>true</extensions> </plugin> </plugins> [...] </build>
In this case, the OpenL project is processed through the Maven lifecycle as follows:
The simplest way to generate interface for rules defined in the TemplateRules.xls file is as follows:
<build> [...] <plugins> [...] <plugin> <groupId>org.openl.rules</groupId> <artifactId>openl-maven-plugin</artifactId> <version>${org.openl.version}</version> <configuration> <moduleName>TemplateRules</moduleName> <interfaceClass>org.company.gen.TemplateRulesInterface</interfaceClass> </configuration> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> [...] </build>
In this case, classes are generated on each Maven run during the generate-sources phase.
To invoke class generation manually, remove the executions
node and run the following command in the console when needed:
mvn openl:generate
For more information on configuration options, see openl:generate.
<build> [...] <plugins> [...] <plugin> <groupId>org.openl.rules</groupId> <artifactId>openl-maven-plugin</artifactId> <version>${org.openl.version}</version> <executions> <execution> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> [...] </build>
For more information on configuration options, see openl:compile.
The simplest way to invoke OpenL Tablets tests is as follows:
<build> [...] <plugins> [...] <plugin> <groupId>org.openl.rules</groupId> <artifactId>openl-maven-plugin</artifactId> <version>${org.openl.version}</version> <executions> <execution> <goals> <goal>test</goal> </goals> </execution> </executions> </plugin> </plugins> [...] </build>
For more information on configuration options, see openl:test.