couldn't execute maven multi module project using exec-maven-plugin

六眼飞鱼酱① 提交于 2019-12-11 20:39:45

问题


I've a multi module maven project here .

The parent project has 3 modules common, with-paranamer, without-paranamer.

The with-paranamer and without-paranamer modules are independent of each other and both are depend on common module.

In without-paranamer module I have added dependency to common module like this.

Below is the structure of the project.

.
├── pom.xml
├── common
│   ├── pom.xml
│   ├─ src
│      ├── main
│         ├─ java
│            ├── ParanamerUtil.java
│            ├── PersonV03.java
│            └── TestCaseClasses.java
│
├── with-paranamer
│   ├── pom.xml
│   ├──src
│      ├── main
│         ├── java
│            └── ParanamerExample.java
|
└── without-paranamer
    ├── pom.xml
    ├─ src
       ├── main
          ├── java
              └── ParametersExample.java

I want to execute ParametersExample class in without-paranamer module using exec-maven-plugin. So I added exec-maven-plugin under pluginManagement in parent pom.xml here.
In without-paranamer module I have added plugin like this.

I've followed the above instructions as mentioned in the stackoverflow post here.

When I run mvn verify the command is successful.

But when I try riunning the command mvn exec:java -Dexec.mainClass=ParametersExample -pl without-paranamer I'm getting below error.

WARNING] The POM for paranamer-maven-demo:common:jar:1.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.189 s
[INFO] Finished at: 2018-09-07T17:23:07-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project without-paranamer: Could not resolve dependencies for project paranamer-maven-demo:without-paranamer:jar:1.0-SNAPSHOT: Could not find artifact paranamer-maven-demo:common:jar:1.0-SNAPSHOT -> [Help 1]

How can I make my program run successful using the exec-maven-plugin.


回答1:


without-paranamer module has a dependency on paranamer-maven-demo.common.1.0-SNAPSHOT, but where can it finds it? Most obvious answer: in local repository. But its not there, unless you install it (also, you have to install pom of parent project).

mvn -N clean install - installs parent pom.( -N stands for non recursive, which means goals will be executed only for parent project, and not for child modules).

mvn -pl common clean install - installs common module.

Now, calling exec:java will be successful (but didn't print any output, because of <skip>true</skip> in plugin management configuration)



来源:https://stackoverflow.com/questions/52229795/couldnt-execute-maven-multi-module-project-using-exec-maven-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!