Maven 3 Multi Module构建尝试在Multi Module POM本身上运行目标 [英] Maven 3 Multi Module build tries to run targets on the Multi Module POM itself

查看:68
本文介绍了Maven 3 Multi Module构建尝试在Multi Module POM本身上运行目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个项目都具有类似的Maven构建.每个项目POM均从父POM扩展而来,该父POM包含每个项目可用的所有公共依赖项,插件等.我还有一个多模块POM,当前与父POM分开.这个多模块POM的目的是让我可以使用一个命令在所有模块上运行目标.

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.

如果我尝试从多模块POM上运行插件(例如JS Duck),则会得到以下输出(为简单起见,更改了项目名称):

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 

失败,因为我的多模块POM中没有指定JS Duck插件.

It fails because I don't have the JS Duck plugin specified in my multi-module POM.

为什么要完全在多模块POM上运行插件?

我可以走另一条路,将模块包含在我的父POM中,而不是使用单独的多模块POM,但这存在另一个问题.在这种情况下,构建成功,因为这一次在多模块/父POM中声明了JS Duck插件.但是,它针对多模块/父POM运行JS Duck插件,该插件本质上会生成垃圾目标"目录,因为那里没有要分析的代码.

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)

在这种情况下,是否有建议的建议?有什么方法可以阻止Maven尝试自己构建多模块POM?也许可以使用其他<packaging>类型呢?

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?

感谢您的建议!

这是all-pom.xml ...出于隐私目的更改了一些详细信息.

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>

这是父POM ...包括子模块的添加.

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>

推荐答案

您可以在all-pom中显式停用插件

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>

这篇关于Maven 3 Multi Module构建尝试在Multi Module POM本身上运行目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆