我可以从任意阶段恢复 Maven 生命周期吗?
Can I resume a Maven lifecycle from an arbritrary phase?
我想说服 Maven "continue where it left off"。我首先做一个 mvn package
来构建包。稍后我可能想通过 mvn install
继续生命周期来进行集成测试等。在这种情况下,我更希望 Maven 不要从头开始重新开始生命周期,而是在 package
(即 pre-integration-test
)之后的第一阶段实际恢复。是否可以在第一个阶段以外的阶段开始生命周期?
据我所知,没有支持此功能的内置功能。但是,您可以执行以下操作:
覆盖所有目标绑定,直到(但不包括)来自以下的预期开始阶段:
default-bindings.xml
<build>/<plugins>/<plugin>
当前和所有父 POM 的部分(检查 mvn help:effective-pom
)
在 profile 中:
<profiles>
<profile>
<id>resume-at-pre-int-test</id>
<build>
<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<id>skip-process-resources</id>
<phase>process-resources</phase>
<goals>
<goal>echo</goal>
</goals>
</execution>
</executions>
<configuration>
<echos>
<echo>Default plugin:goal binding for process-resources phase overridden</echo>
</echos>
</configuration>
</plugin>
<plugin>
...
</plugin>
...
</plugins>
</build>
</profile>
</profiles>
使用 mvn install -P resume-at-pre-int-test
激活它。
我想说服 Maven "continue where it left off"。我首先做一个 mvn package
来构建包。稍后我可能想通过 mvn install
继续生命周期来进行集成测试等。在这种情况下,我更希望 Maven 不要从头开始重新开始生命周期,而是在 package
(即 pre-integration-test
)之后的第一阶段实际恢复。是否可以在第一个阶段以外的阶段开始生命周期?
据我所知,没有支持此功能的内置功能。但是,您可以执行以下操作:
覆盖所有目标绑定,直到(但不包括)来自以下的预期开始阶段:
default-bindings.xml
<build>/<plugins>/<plugin>
当前和所有父 POM 的部分(检查mvn help:effective-pom
)
在 profile 中:
<profiles>
<profile>
<id>resume-at-pre-int-test</id>
<build>
<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<id>skip-process-resources</id>
<phase>process-resources</phase>
<goals>
<goal>echo</goal>
</goals>
</execution>
</executions>
<configuration>
<echos>
<echo>Default plugin:goal binding for process-resources phase overridden</echo>
</echos>
</configuration>
</plugin>
<plugin>
...
</plugin>
...
</plugins>
</build>
</profile>
</profiles>
使用 mvn install -P resume-at-pre-int-test
激活它。