diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/processors/DistributionManagementProcessor.java b/maven-model-builder/src/main/java/org/apache/maven/model/processors/DistributionManagementProcessor.java index 1cc137d2c6..3c9727c5b7 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/processors/DistributionManagementProcessor.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/processors/DistributionManagementProcessor.java @@ -45,12 +45,12 @@ public class DistributionManagementProcessor if ( c.getDistributionManagement() != null ) { - copy( c.getDistributionManagement(), t.getDistributionManagement(), isChildMostSpecialized, - c.getArtifactId(), p ); if ( p != null && p.getDistributionManagement() != null ) { copy( p.getDistributionManagement(), t.getDistributionManagement(), false, c.getArtifactId(), p ); - } + } + copy( c.getDistributionManagement(), t.getDistributionManagement(), isChildMostSpecialized, + c.getArtifactId(), p ); } else if ( p != null && p.getDistributionManagement() != null ) { @@ -66,12 +66,12 @@ public class DistributionManagementProcessor private void copy( DistributionManagement source, DistributionManagement target, boolean isChild, String artifactId, Model parent ) { - if ( target.getDownloadUrl() == null ) + if ( source.getDownloadUrl() != null ) { target.setDownloadUrl( source.getDownloadUrl() ); } - if ( target.getRelocation() == null && isChild && source.getRelocation() != null ) + if ( isChild && source.getRelocation() != null ) { Relocation sourceRelocation = source.getRelocation(); Relocation r = new Relocation(); @@ -82,24 +82,24 @@ public class DistributionManagementProcessor target.setRelocation( r ); } - if ( target.getStatus() == null ) + if ( source.getStatus() != null ) { target.setStatus( source.getStatus() ); } - if ( target.getRepository() == null && source.getRepository() != null ) + if ( source.getRepository() != null ) { target.setRepository( new DeploymentRepository() ); copyRepository( source.getRepository(), target.getRepository() ); } - if ( target.getSnapshotRepository() == null && source.getSnapshotRepository() != null ) + if ( source.getSnapshotRepository() != null ) { target.setSnapshotRepository( new DeploymentRepository() ); copyRepository( source.getSnapshotRepository(), target.getSnapshotRepository() ); } - if ( target.getSite() == null && source.getSite() != null ) + if ( source.getSite() != null ) { target.setSite( new Site() ); copySite( source.getSite(), target.getSite(), isChild, artifactId, parent ); @@ -108,22 +108,22 @@ public class DistributionManagementProcessor private void copyRepository( DeploymentRepository source, DeploymentRepository target ) { - if ( target.getId() == null ) + if ( source.getId() != null ) { target.setId( source.getId() ); } - if ( target.getLayout() == null ) + if ( source.getLayout() != null ) { target.setLayout( source.getLayout() ); } - if ( target.getUrl() == null ) + if ( source.getUrl() != null ) { target.setUrl( source.getUrl() ); } - if ( target.getName() == null ) + if ( source.getName() != null ) { target.setName( source.getName() ); } @@ -133,12 +133,12 @@ public class DistributionManagementProcessor private void copySite( Site source, Site target, boolean isChild, String artifactId, Model parent ) { - if ( target.getId() == null ) + if ( source.getId() != null ) { target.setId( source.getId() ); } - if ( target.getName() == null ) + if ( source.getName() != null ) { target.setName( source.getName() ); } diff --git a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java index dd35f694c3..e3398fce4a 100644 --- a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -1396,6 +1396,13 @@ public class PomConstructionTest assertEquals( 20, ( (List) pom.getValue( "build/pluginManagement/plugins" ) ).size() ); } + public void testDistributionManagement() + throws Exception + { + PomTestWrapper pom = this.buildPom( "distribution-management"); + assertEquals("legacy", pom.getValue( "distributionManagement/repository/layout" )); +} + private void assertPathSuffixEquals( String expected, Object actual ) { String a = actual.toString(); diff --git a/maven-project/src/test/resources-project-builder/distribution-management/pom.xml b/maven-project/src/test/resources-project-builder/distribution-management/pom.xml new file mode 100644 index 0000000000..0c98793eca --- /dev/null +++ b/maven-project/src/test/resources-project-builder/distribution-management/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + + org.apache.maven.its.it0061 + maven-it-it0061 + 1.0 + jar + + Maven Integration Test :: it0061 + + + + test + file:target/test-repo + legacy + + +