You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Jens Mühlenhoff (JIRA)" <ji...@codehaus.org> on 2009/06/09 17:05:42 UTC

[jira] Created: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
------------------------------------------------------------------------------------------------

                 Key: MRELEASE-454
                 URL: http://jira.codehaus.org/browse/MRELEASE-454
             Project: Maven 2.x Release Plugin
          Issue Type: Bug
          Components: prepare
    Affects Versions: 2.0-beta-9
            Reporter: Jens Mühlenhoff


Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.


<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>dist</groupId>
				<artifactId>deps</artifactId>
				<type>pom</type>
				<version>4.0.4-SNAPSHOT</version>
				<scope>import</scope>
			</dependency>
		</dependencies>
</dependencyManagement>



-- 
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] Issue Comment Edited: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "Pedro Rodriguez (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=247472#action_247472 ] 

Pedro Rodriguez edited comment on MRELEASE-454 at 12/22/10 10:41 AM:
---------------------------------------------------------------------

The rewriteDependencies method was rewritten to use raw dependency definitions directly from the pom xml. 

Only dependencies found in the pom xml document are processed. 

However, it was required to interpolate the "groupId", "artifactId" and "version" in the xml in order to compare with the resolved dependencies.


Regarding the "MRELEASE-412" issue while updating properties during the rewrite-poms-for-development phase, we only observed that in the case of a dependency management import and it was fixed.

New unit tests:

One additional "rewrite-for-release" unit test was added

	imported-dependency-management-in-reactor


Two additional "rewrite-poms-for-development" unit tests were added:

	pom-with-parent-and-properties-in-dependency-management
	pom-with-parent-and-properties-in-dependency-management-import


Persistent issue

Maven (2.2.1) always resolves imported dependencyManagement from the repository, ignoring the reactor.  Also, Maven does not recognize the imported dependencyManagement pom as a dependency so the reactor order is broken.   

The workaround we use for that is:

	1) Manually order the modules to ensure that dependencyManagement imported POM gets built before the importing module.

	2) Execute release:prepare with preparationGoals "install" to ensure that the imported POM can be resolved from the repository during the importing module build.

Note: In the new Unit Tests we have added for dependency-management-import we bypassed these issues making available the required artifacts in the test repository. 


There is already a JIRA open for this: MNG-4052. 

MNG-4052:  import scope dependencies prefer to download pom rather than find it in the current project

This issue appears currently closed by it was fixed in 3.0-alpha-3 version. However, the current development version (2.2-SNAPSHOT) of the maven-release-plugin uses Maven 2.0.9.


Next (Question):  How do we plan to upgrade the plugins to Maven 3?

Are we going to create a new "release" branch for the Maven 3 development? ... maven-release-plugin development version "3.0-SNAPSHOT" ????



      was (Author: prodriguez):
    The problem is that the current code rewrites the dependencies already resolved. 

org.apache.maven.shared.release.phase.AbstractRewritePomsPhase, Line 272 

if ( project.getDependencyManagement() != null )
{
    Element dependencyRoot = rootElement.getChild( "dependencyManagement", namespace );
    if ( dependencyRoot != null )
    {
	rewriteDependencies( project.getDependencyManagement().getDependencies(), dependencyRoot,
			     mappedVersions, resolvedSnapshotDependencies, originalVersions, projectId,
			     properties, result, releaseDescriptor );
    }
}
        
A simple fix could be to add the "imported dependency management" dependencies to the dependencies list we want to rewrite:

if ( project.getDependencyManagement() != null )
{
    Element dependencyRoot = rootElement.getChild( "dependencyManagement", namespace );
    if ( dependencyRoot != null )
    {
	List dependencies = new ArrayList( project.getDependencyManagement().getDependencies() );

	// Add "imported dependencyManagement" to the dependencies list to allow them to be rewrited as well   
	Element dependencyManagementDependenciesRoot = dependencyRoot.getChild("dependencies", namespace);
	if( dependencyManagementDependenciesRoot != null ) 
	{
		List dependencyManagementDependencyElements = dependencyManagementDependenciesRoot.getChildren();
		for (Iterator iterator = dependencyManagementDependencyElements
					.iterator(); iterator.hasNext();) 
		{

			Element dependencyManagementDependency = (Element) iterator.next();

			Element groupId = dependencyManagementDependency.getChild( "groupId", namespace );
			Element artifactId = dependencyManagementDependency.getChild( "artifactId", namespace );
			Element version = dependencyManagementDependency.getChild( "version", namespace );
			Element scope = dependencyManagementDependency.getChild( "scope", namespace );
			Element type = dependencyManagementDependency.getChild( "type", namespace );

			if( groupId != null && artifactId != null && version != null && scope != null && type != null && 
					"pom".equals(type.getText()) && "import".equals(scope.getText())  ) 
			{

				Dependency importedDependencyManagement = new Dependency();

				importedDependencyManagement.setGroupId( groupId.getText() );
				importedDependencyManagement.setArtifactId( artifactId.getText() );
				importedDependencyManagement.setVersion( version.getText() );
				importedDependencyManagement.setType( type.getText() );
				importedDependencyManagement.setScope( scope.getText() );

				dependencies.add(importedDependencyManagement);
			}
		}
	}

	rewriteDependencies( dependencies, dependencyRoot,
	     mappedVersions, resolvedSnapshotDependencies, originalVersions, projectId,
	     properties, result, releaseDescriptor );
    }
}


  
> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: http://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>         Attachments: MRELEASE-454.diff
>
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

-- 
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] (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "Stephen Connolly (JIRA)" <ji...@codehaus.org>.
     [ https://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stephen Connolly updated MRELEASE-454:
--------------------------------------

    Fix Version/s:     (was: 2.3)
                   2.2.2
    
> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: https://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>            Assignee: Benjamin Bentmann
>             Fix For: 2.2.2
>
>         Attachments: MRELEASE-412_and_MRELEASE-454.patch, MRELEASE-454.diff, MRELEASE-454.patch
>
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

--
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

       

[jira] Updated: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "Pedro Rodriguez (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pedro Rodriguez updated MRELEASE-454:
-------------------------------------

    Attachment: MRELEASE-412_and_MRELEASE-454.patch

This is the patch file to fix MRELEASE-412 and MRELEASE-454

Please, ignore the previous MRELEASE-454.path


> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: http://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>         Attachments: MRELEASE-412_and_MRELEASE-454.patch, MRELEASE-454.diff, MRELEASE-454.patch
>
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

-- 
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] Commented: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "Pedro Rodriguez (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=247472#action_247472 ] 

Pedro Rodriguez commented on MRELEASE-454:
------------------------------------------

The problem is that the current code rewrites the dependencies already resolved. 

org.apache.maven.shared.release.phase.AbstractRewritePomsPhase, Line 272 

if ( project.getDependencyManagement() != null )
{
    Element dependencyRoot = rootElement.getChild( "dependencyManagement", namespace );
    if ( dependencyRoot != null )
    {
	rewriteDependencies( project.getDependencyManagement().getDependencies(), dependencyRoot,
			     mappedVersions, resolvedSnapshotDependencies, originalVersions, projectId,
			     properties, result, releaseDescriptor );
    }
}
        
A simple fix could be to add the "imported dependency management" dependencies to the dependencies list we want to rewrite:

if ( project.getDependencyManagement() != null )
{
    Element dependencyRoot = rootElement.getChild( "dependencyManagement", namespace );
    if ( dependencyRoot != null )
    {
	List dependencies = new ArrayList( project.getDependencyManagement().getDependencies() );

	// Add "imported dependencyManagement" to the dependencies list to allow them to be rewrited as well   
	Element dependencyManagementDependenciesRoot = dependencyRoot.getChild("dependencies", namespace);
	if( dependencyManagementDependenciesRoot != null ) 
	{
		List dependencyManagementDependencyElements = dependencyManagementDependenciesRoot.getChildren();
		for (Iterator iterator = dependencyManagementDependencyElements
					.iterator(); iterator.hasNext();) 
		{

			Element dependencyManagementDependency = (Element) iterator.next();

			Element groupId = dependencyManagementDependency.getChild( "groupId", namespace );
			Element artifactId = dependencyManagementDependency.getChild( "artifactId", namespace );
			Element version = dependencyManagementDependency.getChild( "version", namespace );
			Element scope = dependencyManagementDependency.getChild( "scope", namespace );
			Element type = dependencyManagementDependency.getChild( "type", namespace );

			if( groupId != null && artifactId != null && version != null && scope != null && type != null && 
					"pom".equals(type.getText()) && "import".equals(scope.getText())  ) 
			{

				Dependency importedDependencyManagement = new Dependency();

				importedDependencyManagement.setGroupId( groupId.getText() );
				importedDependencyManagement.setArtifactId( artifactId.getText() );
				importedDependencyManagement.setVersion( version.getText() );
				importedDependencyManagement.setType( type.getText() );
				importedDependencyManagement.setScope( scope.getText() );

				dependencies.add(importedDependencyManagement);
			}
		}
	}

	rewriteDependencies( dependencies, dependencyRoot,
	     mappedVersions, resolvedSnapshotDependencies, originalVersions, projectId,
	     properties, result, releaseDescriptor );
    }
}



> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: http://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

-- 
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] Commented: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "L. Compère (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=246749#action_246749 ] 

L. Compère commented on MRELEASE-454:
-------------------------------------

Is there some kind of workaround for this issue?  

> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: http://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

-- 
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] Closed: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
     [ https://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann closed MRELEASE-454.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.3
         Assignee: Benjamin Bentmann

Fixed in [r1179704|http://svn.apache.org/viewvc?view=revision&revision=1179704], thanks for the tests.

> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: https://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>            Assignee: Benjamin Bentmann
>             Fix For: 2.3
>
>         Attachments: MRELEASE-412_and_MRELEASE-454.patch, MRELEASE-454.diff, MRELEASE-454.patch
>
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] Updated: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "Pedro Rodriguez (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pedro Rodriguez updated MRELEASE-454:
-------------------------------------

    Attachment: MRELEASE-454.diff

A diff file with the documented changes to fix this issue

> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: http://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>         Attachments: MRELEASE-454.diff
>
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

-- 
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] Updated: (MRELEASE-454) The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"

Posted by "Pedro Rodriguez (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MRELEASE-454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pedro Rodriguez updated MRELEASE-454:
-------------------------------------

    Attachment: MRELEASE-454.patch

This is the complete patch containing both changes and unit tests

Please, ignore MRELEASE-454.diff


> The Release-Plugin does not rewrite dependencies in the DependencyManagement with scope "import"
> ------------------------------------------------------------------------------------------------
>
>                 Key: MRELEASE-454
>                 URL: http://jira.codehaus.org/browse/MRELEASE-454
>             Project: Maven 2.x Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 2.0-beta-9
>            Reporter: Jens Mühlenhoff
>         Attachments: MRELEASE-454.diff, MRELEASE-454.patch
>
>
> Add the following node to the pom. Then prepare the release and this section will not be rewriten, because the "imported" entry will not appear in 
> project.getDependencyManagement().getDependencies(). This methode returns all the resolved dependencies. In this situation the transformDocument method from AbstractRewritePomsPhase could not change the given dependencies, because it is not visible to the method.
> <dependencyManagement>
> 		<dependencies>
> 			<dependency>
> 				<groupId>dist</groupId>
> 				<artifactId>deps</artifactId>
> 				<type>pom</type>
> 				<version>4.0.4-SNAPSHOT</version>
> 				<scope>import</scope>
> 			</dependency>
> 		</dependencies>
> </dependencyManagement>

-- 
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