o Replaced license in source

o Added testing to show failure to merge resources from parent into child build which specifies a build without these elements
o Fixed resource blending for child build sections which don't specify them.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163001 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2004-08-23 20:24:54 +00:00
parent 2a3f7b7220
commit 28be3319be
2 changed files with 63 additions and 1 deletions

View File

@ -1,4 +1,21 @@
package org.apache.maven.project.inheritance;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
@ -167,6 +184,11 @@ public class DefaultModelInheritanceAssembler
{
child.getBuild().setTestOutput( parent.getBuild().getTestOutput() );
}
List resources = child.getBuild().getResources();
if(resources == null || resources.isEmpty()) {
child.getBuild().setResources(parent.getBuild().getResources());
}
if ( child.getBuild().getUnitTest() == null )
{
@ -183,6 +205,11 @@ public class DefaultModelInheritanceAssembler
{
child.getBuild().getUnitTest().setExcludes( parent.getBuild().getUnitTest().getExcludes() );
}
List testResources = child.getBuild().getUnitTest().getResources();
if(testResources == null || testResources.isEmpty()) {
child.getBuild().getUnitTest().setResources(parent.getBuild().getUnitTest().getResources());
}
}
}

View File

@ -1,12 +1,28 @@
/* Created on Aug 23, 2004 */
package org.apache.maven.project.inheritance;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
import java.util.Arrays;
import java.util.List;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Resource;
import org.apache.maven.model.UnitTest;
import org.apache.maven.project.MavenProject;
@ -28,10 +44,20 @@ public class DefaultModelInheritanceAssemblerTest extends TestCase {
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);
parentBuild.setUnitTest(parentUT);
parent.setBuild(parentBuild);
@ -48,12 +74,21 @@ public class DefaultModelInheritanceAssemblerTest extends TestCase {
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
assembler.assembleModelInheritance(child, parent);
List childExcludesTest = child.getBuild().getUnitTest().getExcludes();
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"));
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());
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());
}
}