Reputation: 15
I use the wildfly-maven-plugin to package my application with a wildfly. I have some cli scripts that I want to run in order to for example add oracle driver and datasource. I would like to use system properties to pass to my cli scripts and I have tried reading the documentation (which is minimal and requires a lot of trial and error) without succeeding.
I have tried following the last example here https://docs.wildfly.org/wildfly-maven-plugin/releases/4.2/execute-commands-example.html.
My pom.xml:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>5.0.1.Final</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<bootable-jar>true</bootable-jar>
<bootable-jar-name>application-job-bootable.jar</bootable-jar-name>
<feature-packs>
<feature-pack>
<location>wildfly@maven(org.jboss.universe:community-universe)#22.0.1.Final</location>
</feature-pack>
</feature-packs>
<commands>
<!-- Set the system property in the server configuration -->
<command>/system-property=foo:add(value=bar)</command>
</commands>
<system-properties>
<test.ip>TEST</test.ip>
<bing.test>TEST2</bing.test>
</system-properties>
<packaging-scripts>
<packaging-script>
<scripts>
<script>scripts/wf-ports.cli</script>
<script>scripts/add-user.cli</script>
<script>scripts/add-driver.cli</script>
<script>scripts/add-datasource-node.cli</script>
</scripts>
</packaging-script>
</packaging-scripts>
</configuration>
</plugin>
The documentation shows nothing of how to reference these system props but when running the /system-property=*:read-resource
from one of my cli-scripts it returns an empty result. So neither specifying or using the works.
Upvotes: 0
Views: 72
Reputation: 174
Here's an example how to pass properties to the packaging scripts from the properties file:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
...
<packaging-scripts>
<packaging-script>
<commands>
<command>/socket-binding-group=standard-sockets/socket-binding=jgroups-udp:write-attribute(name=port,value=${PORT})</command>
</commands>
<properties-files>
<property-file>jgroups.properties</property-file>
</properties-files>
<resolve-expressions>true</resolve-expressions>
</packaging-script>
</packaging-scripts>
and the content of the jgroups.properties
file is e.g.
PORT=35200
This resolves the expression in the CLI command and not at the runtime.
Refer to plugin documentation at https://docs.wildfly.org/wildfly-maven-plugin/releases/5.0/package-mojo.html#packagingScripts
Upvotes: 2