Maven build profiles in a mutli-module project property expansion

134 views Asked by At

I have a Multi-Module Maven project. My parent POM has the following modules:

<module>common</module>
<module>ingest</module>
<module>package</module>

The package modules handles all aspects of building a deployable zip file using maven-antrun-plugin. The other two modules are where the core application code is located. Within the package I have various profiles holding the configuration settings for production, staging and development environments. Each profile looks like:

<profile>
    <id>prod</id>
     <properties>
          <oozie.url>http://oozie-server:11000/oozie</oozie.url>
          <stage.user>prod-stage</stage.user>
    </properties>
</profile>

This works perfectly at the parent level, running:

mvn clean install -P prod

All the .properties file have the various properties expanded to be the ones in the Maven profile.

Within the ingest module, one class may rely upon a .properties file with the ingest module. The contents of this properties file will look something like:

stageUser=${stage.user}

When running tests for the ingest module, the properties are not expanded to be the properties from the build profile e.g. the property will still be stageUser=${stage.user} rather than stageUser=prod-stage. This causes the test to fail.

The only workaround I have is to add in the required profiles and properties to get the test to pass into the ingest POM. This means I have these properties in two locations both the package and ingest modules. Is there a better solution to this?

1

There are 1 answers

1
M A On BEST ANSWER

The inheritance of properties from the parent should work. Make sure you have the parent declaration in the child modules:

<parent>
    <artifactId>parent</artifactId>
    <groupId>parentGroupId</groupId>
    <version>version</version>
</parent>