【问题标题】:Execution order of goal when a plugin goal in attached to a lifecycle phase in maven插件目标附加到maven生命周期阶段时目标的执行顺序
【发布时间】:2014-06-21 15:46:42
【问题描述】:

我正在尝试了解 maven 目标执行顺序。

所以我有一个 pom 将 maven-antrun-plugin run 目标附加到 maven 生命周期构建的 clean 阶段。

当运行mvn clean 时,我得到的输出如输出部分所示:
现在我的问题是:
1 为什么maven-clean-plugin:2.4.1:clean (default-clean) 目标按照我的附件执行 要运行哪个目标,即pre-process-classes... 那么我的目标是添加到 Maven 拥有的默认目标列表中还是可以被覆盖?基本上maven如何决定执行哪个目标?

2 在插件部分我只有artifactIdversion 但没有groupId。那么 maven 是如何找到正确的插件的.. 不需要 groupId 吗?

输出

 --- maven-clean-plugin:2.4.1:clean (default-clean) @ second_third ---
 Deleting D:\tmp\maven\first_second\target

 --- maven-antrun-plugin:1.1:run (pre-process-classes) @ second_third ---
 Executing tasks
echo] Build Dir: D:\tmp\maven\first_second\target

pom.xml

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>my.second_third_maven</groupId>
  <artifactId>second_third</artifactId>
  <version>1.1.0</version>
  <build>
  <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.1</version>
          <executions>
            <execution>
              <id>pre-process-classes</id>
              <phase>clean</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
              <tasks>
                <echo>Build Dir: ${project.build.directory}</echo>
              </tasks>
              </configuration>
            </execution>
          </executions>
        </plugin>
    </plugins>
  </build>
</project>

【问题讨论】:

    标签: java maven build maven-3 maven-plugin


    【解决方案1】:

    回答第二个问题:

    By default, Maven will search the groupId org.apache.maven.plugins 
    for prefix-to-artifactId mappings for the plugins it needs to
    perform a given build.
    

    http://maven.apache.org/guides/introduction/introduction-to-plugin-prefix-mapping.html

    “配置 Maven 以搜索插件”部分

    【讨论】:

      猜你喜欢
      • 2014-12-25
      • 1970-01-01
      • 2014-12-23
      • 1970-01-01
      • 2011-12-23
      • 2020-03-25
      • 1970-01-01
      • 2016-02-18
      • 2020-04-25
      相关资源
      最近更新 更多