Reputation: 451
Let`s say there is a parent project A that has modules B and C in its pom.xml.
Project A
|-pom.xml
|----------->ModuleB
| |->pom.xml
|----------->ModuleC
| |->pom.xml
<modules>
<module>B</module>
<module>C</module>
</modules>
The module C itself has some dependency that belongs only to this submodule. This dependency should be built before module C, so I want to call "-am" (--also-make) option when "mvn install" is called for C.
Maven is being executed remotely, all I have is pom files. Build job runs on remote Jenkins, it uses the current profile in project A parent pom, only this profile must be used.
I though it can be done in module C`s pom, in configuration of maven-compiler-plugin, for example?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.source}</source>
<target>${jdk.target}</target>
**<arguments>-am</arguments>** <!--smth like this maybe?-->
</configuration>
</plugin>
I also thought about creating another pom.xml to have only submodule C and its dependency in the right order, and to be used instead of current submodule C in parent pom, but want to try -am option first. Besides, I do not quite see now where to put this new pom, because we are already at parent A level.
Probably the whole project structure should be refactored, but it is what I have for now.
Upd: below is less simplified current project structure.
Project A (maven parent for B, C, D)
|-pom.xml
|----------->ModuleB
| |->pom.xml
|----------->folder
|----------->folder
|----------->ModuleC
| |->pom.xml
|----------->ModuleD
| |->pom.xml
<modules>
<module>B</module>
<!-- <module>D</module> | initially was here, now needs to be only C's dependency -->
<module>C</module>
</modules>
Upvotes: 1
Views: 1226
Reputation: 7968
--also-make option can be used when projects specified are also listed in the modules section of the aggregator(reactor) pom.xml. Since you don't have the required projects in your modules section You can't use it in your current setup.
You can just add the extra projects to your current modules section and this will fix your problem. (You don't have worry about order of modules you write, Maven will build them in the correct order for you. And you don't have to use also-make)
You can also use the solution you suggested in the question. It does not have to be parent of C, It can be just the aggregator of C and its dependencies.( I don't think this is neccessary. You can just add all of them to your current modules section)
Also parent pom and aggregator pom are different concepts.
Upvotes: 2