wildfly-extras / wildfly-jar-maven-plugin

WildFly Bootable JAR
https://docs.wildfly.org/bootablejar/
Apache License 2.0
57 stars 40 forks source link

Make easier to pass build and runtime environment variables #282

Open yersan opened 3 years ago

yersan commented 3 years ago

Right now we can pass build time environment variables appending them with -D to the maven goal. For example If I am using a feature pack that requires configurations via environment variables (e.g. eap-datasources-galleon-pack) I can just run mvn package -Dmy.feature.pack.variable=value

If I additionally need to pass runtime variables to the server, then I can use the following:

mvn package wildfly-jar:run \
-Dmy.feature.pack.variable=value \
-Dwildfly.bootable.jvmArguments='-Dmy.runtime.variable=value'

Maybe an easier approach could be to pass these sort of variables via maven plugin configuration. That will allow the developer to keep the configuration on the pom.xml by default instead of supplying the values externally. It will also allow the developer to think in just maven environment variables with the possibility to turn out the previous command in something like this to override any default:

mvn package wildfly-jar:run \
-Doverride.default.pom.my.feature.pack.variable=value \
-Doverride.default.pom.my.runtime.variable=value

The plugin configuration could read the command line environment variables by using:

<configuration>
  <build-env>
      <my.feature.pack.variable>${override.default.pom.my.feature.pack.variable}</my.feature.pack.variable>
  </build-env>
  <env>
     <my.runtime.variable>${override.default.pom.my.runtime.variable}</my.runtime.variable>
  </env>
</configuration>