Details
-
Wish
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.1.1
-
None
Description
When Maven executes a lifecycle, it does not execute any phases succeeding a failing phase. It would be great if Maven supports a 'finally' phase, which is guaranteed to run regardless of the state of the lifecycle just like a Java 'finally' block. The use case I would need such a phase for is the following:
<profile> <id>sourceforge-shell</id> <activation> <activeByDefault>false</activeByDefault> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <dependencies> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant-jsch</artifactId> <version>1.7.1</version> </dependency> </dependencies> <executions> <execution> <id>create-sourceforge-shell</id> <phase>validate</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <sshexec host="shell.sourceforge.net" username="${sf.username},${sf.project}" password="${sf.password}" command="create" timeout="300000" /> </tasks> </configuration> </execution> <execution> <id>create-sourceforge-shell-site</id> <phase>pre-site</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <sshexec host="shell.sourceforge.net" username="${sf.username},${sf.project}" password="${sf.password}" command="create" timeout="300000" /> </tasks> </configuration> </execution> <execution> <id>shutdown-sourceforge-shell</id> <phase>deploy</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <sshexec host="shell.sourceforge.net" username="${sf.username},${sf.project}" password="${sf.password}" command="shutdown" timeout="300000" /> <echo message="Sleeping for 1 minute waiting for shutdown of shell." /> <sleep minutes="1" /> </tasks> </configuration> </execution> <execution> <id>shutdown-sourceforge-shell-site</id> <phase>site-deploy</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <sshexec host="shell.sourceforge.net" username="${sf.username},${sf.project}" password="${sf.password}" command="shutdown" timeout="300000" /> <echo message="Sleeping for 1 minute waiting for shutdown of shell." /> <sleep minutes="1" /> </tasks> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile>
I am currently using this profile when deploying to sourceforge. The problem is, that the shell won't get shutdown, whenever a build fails. It needs to get shutdown, so that a build for another SF project can succeed. In the example above, the two executions 'shutdown-sourceforge-shell' and 'shutdown-sourceforge-shell-site' could be bound to a 'finally' phase and could shutdown the shell regardless of the outcome of the build.
Attachments
Issue Links
- is related to
-
MNG-5389 AbstractMavenLifecycleParticipant need a afterSessionEnd
- Closed