Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process forked out of Maven release:perform plugin ignores user's settings.xml?

As per the documentation, the Maven release:perform goal checks out the project and then forks a new Maven instance to build it. For some reason the forked instance appears to ignore the user's settings.xml, which causes an error in my case because that file has the definition of a property that is used to compose the repository's URL in the parent pom.

  • User's settings.xml
    Definition of a property in a "nexus" profile which is always active.

    <profiles>
      <profile>
        <id>nexus</id>
        <properties>
          <dist.url>http://host.com/nexus/content/repositories</dist.url>
        </properties>
      </profile>
    </profiles>
    
    <activeProfiles>
      <activeProfile>nexus</activeProfile>
    </activeProfiles>
    
  • Parent's pom.xml
    Usage of the defined property to compose the repository's URL.

    <distributionManagement>
      <repository>
        <id>nexus</id>
        <url>${dist.url}/releases</url>
      </repository>
    </distributionManagement>
    
  • Command executed:

    mvn release:perform
    
  • Output (after it indicates having successfully checked out, built, tested and packaged the project):

    [INFO] Uploading: ${dist.url}/releases/com/acme/access/my-project/1.0/my-project-1.0.jar
    [INFO] [INFO] ------------------------------------------------------------------------
    [INFO] [INFO] BUILD FAILURE
    [INFO] [INFO] ------------------------------------------------------------------------
    [INFO] [INFO] Total time: 3.659s
    [INFO] [INFO] Finished at: Wed Aug 01 14:40:23 EDT 2012
    [INFO] [INFO] Final Memory: 21M/307M
    [INFO] [INFO] ------------------------------------------------------------------------
    [INFO] [WARNING] The requested profile "nexus" could not be activated because it does not exist.
    [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project my-project: Failed to deploy artifacts: Could not transfer artifact com.acme.access:my-project:jar:1.0 from/to nexus (${dist.url}/releases): Error transferring file: no protocol: ${dist.url}/releases/com/acme/access/my-project/1.0/my-project-1.0.jar -> [Help 1]
    

Notice how the forked Maven instance is trying to upload to ${dist.url}, which indicates that the property defined in settings.xml was not read. Also, the warning message informs that profile "nexus" was not found. I'm assuming that the main Maven instance passed the profile information down to the forked instance so it knew to look for it, but since it ignored (or did not find) the user's settings.xml, it could not find that profile.

The only way I have found to circumvent this is to manually specify the location of the settings.xml file through the use of Maven's command line -s argument "wrapped" by the plugin's arguments argument, as in

mvn release:perform -Darguments="-s C:\Users\theuser\.m2\settings.xml"

Is the plugin behaving in an expected/correct way? Is there a way to keep the property definition inside the user's settings.xml without having to specify the location of the file as I have done above?

More information:

  • The problem seems to be specifically with the plugin not finding the user's settings.xml, as copying the profile information into the global settings.xml does cause it to work.

  • The user's settings.xml is properly named/created because running help:active-profiles indicates that the profile is active. Manually building and deploying with mvn clean deploy also works correctly (ie, the repository URL is correctly calculated and the artifact is uploaded).

like image 461
jsiqueira Avatar asked Aug 01 '12 21:08

jsiqueira


People also ask

What does mvn release prepare do?

mvn release:prepare This command prepares for a release in SCM. It goes through several phases to ensure the POM is ready to be released and then creates a tag in SVN which can be used by release:perform to make a release.

What is Maven release process?

Maven will compile, test and package the versioned project source code into an artifact. The final deliverable will then be released into an appropriate maven repository. The release:perform goal will: Extract file revisions versioned under the new tag name.

What is release prepare?

Description: Prepare for a release in SCM. Steps through several phases to ensure the POM is ready to be released and then prepares SCM to eventually contain a tagged version of the release and a record in the local copy of the parameters used. This can be followed by a call to release:perform .


1 Answers

It's not necessarily a bug in the maven-release-plugin. It seems that you ran into this Maven bug: MNG-5224 The bug should be fixed in Maven 3.0.4.

like image 154
Stefan Ferstl Avatar answered Sep 19 '22 06:09

Stefan Ferstl