[MNG-4102] -Properties used for interpolation of inherited properties can't be customized by child. [BUG] - override property in profile.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@757485 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-03-23 18:19:37 +00:00
parent 4b3dcfac94
commit 0f8624c297
4 changed files with 57 additions and 11 deletions

View File

@ -82,7 +82,7 @@ public class ProcessorContext
List<Processor> processors =
Arrays.asList( (Processor) new BuildProcessor( new ArrayList<Processor>() ),
(Processor) new ProfilesModuleProcessor(), new PropertiesProcessor(), new ParentProcessor(),
(Processor) new ProfilesModuleProcessor(), new ProfilePropertiesProcessor(), new ParentProcessor(),
new OrganizationProcessor(), new MailingListProcessor(), new IssueManagementProcessor(),
new CiManagementProcessor(), new ReportingProcessor(), new RepositoriesProcessor(),
new DistributionManagementProcessor());

View File

@ -0,0 +1,40 @@
package org.apache.maven.project.processor;
import java.util.Properties;
import org.apache.maven.model.Model;
public class ProfilePropertiesProcessor
extends BaseProcessor
{
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
{
super.process( parent, child, target, isChildMostSpecialized );
Model t = (Model) target, c = (Model) child, p = (Model) parent;
Properties properties = new Properties();
if ( c.getProperties() != null )
{
properties.putAll( c.getProperties() );
}
if ( p != null && p.getProperties() != null )
{
properties.putAll( p.getProperties() );
}
if ( !properties.isEmpty() )
{
if(t.getProperties().isEmpty())
{
t.setProperties( properties );
}
else
{
t.getProperties().putAll( properties );
}
}
}
}

View File

@ -32,21 +32,27 @@ public class PropertiesProcessor
Model t = (Model) target, c = (Model) child, p = (Model) parent;
Properties properties = new Properties();
if ( c.getProperties() != null )
{
properties.putAll( c.getProperties() );
}
if ( p != null && p.getProperties() != null )
{
properties.putAll( p.getProperties() );
}
if ( c.getProperties() != null )
{
properties.putAll( c.getProperties() );
}
if ( !properties.isEmpty() )
{
t.setProperties( properties );
if(t.getProperties().isEmpty())
{
t.setProperties( properties );
}
else
{
t.getProperties().putAll( properties );
}
}
}
}

View File

@ -1176,23 +1176,23 @@ public class PomConstructionTest
{
PomTestWrapper pom =
buildPomFromMavenProject( "profile-injection-order", "pom-a", "pom-b", "pom-e", "pom-c", "pom-d" );
assertEquals( "e", pom.getValue( "properties[1]/pomProperty" ) );
}
//*/
/* FIXME
/* FIXME*/
public void testPropertiesInheritance()
throws Exception
{
PomTestWrapper pom = buildPom( "properties-inheritance/sub" );
assertEquals( "parent-property", pom.getValue( "properties/parentProperty" ) );
assertEquals( "child-property", pom.getValue( "properties/childProperty" ) );
assertEquals( "child-override", pom.getValue( "properties/overriddenProperty" ) );
}
//*/
/* FIXME: MNG-4102
/* FIXME: MNG-4102*/
public void testInheritedPropertiesInterpolatedWithValuesFromChild()
throws Exception
{