I have a multi-module maven setup. A parent module, plus two sub-modules (children), A and B. Module B has a dependency on A. However, if I use the spring-boot-maven-plugin in module A, the compilation dependency doesn't get resolved, and the compile goal for module B will throw 'cannot find symbol' and 'package does not exist' errors. Everything works if I don't use that plugin, however I will not be able to remove it in this project.
Here is a way to reproduce the problem:
Parent pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.whatever</groupId>
<artifactId>theparent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>service</module>
<module>serviceClient</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
Module A
<modelVersion>4.0.0</modelVersion>
<artifactId>service</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.whatever</groupId>
<artifactId>theparent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
Module B
<modelVersion>4.0.0</modelVersion>
<artifactId>serviceClient</artifactId>
<parent>
<groupId>com.whatever</groupId>
<artifactId>theparent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.whatever</groupId>
<artifactId>service</artifactId>
<version>2.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
Now, all you have to do is have a class in Module A, and another class in Module B, which imports and uses the first class. It should compile fine, when done so by running 'mvn clean install' at the parent module level. However, once this plugin is added in Module A:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.whatever.Application</mainClass>
</configuration>
</plugin>
</plugins>
</build>
, Module B can no longer resolve dependencies from Module A, and you will see 'package does not exist', 'cannot find symbol', etc. messages, indicating it can't see the class from Module A.
Is this a bug? Can anyone help me to get around this problem?