Reputation: 645
I have a following tree structure of maven project:
Root/pom.xml
Root/moduleA/pom.xml
Root/moduleA/src/main/java/moduleA/MyClass.java
and i want to use a class moduleA.MyClass in Root pom.xml via exec-maven plugin. The problem is: if i define ModuleA as a module of pom xml with
Root/pom.xml
<modules>
<module>moduleA</module>
</modules>
I cannot declare it as a dependency of Root with
Root/pom.xml
<dependencies>
<dependency>
<groupId>Root</groupId>
<artifactId>moduleA</artifactId>
<version>1.0</version>
<scope>install</scope>
</dependency>
</dependencies>
because it will lead to cyclic depndencies like this:
[INFO] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='Root:moduleA'}' and 'Vertex{label='Root:moduleA'}' introduces to cycle in the graph Root:moduleA --> Root:moduleA
The question is: how to keep moduleA built with install
target executed on Root pom and have ability to execute classes of moduleA with exec-maven-plugin?
Upvotes: 2
Views: 947
Reputation: 6408
You haven't posted your full pom.xml, but I know by default the exec plugin is not used by the install goal. You can declare moduleA as a dependency within the plugin declaration, which I think would solve your problem.
On the other hand, if you need to execute part of moduleA in your install goal, then you won't be able to use this setup without a third pom.xml, which would just execute your class.
Upvotes: 1
Reputation: 638
I think your question is similar to the chicken-and-egg-problem. Your root POM is an aggregator for your project which produces artifacts you want to use. Before the artifacts are produced, they cannot be used. If the class of your moduleA is required in your root POM (aka aggregator), you should build it in a separate project. But probably your build process allows to execute MyClass later (not in the root POM), you can move this execution to another module and set a dependency to moduleA.
Upvotes: 1