I used maven-remote-resources-plugin for a similar purpose. Create a separate resource project (com.company:resourceProj) of type jar. Put the JMeter resource files in /src/main/resources
.
/src/main/resources/common.properties (your filenames obviously) /src/main/resources/a.properties etc.
Follow the instructions in example to create the package.
Now add this configuration to the parent POM (if you want, to the testing profile):
<properties> <shared.resources.dir>${project.build.directory}/shared-resources</shared.resources.dir> </properties> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-remote-resources-plugin</artifactId> <executions> <execution> <id>load-resources</id> <phase>initialize</phase> <goals> <goal>process</goal> </goals> <configuration> <resourceBundles> <resourceBundle>com.company:resourceProj:version</resourceBundle> </resourceBundles> <attached>false</attached> <outputDirectory>${shared.resources.dir}</outputDirectory> </configuration> </execution> </executions> </plugin>
Now tell Maven that these are test resources. If the elements of the test resource are consistent between the modules, this can also go to the parent, if they differ, then it is in the POM module. (In my experience with Maven 3 resources defined in a child project, priority over parent is not combined.)
<testResources> <testResource> <directory>${shared.resources.dir}</directory> <includes> <include>common.properties</include> <include>${module.file}.properties</include> </includes> </testResource> </testResources>
In the child module, define the property of the resource module (this is module a):
<properties> <module.file>a</module.file> </properties>
Adapt it to suit your use case.
---- Edit ----
If the configuration is placed in the parent POM, the parent POM may not be created depending on the configuration provided by the child. When we create common base / parent projects, we do not want to require that all properties that should be provided by child projects (inheritors) be defined. Therefore, we activate this profile when creating common projects in order to get around everything that applies only to children.
To do this, add the empty pom-packaging.marker
file to the pom-packaging.marker
basedir project. Then add this profile to the parent POM. When the parent project is built, Maven will find the marker file, enable the profile, and disable all executions included in the profile. When the child project is built, the marker file does not exist, so the configuration in the main part of the POM will take effect.
I also used this method with the Enforcer plugin - the parent defines enforcement rules that should apply to projects inherited from the parent, but cannot satisfy the rules when it is built. If the plugin provides the "skip" property, you can enable it in this profile, and not use the phase = not in the plugin configuration.
<profile> <id>pom-packaging</id> <activation> <file> <exists>pom-packaging.marker</exists> </file> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-remote-resources-plugin</artifactId> <executions> <execution> <id>load-resources</id> <phase>none</phase> </execution> </executions> </plugin> .... other plugin executions here .... </plugins> </build> </profile>