插件目标附加到maven中的生命周期阶段时的目标执行顺序

时间:2014-06-21 15:46:43

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

我正在尝试了解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怎么找到正确的插件.. isnt 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>

1 个答案:

答案 0 :(得分:0)

回答第二个问题:

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

部分&#34;配置Maven搜索插件&#34;