mirror of https://github.com/apache/maven.git
o Reformatted source code.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163002 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
28be3319be
commit
975e9491d8
|
@ -24,9 +24,11 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
* @todo generate this with modello to keep it in sync with changes in the model.
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||
* @version $Id: DefaultModelInheritanceAssembler.java,v 1.4 2004/08/23 20:24:54
|
||||
* jdcasey Exp $
|
||||
* @todo generate this with modello to keep it in sync with changes in the
|
||||
* model.
|
||||
*/
|
||||
public class DefaultModelInheritanceAssembler
|
||||
implements ModelInheritanceAssembler
|
||||
|
@ -81,7 +83,6 @@ public class DefaultModelInheritanceAssembler
|
|||
child.setUrl( parent.getUrl() );
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Distribution
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -152,7 +153,8 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
else
|
||||
{
|
||||
// The build has been set but we want to step in here and fill in values
|
||||
// The build has been set but we want to step in here and fill in
|
||||
// values
|
||||
// that have not been set by the child.
|
||||
|
||||
if ( child.getBuild().getDirectory() == null )
|
||||
|
@ -186,8 +188,9 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
List resources = child.getBuild().getResources();
|
||||
if(resources == null || resources.isEmpty()) {
|
||||
child.getBuild().setResources(parent.getBuild().getResources());
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
{
|
||||
child.getBuild().setResources( parent.getBuild().getResources() );
|
||||
}
|
||||
|
||||
if ( child.getBuild().getUnitTest() == null )
|
||||
|
@ -207,8 +210,9 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
List testResources = child.getBuild().getUnitTest().getResources();
|
||||
if(testResources == null || testResources.isEmpty()) {
|
||||
child.getBuild().getUnitTest().setResources(parent.getBuild().getUnitTest().getResources());
|
||||
if ( testResources == null || testResources.isEmpty() )
|
||||
{
|
||||
child.getBuild().getUnitTest().setResources( parent.getBuild().getUnitTest().getResources() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ package org.apache.maven.project.inheritance;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Model;
|
||||
|
@ -26,69 +25,87 @@ import org.apache.maven.model.Resource;
|
|||
import org.apache.maven.model.UnitTest;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
public class DefaultModelInheritanceAssemblerTest extends TestCase {
|
||||
|
||||
public void testShouldOverrideUnitTestExcludesOnly() {
|
||||
public class DefaultModelInheritanceAssemblerTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testShouldOverrideUnitTestExcludesOnly()
|
||||
{
|
||||
Model parent = new Model();
|
||||
parent.setGroupId("test");
|
||||
parent.setArtifactId("test");
|
||||
parent.setVersion("0.0");
|
||||
|
||||
parent.setGroupId( "test" );
|
||||
parent.setArtifactId( "test" );
|
||||
parent.setVersion( "0.0" );
|
||||
|
||||
Build parentBuild = new Build();
|
||||
parentBuild.setSourceDirectory("src/main/java");
|
||||
parentBuild.setAspectSourceDirectory("src/main/aspects");
|
||||
parentBuild.setUnitTestSourceDirectory("src/test/java");
|
||||
|
||||
parentBuild.setSourceDirectory( "src/main/java" );
|
||||
parentBuild.setAspectSourceDirectory( "src/main/aspects" );
|
||||
parentBuild.setUnitTestSourceDirectory( "src/test/java" );
|
||||
|
||||
Resource parentResource = new Resource();
|
||||
parentResource.setDirectory("src/main/resources");
|
||||
|
||||
parentBuild.addResource(parentResource);
|
||||
parentResource.setDirectory( "src/main/resources" );
|
||||
|
||||
parentBuild.addResource( parentResource );
|
||||
|
||||
UnitTest parentUT = new UnitTest();
|
||||
parentUT.setIncludes(Arrays.asList(new String[] {"**/*Test.java"}));
|
||||
parentUT.setExcludes(Arrays.asList(new String[] {"**/*Abstract*.java"}));
|
||||
|
||||
parentUT.setIncludes( Arrays.asList( new String[] { "**/*Test.java" } ) );
|
||||
parentUT.setExcludes( Arrays.asList( new String[] { "**/*Abstract*.java" } ) );
|
||||
|
||||
Resource parentUTResource = new Resource();
|
||||
parentUTResource.setDirectory("src/test/resources");
|
||||
|
||||
parentUT.addResource(parentUTResource);
|
||||
parentUTResource.setDirectory( "src/test/resources" );
|
||||
|
||||
parentBuild.setUnitTest(parentUT);
|
||||
parent.setBuild(parentBuild);
|
||||
parentUT.addResource( parentUTResource );
|
||||
|
||||
parentBuild.setUnitTest( parentUT );
|
||||
parent.setBuild( parentBuild );
|
||||
|
||||
Model child = new Model();
|
||||
|
||||
Build childBuild = new Build();
|
||||
|
||||
UnitTest childUT = new UnitTest();
|
||||
parentUT.setExcludes(Arrays.asList(new String[] {"**/*Abstract*.java", "**/*AspectTest.java"}));
|
||||
|
||||
childBuild.setUnitTest(childUT);
|
||||
child.setBuild(childBuild);
|
||||
parentUT.setExcludes( Arrays.asList( new String[] { "**/*Abstract*.java", "**/*AspectTest.java" } ) );
|
||||
|
||||
childBuild.setUnitTest( childUT );
|
||||
child.setBuild( childBuild );
|
||||
|
||||
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
|
||||
assembler.assembleModelInheritance(child, parent);
|
||||
|
||||
assertEquals("source directory should be from parent", "src/main/java", child.getBuild().getSourceDirectory());
|
||||
assertEquals("unit test source directory should be from parent", "src/test/java", child.getBuild().getUnitTestSourceDirectory());
|
||||
assertEquals("aspect source directory should be from parent", "src/main/aspects", child.getBuild().getAspectSourceDirectory());
|
||||
assembler.assembleModelInheritance( child, parent );
|
||||
|
||||
assertEquals( "source directory should be from parent", "src/main/java", child.getBuild().getSourceDirectory() );
|
||||
assertEquals( "unit test source directory should be from parent", "src/test/java", child.getBuild()
|
||||
.getUnitTestSourceDirectory() );
|
||||
assertEquals( "aspect source directory should be from parent", "src/main/aspects", child.getBuild()
|
||||
.getAspectSourceDirectory() );
|
||||
|
||||
List childExcludesTest = child.getBuild().getUnitTest().getExcludes();
|
||||
assertTrue("unit test excludes should have **/*AspectTest.java", childExcludesTest.contains("**/*AspectTest.java"));
|
||||
assertTrue("unit test excludes should have **/*Abstract*.java", childExcludesTest.contains("**/*Abstract*.java"));
|
||||
|
||||
assertTrue( "unit test excludes should have **/*AspectTest.java", childExcludesTest
|
||||
.contains( "**/*AspectTest.java" ) );
|
||||
assertTrue( "unit test excludes should have **/*Abstract*.java", childExcludesTest
|
||||
.contains( "**/*Abstract*.java" ) );
|
||||
|
||||
List resources = child.getBuild().getResources();
|
||||
assertEquals("build resources inherited from parent should be of size 1", 1, resources.size());
|
||||
assertEquals("first resource should have dir == src/main/resources", "src/main/resources", ((Resource)resources.get(0)).getDirectory());
|
||||
|
||||
assertEquals( "build resources inherited from parent should be of size 1", 1, resources.size() );
|
||||
assertEquals( "first resource should have dir == src/main/resources", "src/main/resources",
|
||||
((Resource) resources.get( 0 )).getDirectory() );
|
||||
|
||||
List utResources = child.getBuild().getUnitTest().getResources();
|
||||
assertEquals("UT resources inherited from parent should be of size 1", 1, utResources.size());
|
||||
assertEquals("first UT resource should have dir == src/test/resources", "src/test/resources", ((Resource)utResources.get(0)).getDirectory());
|
||||
}
|
||||
|
||||
assertEquals( "UT resources inherited from parent should be of size 1", 1, utResources.size() );
|
||||
assertEquals( "first UT resource should have dir == src/test/resources", "src/test/resources",
|
||||
((Resource) utResources.get( 0 )).getDirectory() );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue