wildfly-jar-maven-plugin icon indicating copy to clipboard operation
wildfly-jar-maven-plugin copied to clipboard

Make easier to pass build and runtime environment variables

Open yersan opened this issue 3 years ago • 0 comments

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>

yersan avatar Nov 03 '21 15:11 yersan