1

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.

user51
  • 8,843
  • 21
  • 79
  • 158
  • you're having a dependency problem - the re is no such artifact: paranamer-maven-demo:common:jar:1.0-SNAPSHOT. Show your pom.xml for all modules and project – ACV Sep 07 '18 at 22:05
  • link to the code repository is https://github.com/rajcspsg/paranamer-maven-demo. It is also in the first line of this question. Also paranamer-maven-demo:common:jar is submodule of the parent project. I've added dependency as well. – user51 Sep 07 '18 at 22:20
  • you should put the pom.xml fragment here. – ACV Sep 08 '18 at 09:46

1 Answers1

2

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)

Flame239
  • 1,274
  • 1
  • 8
  • 20
  • I could only make it work with `mvn clean install` without the `-N` flag. Will there be problems if you install all the modules? And if yes, am I right to assume it's the ones being "depended" on that needs installing? As of now, I'm happily ignorant in don't-fix-it-if-it aint broke-land. – Erk Dec 08 '19 at 17:25