You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Christian Schulte (JIRA)" <ji...@codehaus.org> on 2009/06/08 00:39:42 UTC

[jira] Created: (MNG-4188) Add a 'finally' phase.

Add a 'finally' phase.
----------------------

                 Key: MNG-4188
                 URL: http://jira.codehaus.org/browse/MNG-4188
             Project: Maven 2
          Issue Type: Wish
          Components: Plugins and Lifecycle
    Affects Versions: 3.x
            Reporter: Christian Schulte
            Priority: Minor


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:

{code}
<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>
{code}

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.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] (MNG-4188) Add a 'finally' phase.

Posted by "Robert Scholte (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-4188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=319817#comment-319817 ] 

Robert Scholte commented on MNG-4188:
-------------------------------------

Maybe a {{finally}}-phase is not the right solution.
There are several phases which always belong together:
* pre-integration-test, integration-test, post-integration-test
* pre-clean, clean, post-clean
* pre-site, site, post-site

In all these cases it makes more sense to have the following construction:
{code}
try
{
  // execute pre-<P>
  // execute <P>
}
finally
{
  // execute post-<P>
}
{code}

But we would still need a mechanism for those users who really, really want to execute up until the specified phase.
Maybe something like {{mvn integration-test.}} //notice the end-dot!

                
> Add a 'finally' phase.
> ----------------------
>
>                 Key: MNG-4188
>                 URL: https://jira.codehaus.org/browse/MNG-4188
>             Project: Maven 2 & 3
>          Issue Type: Wish
>          Components: Plugins and Lifecycle
>    Affects Versions: Issues to be reviewed for 3.x
>            Reporter: Christian Schulte
>            Priority: Minor
>             Fix For: Issues to be reviewed for 3.x
>
>
> 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:
> {code}
> <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>
> {code}
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira