10

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?

Rinke
  • 6,095
  • 4
  • 38
  • 55
  • 1
    I don't think you can do that. [See also this mail](http://maven.40175.n5.nabble.com/Execute-only-a-specific-phase-td103134.html). – Tunaki Jun 30 '16 at 10:20
  • i know that mvn install do: "validate", "compile", "package" and "verify" before doing the "install", so, actually i don't know if is possible tho override this, cause overwrite this setting should be the only way – RudiDudi Jun 30 '16 at 10:27

1 Answers1

2

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.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107