[MNG-0731] - The distribution mng layout element was not being copied in the model.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@767294 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-04-21 21:09:06 +00:00
parent d470d0c812
commit f53cbd5fbd
3 changed files with 61 additions and 15 deletions

View File

@ -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() );
}

View File

@ -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();

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.it0061</groupId>
<artifactId>maven-it-it0061</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: it0061</name>
<distributionManagement>
<repository>
<id>test</id>
<url>file:target/test-repo</url>
<layout>legacy</layout>
</repository>
</distributionManagement>
</project>