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
|
@ -25,8 +25,10 @@ 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.
|
||||
* @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,7 +188,8 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
List resources = child.getBuild().getResources();
|
||||
if(resources == null || resources.isEmpty()) {
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
{
|
||||
child.getBuild().setResources( parent.getBuild().getResources() );
|
||||
}
|
||||
|
||||
|
@ -207,7 +210,8 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
List testResources = child.getBuild().getUnitTest().getResources();
|
||||
if(testResources == null || testResources.isEmpty()) {
|
||||
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,34 +25,42 @@ 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" );
|
||||
|
||||
Build parentBuild = new Build();
|
||||
|
||||
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 );
|
||||
|
||||
UnitTest parentUT = new UnitTest();
|
||||
|
||||
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 );
|
||||
|
@ -66,29 +73,39 @@ public class DefaultModelInheritanceAssemblerTest extends TestCase {
|
|||
Build childBuild = new Build();
|
||||
|
||||
UnitTest childUT = new UnitTest();
|
||||
|
||||
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());
|
||||
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( "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