I have the following structure:
main/
--pom.xml
--common/
--pom.xml
--core/
--pom.xml
Both common and core are modules of the main projects, so main/pom.xml is like this:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>main</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>Main APP</name>
<url>http://maven.apache.org</url>
<modules>
<module>common</module>
<module>core</module>
</modules>
</project>
Besides that, common/pom.xml is supposed to hold some common dependencies between all future modules. This is how common/pom.xml looks like for now:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>common</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>mod1</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>common-dependency</groupId>
<artifactId>common</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Finally, the module core should use dependencies defined in the common module, so this is what I done in core/pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>core</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Core</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
What I wanted is that when I run mvn dependency:copy-dependencies
inside core module, maven should copy all the dependencies from common module, also (that common-dependency:common, for example). But actually what happens is that it do not copy any dependency, so it's like if core module didn't had any dependency at all.
What am I missing here?