1

I have this architecture

 mmsb |----pom.xml (packaging : pom) -> declare modules API and Utils |----api | |----pom.xml (packaging : pom) -> declare module api-slack / parent project | |----api-slack | |----pom.xml (packaging : pom) -> declare module api-slack-core / parent api | |----api-slack-core | |----pom.xml (packaging : jar) -> java code / parent api-slack |----utils | |----pom.xml (packaging : jar) -> java code / parent project / has dependency from api-slack-core | 

And it not works

With clean install from root Maven say :

 ~/dev/maven-multi-sub-projets ⌚ 11:03:48 $ mvn clean install -DskipTests Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] mmsb [INFO] api [INFO] api-slack [INFO] api-slack-core [INFO] utils [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building mmsb 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ mmsb --- [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ mmsb --- [INFO] Installing /home/mario/dev/maven-multi-sub-projets/pom.xml to /opt/maven/m2repo/fr/app/mmsb/1.0-SNAPSHOT/mmsb-1.0-SNAPSHOT.pom [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building api 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ api --- [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ api --- [INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/pom.xml to /opt/maven/m2repo/fr/app/api/1.0-SNAPSHOT/api-1.0-SNAPSHOT.pom [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building api-slack 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ api-slack --- [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ api-slack --- [INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/api-slack/pom.xml to /opt/maven/m2repo/fr/app/api-slack/1.0-SNAPSHOT/api-slack-1.0-SNAPSHOT.pom [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building api-slack-core 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ api-slack-core --- [INFO] Deleting /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ api-slack-core --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ api-slack-core --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ api-slack-core --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ api-slack-core --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ api-slack-core --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ api-slack-core --- [INFO] Building jar: /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target/api-slack-core-1.0-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:1.4.2.RELEASE:repackage (default) @ api-slack-core --- [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ api-slack-core --- [INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target/api-slack-core-1.0-SNAPSHOT.jar to /opt/maven/m2repo/fr/app/api-slack-core/1.0-SNAPSHOT/api-slack-core-1.0-SNAPSHOT.jar [INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/pom.xml to /opt/maven/m2repo/fr/app/api-slack-core/1.0-SNAPSHOT/api-slack-core-1.0-SNAPSHOT.pom [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building utils 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ utils --- [INFO] Deleting /home/mario/dev/maven-multi-sub-projets/utils/target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ utils --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ utils --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /home/mario/dev/maven-multi-sub-projets/utils/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[3,29] package fr.app.api.slack.core does not exist [ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[11,13] cannot find symbol symbol: class SlackService location: class fr.app.utils.Application [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] mmsb ............................................... SUCCESS [ 0.213 s] [INFO] api ................................................ SUCCESS [ 0.005 s] [INFO] api-slack .......................................... SUCCESS [ 0.004 s] [INFO] api-slack-core ..................................... SUCCESS [ 1.558 s] [INFO] utils .............................................. FAILURE [ 0.113 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.197 s [INFO] Finished at: 2016-12-15T11:03:52+01:00 [INFO] Final Memory: 32M/317M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project utils: Compilation failure: Compilation failure: [ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[3,29] package fr.app.api.slack.core does not exist [ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[11,13] cannot find symbol [ERROR] symbol: class SlackService [ERROR] location: class fr.app.utils.Application [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :utils 

How to declare dependency of api-slack-core in utils ?

UPDATE

I upload code in this repository : https://github.com/mmaryo/mmsb

The problem is when I import fr.app.api.slack.core.SlackService inside fr.app.utils.Application

UPDATE 2

I found the problem, I removed :

 <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> 
3
  • Have you performed mvn clean install from the root module ? Commented Dec 14, 2016 at 14:39
  • Yes it's clean install from root Commented Dec 14, 2016 at 14:59
  • OK. Can you show the pom of Utils and Api-slack-core modules ? Commented Dec 14, 2016 at 15:02

2 Answers 2

1

Few things here -

At your parent pom level (project), why do you still have parent declared?

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.2.RELEASE</version> </parent> 

that too with

<packaging>pom</packaging> 

and along with that why do you have

<module>api-slack</module> <module>api-slack-core</module> 

if they are supposed to be hierarchically within api -> api-slack -> api-slack-core. As an improvement please move module out within the project level as well.


Then at Api level, I doubt how even Api is building currently with incorrect parent name -

<parent> <groupId>fr.app</groupId> <artifactId>vishnou</artifactId> <!-- modified --> <version>1.0-SNAPSHOT</version> </parent> 

Api-slack seems fine.


Api-slack-core can get rid of redundant empty

<dependencies></dependencies> 

and specify a version for plugin(unless already defined in any of the parent poms) as -

<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>x.y.z</version> </plugin> 

Further Utils can use Api-slack-core as a dependency and also please change

<groupId>fr.app</groupId> <artifactId>utils</artifactId> <!--changed--> 

Overall, I would suggest you to please go through a multi module example as suggested by the guide as well.

Sign up to request clarification or add additional context in comments.

3 Comments

vishnou is the name of the project, I correct it because I change the name for stackoverflow
spring-boot-starter-parent is the parent of my parent (vishnou) because I use spring boot projects.spring.io/spring-boot
hi nullpointer, I upload code on github. Hope you can help me
0

Try running mvn clean install -pl Utils -am ? where Utils is the name of the module in the parent-pom.

Maven Reactor should figure out the dependencies by itself - you just need to put the GAV (groupid, artifactid, version) of your dependencies.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.