zDev - M2E - OSS
  1. zDev - M2E - OSS
  2. MNGECLIPSE-1983

[Feature Request] Support for Maven Release Plugin

    Details

    • Type: Task Task
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 0.9.9 iteration 12/02
    • Fix Version/s: None
    • Component/s: UI
    • Labels:
      None
    • Global Rank:
      1009

      Description

      Summary:

      M2Eclipse UI should provide a couple windows to perform maven releases. A user should be able to do it for several open projects at once.

      M2eclipse users : please vote for this feature if you are interested !

      Details:

      1- Context

      We have been using Maven for 4 years now in the context of OSGi projects with many modules (typically 50+ maven projects in a SVN layout). All our maven projects are independent of each other for versions and releases (independent lifecycles), but each project of course may have dependencies to other projects.

      It happens that modules are released independently (using mvn release:prepare and mvn release:perform), but it also happens that some bug fix requires to release several modules at the same time. In such case this is particularly difficult to handle for the developers: it requires to

      • know the dependency graph, or have an aggregator pom, in order to know the release order
      • perform the release on each of them one after the other

      2- Feature request

      Pure Maven Release Process

      It would be great if m2eclipse could provide a way to right-click on any set of open maven projects in the project explorer, that would open a wizard to perform this task. The wizard could just

      • display the release(tag) version and next working (trunk) version of each of the selected projects, in an editable form (default ones being the same default ones as the maven release plugin)
      • provide an "advanced" button allowing the user to configure the sequence of commands (by default only mvn release:prepare + mvn release:perform, but by experience we would want to use "svn commit" + "svn up" (fixes lots of bugs in mvn release)+ "mvn compile release:prepare" + "mvn compile release:perform" (the compile phase allows for example to generate a 'year' property used in license headers).

      Once the user would confirm, this would trigger the release in the right order.

      Smooth eclipse integration

      Additionally a very good feature would be to

      • update the eclipse .project file before each release in order to append the release version to the eclipse project name of the TAG.
      • after the release, update the .project file in the trunk so that it gets its trunk name back (no version appended o the eclipse project name)

      Once the projects are released, the user could be prompted to either keep the trunk projects open (to do new developments that will lead to a new release), or to remove(delete) the trunk and open the newly created tags instead. Or if the names of the projects have been properly modified according to (c), to open both.

      3- Implementation suggestions

      To ease this process and in particular automatic update of inter-projects dependencies within the selected projects, I think of two possible ways:

      1. the m2eclipse creates a temporary aggregator pom, pre-fills the release.properties file as in http://maven.apache.org/plugins/maven-release-plugin/examples/non-interactive-release.html and perform the release on this pom. This should work fairly well because I think the maven release plugin handles all cross-projects dependency versions updates pretty well in such case.
      2. If 1. does not work for some reason, the plugin could use maven reactor to get the right release order, and then release all projects one after the other. Before releasing projects 2 to n, it would need to use the "versions maven plugin" in order to update the pom with the potential new dependency version ( http://mojo.codehaus.org/versions-maven-plugin/use-latest-versions-mojo.html with the option "includes" set to the list of artifactIds of the selected projects)


      Is there any roadmap for such a feature ?

      Best regards,

      Sylvain MARIE

        Issue Links

          Activity

          Hide
          Sylvain Marié added a comment - - edited

          Hello,

          I recently received a comment about this feature from a JIRA user. I don't know if the issue of being able to perform neat grouped releases from within eclipse is considered important as of today, but I just wanted to share with you some code I had written for that issue, more than one year ago at a time where I was still an active maven user.

          >> see attachment "org.maven.ide.eclipse.ext.release.zip"

          The bottomline is that it is in a state where a developer with good knowledge of eclipse plugin development, maven release plugin, and of course M2E (and especially the maven launching mechanisms), could make it production-ready in a matter of days or even less. Unfortunately in my case I was lacking knowledge of the "launching maven inside eclipse" part, and besides I had to rely on an older version of m2e.

          Short description of the code - that is incredibly tiny :

          This code, that we could call "release extension for m2e", registers a "Release" action to the global m2 menu. When the user selects one or several eclipse maven projects, he can right-click and select this Maven > Release menu, that opens a popup displaying the list of selected maven project, ordered by natural maven reactor order. The popup also displays the project current snapshot versions, and suggests the release version and next development (snapshot) version. The user can modify these versions, but each modification is validated by the maven-release-plugin engine: therefore the release version should be >= current snapshot version, and the next snapshot version should be strictly more. Finally the popup allows the user to start the release in that order with the selected version numbers.

          An advanced version of this popup would also allow the user to configure the release action command (e.g. "mvn release:prepare release:perform", "mvn -DdryRun=true release:perform", etc.), and potential pre-release and post-release operations performed before/after each individual project release. I had not enough time to create it when I wrote this, but I had the idea that pre-release should by default use the "maven-versions-update" - so that if one of the project to release depends on another, the dependency in the pom would be updated to new version.

          Status of the core functionality

          This code used to compile and work in the sense that the chain of operations was correctly executed, the project release order and version numbers proposed by the popup were always consistent, and the user could not set a release version number that was inconsistent with the traditional maven release constraints. However when it comes to the last operation - the release itself - I always used a fake maven goal and never the "release:perform". So you will find in ReleaseConfiguration.java that the default release command was "mvn help:active-profiles" instead of the true release command.

          Before testing the true release behaviour, the main missing step is for the method performing the actual release (releaseWithLauncher() method, in ReleaseAction.java ) to get feedback from the operation (success ? failure ?) so as to be able to stop the release chain if any problem, and ask the user if he wants a transactional rollback. I stopped development at that point by lack of time, unfortunately.

          Compilation and dependencies

          By lack of knowledge about m2e I chose to copy the required jars (m2e, maven release plugin, maven embedder) in the /lib folder instead of nicely declaring dependencies in a proper pom. The versions used are a bit more than one year old (from mid 2009). So you may have difficulties to make it compile and run against the latest version of m2eclipse and maven-release-plugin "as is", but if you know m2e and maven-release well you won't have any major trouble understanding what should be done.

          Potential improvements

          There are still a number of potential improvements listed in commentaries of the ReleaseAction.java code, for example before releasing each project,

          • Execute custom pre/post-release actions (as explained above )
          • Updating the version number of the dependencies if one of them was released in this release batch. (as explained above ) This could be a custom pre-release action thanks to the maven versions plugin, but could even be hardcoded because it is almost surely always needed.
          • Renaming the eclipse project with the version number before performing the release, so that one developer will later be able to open several versions of the maven project in eclipse without name collisions trouble.
          Conclusion

          The code is VERY simple to understand so you will quickly be able to see if it is worth looking further at this functionality, and if can easily be turned into a valid plugin for m2e or not.

          I feel sorry not to have found the time to make this work entirely when I coded it, but I then changed jobs completely and had not opportunity to develop again ever since. I thought it was maybe better for the community that I pass this to an active development team like sonatype. Here is the answer I got from Igor Fedorenko (m2e team) :

          "At this point we do not have plans to integrate release plugin
          functionality in m2e... mostly due to the lack of time and resources to
          do this proper."

          So I guess if anyone needs this functionality at least he/she can try to start from where I stopped.
          Best regards

          Sylvain

          Show
          Sylvain Marié added a comment - - edited Hello, I recently received a comment about this feature from a JIRA user. I don't know if the issue of being able to perform neat grouped releases from within eclipse is considered important as of today, but I just wanted to share with you some code I had written for that issue, more than one year ago at a time where I was still an active maven user. >> see attachment "org.maven.ide.eclipse.ext.release.zip" The bottomline is that it is in a state where a developer with good knowledge of eclipse plugin development, maven release plugin, and of course M2E (and especially the maven launching mechanisms), could make it production-ready in a matter of days or even less. Unfortunately in my case I was lacking knowledge of the "launching maven inside eclipse" part, and besides I had to rely on an older version of m2e. Short description of the code - that is incredibly tiny : This code, that we could call "release extension for m2e", registers a "Release" action to the global m2 menu. When the user selects one or several eclipse maven projects, he can right-click and select this Maven > Release menu, that opens a popup displaying the list of selected maven project, ordered by natural maven reactor order. The popup also displays the project current snapshot versions, and suggests the release version and next development (snapshot) version. The user can modify these versions, but each modification is validated by the maven-release-plugin engine: therefore the release version should be >= current snapshot version, and the next snapshot version should be strictly more. Finally the popup allows the user to start the release in that order with the selected version numbers. An advanced version of this popup would also allow the user to configure the release action command (e.g. "mvn release:prepare release:perform", "mvn -DdryRun=true release:perform", etc.), and potential pre-release and post-release operations performed before/after each individual project release. I had not enough time to create it when I wrote this, but I had the idea that pre-release should by default use the "maven-versions-update" - so that if one of the project to release depends on another, the dependency in the pom would be updated to new version. Status of the core functionality This code used to compile and work in the sense that the chain of operations was correctly executed, the project release order and version numbers proposed by the popup were always consistent, and the user could not set a release version number that was inconsistent with the traditional maven release constraints. However when it comes to the last operation - the release itself - I always used a fake maven goal and never the "release:perform". So you will find in ReleaseConfiguration.java that the default release command was "mvn help:active-profiles" instead of the true release command. Before testing the true release behaviour, the main missing step is for the method performing the actual release (releaseWithLauncher() method, in ReleaseAction.java ) to get feedback from the operation (success ? failure ?) so as to be able to stop the release chain if any problem, and ask the user if he wants a transactional rollback. I stopped development at that point by lack of time, unfortunately. Compilation and dependencies By lack of knowledge about m2e I chose to copy the required jars (m2e, maven release plugin, maven embedder) in the /lib folder instead of nicely declaring dependencies in a proper pom. The versions used are a bit more than one year old (from mid 2009). So you may have difficulties to make it compile and run against the latest version of m2eclipse and maven-release-plugin "as is", but if you know m2e and maven-release well you won't have any major trouble understanding what should be done. Potential improvements There are still a number of potential improvements listed in commentaries of the ReleaseAction.java code, for example before releasing each project, Execute custom pre/post-release actions (as explained above ) Updating the version number of the dependencies if one of them was released in this release batch. (as explained above ) This could be a custom pre-release action thanks to the maven versions plugin, but could even be hardcoded because it is almost surely always needed. Renaming the eclipse project with the version number before performing the release, so that one developer will later be able to open several versions of the maven project in eclipse without name collisions trouble. Conclusion The code is VERY simple to understand so you will quickly be able to see if it is worth looking further at this functionality, and if can easily be turned into a valid plugin for m2e or not. I feel sorry not to have found the time to make this work entirely when I coded it, but I then changed jobs completely and had not opportunity to develop again ever since. I thought it was maybe better for the community that I pass this to an active development team like sonatype. Here is the answer I got from Igor Fedorenko (m2e team) : "At this point we do not have plans to integrate release plugin functionality in m2e... mostly due to the lack of time and resources to do this proper." So I guess if anyone needs this functionality at least he/she can try to start from where I stopped. Best regards Sylvain

            People

            • Assignee:
              Unassigned
              Reporter:
              Sylvain Marié
            • Votes:
              20 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

              • Created:
                Updated: