javamavenmaven-3exec-maven-pluginmaven-exec-plugin

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


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.


Solution

  • 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)