Processors: IssueManagement, Prerequisites

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@751810 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-03-09 19:49:19 +00:00
parent 23a6dad5b8
commit 2fc16b00db
5 changed files with 135 additions and 1 deletions

View File

@ -13,6 +13,5 @@ public class BuildProcessor
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
{
super.process( parent, child, target, isChildMostSpecialized );
}
}

View File

@ -0,0 +1,34 @@
package org.apache.maven.project.processor;
import org.apache.maven.model.IssueManagement;
import org.apache.maven.model.Model;
public class IssueManagementProcessor extends BaseProcessor
{
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
{
super.process( parent, child, target, isChildMostSpecialized );
Model t = (Model) target;
Model c = (Model) child;
Model p = (Model) parent;
if( c.getIssueManagement() != null)
{
IssueManagement childMng = c.getIssueManagement();
IssueManagement mng = new IssueManagement();
mng.setSystem( childMng.getSystem() );
mng.setUrl( childMng.getUrl() );
t.setIssueManagement( mng );
}
else if(p != null && p.getIssueManagement() != null)
{
IssueManagement parentMng = p.getIssueManagement();
IssueManagement mng = new IssueManagement();
mng.setSystem( parentMng .getSystem() );
mng.setUrl( parentMng .getUrl() );
t.setIssueManagement( mng );
}
}
}

View File

@ -0,0 +1,25 @@
package org.apache.maven.project.processor;
import org.apache.maven.model.Model;
import org.apache.maven.model.Prerequisites;
public class PrerequisitesProcessor extends BaseProcessor
{
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
{
super.process( parent, child, target, isChildMostSpecialized );
if ( isChildMostSpecialized )
{
Model t = (Model) target;
Model c = (Model) child;
if(c.getPrerequisites() == null)
{
return;
}
Prerequisites prerequisites = new Prerequisites();
prerequisites.setMaven( c.getPrerequisites().getMaven());
t.setPrerequisites( prerequisites );
}
}
}

View File

@ -0,0 +1,27 @@
package org.apache.maven.project.processor;
import org.apache.maven.model.IssueManagement;
import org.apache.maven.model.Model;
import junit.framework.TestCase;
public class IssueManagementProcessorTest extends TestCase
{
public void testChildCopy()
{
IssueManagement mng = new IssueManagement();
mng.setSystem( "system" );
mng.setUrl( "http://url" );
Model child = new Model();
child.setIssueManagement( mng );
Model target = new Model();
IssueManagementProcessor proc = new IssueManagementProcessor();
proc.process( null, child, target, false );
assertEquals("system", target.getIssueManagement().getSystem());
assertEquals("http://url", target.getIssueManagement().getUrl());
}
}

View File

@ -0,0 +1,49 @@
package org.apache.maven.project.processor;
import org.apache.maven.model.Model;
import org.apache.maven.model.Prerequisites;
import junit.framework.TestCase;
public class PrerequisitesProcessorTest extends TestCase
{
public void testMaven()
{
Prerequisites prerequisites = new Prerequisites();
prerequisites.setMaven( "2.1" );
Model child = new Model();
child.setPrerequisites( prerequisites );
Model target = new Model();
PrerequisitesProcessor proc = new PrerequisitesProcessor();
proc.process( null, child, target, true );
assertEquals("2.1", target.getPrerequisites().getMaven());
//Immutable
prerequisites.setMaven( "2.2" );
assertEquals("2.1", target.getPrerequisites().getMaven());
}
public void testMavenParent()
{
Prerequisites prerequisites = new Prerequisites();
prerequisites.setMaven( "2.1" );
Model parent = new Model();
parent.setPrerequisites( prerequisites );
Model target = new Model();
PrerequisitesProcessor proc = new PrerequisitesProcessor();
proc.process( parent, new Model(), target, false );
assertEquals(null, target.getPrerequisites());
}
}