I have a multi-module maven project which has profiles set up. So if I want to use my mock version I can specify:
mvn clean install -Pmock
How can I replicate this in another project’s pom which is going to have this mock implementation as a dependency?
I tried the following, but the profile tag is seen as invalid:
<dependency>
<groupId>com.mysite</groupId>
<artifactId>rest.service</artifactId>
<profile>mock</profile>
<type>war</type>
<version>1.0-SNAPSHOT</version>
</dependency>
You need to have a parent pom where you define and activate the profile, but don’t configure it. The configuration will stay with the dependent module.
In your parent pom you would have something like:
Then in your module you can configure that profile: