Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I resume a Maven lifecycle from an arbritrary phase?

I would like to convince Maven to "continue where it left off". I first do a mvn package to build the package. At a later time I may want to continue the lifecycle to do the integration test etc. by doing a mvn install. In this case I would prefer Maven not to start the lifecycle all over again from the start, but to actually resume at the first phase after package (i.e. pre-integration-test). Is it possible to start the lifecycle at a phase other than the first one?

like image 814
Rinke Avatar asked Jun 30 '16 09:06

Rinke


1 Answers

AFAIK, there's no built-in functionality that supports this. You can, however do the following:

Overwrite all goal bindings up to (but excluding) the intended starting phase that come from:

  • default-bindings.xml
  • <build>/<plugins>/<plugin> sections of the current and all parent POMs (check with mvn help:effective-pom)

in a profile like:

<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>

Activate it with mvn install -P resume-at-pre-int-test.

like image 82
Gerold Broser Avatar answered Oct 05 '22 10:10

Gerold Broser