Uploaded image for project: 'WildFly Maven Plugin'
  1. WildFly Maven Plugin
  2. WFMP-70

make configuration possible with properties read from a file with maven properties plugin

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • None
    • Maven Plugin
    • None

      I want to configure the wildfly plugin based on environment specific properties read from a file during initialization phase. Therefore I use the properties-maven-plugin and configured two profiles to read a configuration file bases on the environment name.

      Here is the content of the dev configuration file:

      wildfly.hostname=localhost
      wildfly.port=8081
      wildfly.management.port=9991
      wildfly.username=admin
      wildfly.password=admin
      

      Here is the plugin configuration:

      <plugin>
              <groupId>org.codehaus.mojo</groupId>
      	<artifactId>properties-maven-plugin</artifactId>
      	<version>1.0.0</version>
      	<executions>
      		<execution>
      			<phase>initialize</phase>
      	         	<goals>
      				<goal>read-project-properties</goal>
      			</goals>
      			<configuration>
      				<files>
      					<file>config/wildfly-${environment}.properties</file>
      				</files>
      			</configuration>
      		</execution>
      	</executions>
      </plugin>
      <plugin>
      	<groupId>org.wildfly.plugins</groupId>
      	<artifactId>wildfly-maven-plugin</artifactId>
      	<version>1.1.0.Beta1</version>
      
      	<configuration>
      		<hostname>${wildfly.hostname}</hostname>
      		<port>${wildfly.management.port}</port>
      		<username>${wildfly.username}</username>
      		<password>${wildfly.password}</password>
      	</configuration>
      </plugin>
      

      Here is the profile configuration:

      <profiles>
      	<profile>
      		<id>dev</id>
      		<activation>
      			<activeByDefault>true</activeByDefault>
      		</activation>
      		<properties>
      			<environment>dev</environment>
      		</properties>
              </profile>
      
      	<profile>
      		<id>staging</id>
      		<properties>
      			<environment>staging</environment>
      		</properties>
              </profile>
      </profiles>
      

      When I run mvn wildfly:deploy the configuration cannot access the properties read from the file and the default values are used.

      Running mvn initialize wildfly:deploy it works as expected.

      There is a stackoverflow question which describes the same behavior.

      Is it possible to run the initialize phase before wildfly:deploy without explicitly calling it on the command line?

            Unassigned Unassigned
            ancho_jira Frank Becker (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: