Quantcast
Channel: In maven child pom dependencies are not taking version from parent pom dependencies if they are mentioned in a profile - Stack Overflow
Viewing all articles
Browse latest Browse all 2

In maven child pom dependencies are not taking version from parent pom dependencies if they are mentioned in a profile

$
0
0

I have a multi-module project, and I am using profiles in the parent pom , which have specific dependencies mentioned in them.The issue here is that, if in a child pom , I am overriding the dependency element, and mentioning one of the dependencies in the parent pom (which is declared in a profile in parent pom) , the version of that specific dependency needs to be mentioned again.

E.g Parent pom

<dependencies><dependency><groupId>com.mycode.apps</groupId><artifactId>jobs</artifactId><version>4</version>   </dependency></dependencies><profiles><profile><id>common-dependencies</id><activation><activeByDefault>true</activeByDefault></activation><dependencies><dependency><groupId>com.mycode.apps</groupId><artifactId>dao</artifactId><version>4</version>   </dependency></dependencies></profile></profiles>

Now in child pom.xml

<dependencies><!--this one doesnt need a version specified --><dependency><groupId>com.mycode.apps</groupId><artifactId>jobs</artifactId></dependency><!--this one makes maven throw an error(if version is not specified) while compilation --><dependency><groupId>com.mycode.apps</groupId><artifactId>dao</artifactId></dependency></dependencies>

Any idea what might be wrong and how can I fix this??

NOTE: The profile is marked as activeByDefault


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>