I have a maven module A that is dependent on the classes in the module B (both are child modules in a project).
In the A‘s pom.xml I have the following:
<dependencies>
<dependency>
<groupId>test.pack</groupId>
<artifactId>B</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
But when I try to build the A, the B does not appear in the dependencies correctly, I get compilation errors in the class that is in the A‘s test.pack.packFromA package in the import statement, which looks like import test.pack.packFromB.*.
So, my B dependency doesn’t work correctly. But I thought classes from the B would be packed and added in the classpath, so I could use them. I tried to add <type> in that dependency, but that didn’t help. What am I doing wrong here? Thanks in advance.
EDIT:
The <modules> part of parent’s pom.xml looks like that:
<modules>
<module>B</module>
<module>A</module>
</modules>
Here is the error I get: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project A: Compilation failure: Compilation failure:
Have you done
mvn installin module B, before you tried to build module A?(If you do “mvn package” instead of
mvn install, module B won’t be placed in the repo, so Maven won’t find it when building module A).Also, have you tried building the multi-module project from the parent module? (When you do this, Maven will build the modules in the correct order)
If that’s not it, verify that the classes you are referencing are located under
src/main/java/test/pack/packFromBin module B. If they are undersrc/test/java..you need a specific type of dependency for that.Hope that helps.