问题
I have several projects that all have a similar Maven build. Each of the project POMs extend from a parent POM containing all of the common dependencies, plugins, etc. that are available to each project. I also have a multi-module POM, currently separate from the parent POM. The purpose of this multi-module POM is to have a single place I can run a target on all of the modules with one command.
If I try to run a plugin, say JS Duck, off of the multi-module POM, I get the following output (project names changed for simplicity):
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Project 1 .......................................... SUCCESS [7.850s]
[INFO] Project 2 .......................................... SUCCESS [0.803s]
[INFO] Project 3 .......................................... SUCCESS [8.488s]
[INFO] Multi-Module POM ................................... FAILURE [0.477s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.780s
[INFO] Finished at: Fri Dec 14 09:31:52 EST 2012
[INFO] Final Memory: 17M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'jsduck' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories
It fails because I don't have the JS Duck plugin specified in my multi-module POM.
Why is it trying to run the plugin on the multi-module POM at all?
I can go the other route and include the modules in my parent POM instead of having a separate multi-module POM, but that has a different problem. In that case, the build succeeds because this time the JS Duck plugin is declared in the multi-module/parent POM. However, it runs the JS Duck plugin against the multi-module/parent POM which essentially generates a garbage 'target' directory because there is no code there to analyze.
For reference, my project structure is:
dev
|- Project1
|- pom.xml
|- Project2
|- pom.xml
|- Project3
|- pom.xml
|- pom.xml (parent POM)
|- all-pom.xml (multi-module POM)
Is there any recommended suggestions in this situation? Is there any way to stop Maven from trying to build the multi-module POM itself? Maybe a different <packaging>
type that would do that?
Thanks for your suggestions!
[EDIT]
Here is the all-pom.xml... some details changed for privacy.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nate</groupId>
<artifactId>projects-all</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>Multi-Module POM</name>
<description>Builds all projects</description>
<modules>
<module>Project1</module>
<module>Project2</module>
<module>Project3</module>
</modules>
<repositories>
...
</repositories>
<pluginRepositories>
...
</pluginRepositories>
</project>
And here is the parent POM... including the addition of child modules.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nate.pom</groupId>
<artifactId>js-master</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>JavaScript Project POM</name>
<description>Parent POM for all JavaScript projects.</description>
<!-- inherit license and other company-wide configuration -->
<parent>
<groupId>com.nate</groupId>
<artifactId>master</artifactId>
<version>1.1</version>
</parent>
<modules>
<module>Project1</module>
<module>Project2</module>
<module>Project3</module>
</modules>
<properties>
<release.version>1.0.0</release.version>
</properties>
<scm>
...
</scm>
<issueManagement>
...
</issueManagement>
<ciManagement>
...
</ciManagement>
<developers>
...
</developers>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src/main/js</sourceDirectory>
</build>
<profiles>
<profile>
<id>javascript</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
...
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
...
<plugin>
<groupId>nl.secondfloor.mojo.jsduck</groupId>
<artifactId>jsduck-maven-plugin</artifactId>
<version>0.1.1-SNAPSHOT</version>
<configuration>
<javascriptDirectory>src/main/js</javascriptDirectory>
<targetDirectory>target/site/api</targetDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
...
</repositories>
<pluginRepositories>
...
</pluginRepositories>
</project>
回答1:
You can explicitly deactivate the plugin in the all-pom
<plugin>
<groupId>nl.secondfloor.mojo.jsduck</groupId>
<artifactId>jsduck-maven-plugin</artifactId>
<version>0.1.1-SNAPSHOT</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
回答2:
The pom which contains the modules list:
<modules>
<module>..</module>
..
</modules>
must have the packaging type pom.
来源:https://stackoverflow.com/questions/13881050/maven-3-multi-module-build-tries-to-run-targets-on-the-multi-module-pom-itself