[英]How are maven plugin goals mapped to maven phases?
I am working on maven project recently but really i do not understand how it works internally as coming from ant background. 我最近正在从事Maven项目,但实际上我不了解它是如何从蚂蚁背景来的内部工作的。
Here are basic questions which i tried to google but could not get satisfaction. 这是我尝试使用Google却无法获得满意的基本问题。
1)When i run mvn clean install or mvn clean package. 1)当我运行MVN清洁安装或MVN清洁包。 Does install or package goal internally run all plugin one by one defined in pom and parent pom or to run a plugin we need to execute mvn
安装或打包目标是在内部逐个运行pom和父pom中定义的所有插件,还是运行我们需要执行mvn的插件
2)Does all goal of a plugin gets executed ? 2)是否执行了插件的所有目标?
3)How goal , phase and task are related to each other?. 3)目标,阶段和任务如何相互关联? Consider the below example
考虑下面的例子
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.projectgroup</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<profiles>
<profile>
<id>test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/env.test.properties" tofile="${project.build.outputDirectory}/env.properties"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
say if i run mvn test -Ptest, does it mean i am going to run phase test under profile test ? 说如果我运行mvn test -Ptest,是否表示我要在配置文件测试下运行阶段测试?
Large part of that is illustrated in Introduction to the Build Lifecycle . Build Lifecycle简介对此进行了很大的说明 。
Package goals can either be run explicitly as mvn release:perform
(calls perform
goal of maven-release-plugin
) or they can be bound to certain phase . 软件包目标可以作为
mvn release:perform
显式运行(调用perform
maven-release-plugin
目标),也可以将它们绑定到特定阶段 。 Maven plugins often come with some goals pre-bound. Maven插件通常会预先绑定一些目标。 You can define your own binding in your
pom.xml
or even specify several different bindings using profiles. 您可以在
pom.xml
定义自己的绑定,甚至可以使用配置文件指定几个不同的绑定。 In your example, you bind maven-antrun-plugin:run
to phase test
if and only if profile test
is executed. 在您的示例中,仅当执行配置文件
test
时,才将maven-antrun-plugin:run
绑定到阶段test
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.