I know this question has been asked numerous times but the methods I've read just doesn't work for me. I tried this but it still won't work.
I have a subproject(A) that depends on another subproject(B).
Both subprojects are contained in a parent directory with a parent pom.xml (declares A and B as modules) within their respective subdirectories.
Compiling and installing the project works fine with the maven-assembly-plugin but when I try to test A, it doesn't recognize the classes from B. I have tried installing it first and then testing but it still won't find the classes. What am I missing?
Error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile
(default-testCompile) on project (A)
[ERROR] TestService.java:[8,17] cannot find symbol
[ERROR] symbol: class **Model** (the class I'm referencing in B)
[ERROR] location: class **TestService**
(test in A that tests the class in ../service/src/main/java/Service.java)
Edit:
/project
--/service (this depends on model;this is also what I want to test)
---/src
----/main
-----/java
------/Service.java
----/test
-----/java
------/TestService.java
--/model (independent)
---/src
----/main
-----/java
------/Model.java
--/entry (this depends on service; entry point of the whole project)
--pom.xml (parent pom)
Each of the three projects have their own pom.xml inside.
/model/pom.xml contains no dependencies and no plugins
here's parent: parent/pom.xml
...
<modules>
<module>entry</module>
<module>service</module>
<module>model</module>
</modules>
here's entry:
/service/pom.xml
...
<parent>
<groupId>com.some.project</groupId>
<artifactId>project</artifactId>
<version>xx</version>
</parent>
<artifactId>entry</artifactId>
<packaging>jar</packaging>
<version>xx</version>
<name>entry</name>
<build>
...
<!--assembly plugin is declared here-->
</build>
<dependencies>
<dependency>
<groupId>com.some.project</groupId>
<artifactId>service</artifactId>
<version>xx</version>
</dependency>
</dependencies>
here's service:
/service/pom.xml
...
<parent>
<groupId>com.some.project</groupId>
<artifactId>project</artifactId>
<version>xx</version>
</parent>
<artifactId>service</artifactId>
<packaging>jar</packaging>
<version>xx</version>
<name>service</name>
<dependencies>
<dependency>
<groupId>com.some.project</groupId>
<artifactId>model</artifactId>
<version>xx</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>