OpenL Tablets Maven plugin expects the following directory structure:
|- your-project/ Project root folder | |- pom.xml Maven project file | | | |- src/ | | | | | | | | |- main/ | | | | | | | |- java/ Contains java sources | | | | | | | |- resources/ Contains java resources | | | | | | | |- openl/ Contains all OpenL-related resources (rules, xml etc.) | | | | | | | | | |- rules.xml OpenL project descriptor | | | | |- rules/ | | | | | |- MyRules.xlsx File with rules | | | | | | | | |- test/ Contains tests run upon build generation | | | | | | | |- openl/ OpenL project for testing the rules | | | | | | | | | |- rules.xml OpenL project descriptor, contains dependency on the tested OpenL project | | | | |- rules/ | | | | | |- MyTest.xlsx File with OpenL 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</packaging> [...] <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 Maven lifecycle as follows:
The simplest way to generate interface for rules defined in the TemplateRules.xls file:
<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.