Reputation: 527
I have a Maven POM Project that includes a number of modules.
One of them is a REST Web Service that some of the other modules use. This module is a standalone executable.
What I am trying to achieve is to have the web service build and run before all the other modules.
I understand that just by changing the order of the modules in the pom file I can get the module to build before the others, but how do I run it before building the rest of them?
I need to run it so that I can perform a series of tests included in the rest of the modules.
The reason I am trying to achieve this kind of functionality is because what I'm ultimately trying to do is having the project build and test correctly on Jenkins.
Upvotes: 5
Views: 2425
Reputation: 158
I understand that just by changing the order of the modules in the pom file I can get the module to build before the others, but how do I run it before building the rest of them?
Ordering of modules will not necessarily build them in that order. If one module depends on another then you must handle it through <dependency>
in the pom of the dependent project.
To answer your question, build the REST service module first and deploy it to your server/container. In multimodule projects running command like mvn somegoal
will run somegoal
on all the modules.
To run different goals on modules, try in two steps
mvn -pl module1 somegoal
mvn -pl module2 someothergoal
In your project they will take the form of
mvn -pl RESTModule deploy
followed by usual
mvn command for running test for other modules. Remember the -pl option for these too.
Edit: After looking at the requirements from your comment I tried one more solution. Might work for you as well. Add maven-deploy-plugin to the pom of REST Module and tie it to a phase such that only the RESTModule project deploys the artifacts but not others (since they don't have such plugin in their pom). snippet to be added.
`
<project>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>MyProjId</id>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
<distributionManagement>
<repository>
<id>my-repository</id>
<url>http://path/to/your/repo</url>
</repository>
</distributionManagement>
</project>
and run the project using the parent pom in jenkins.
Upvotes: 1