maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance DefaultModelInheritanceAssembler.java
Date Mon, 23 Aug 2004 20:24:55 GMT
jdcasey     2004/08/23 13:24:54

  Modified:    maven-core/src/test/java/org/apache/maven/project/inheritance
                        DefaultModelInheritanceAssemblerTest.java
               maven-core/src/main/java/org/apache/maven/project/inheritance
                        DefaultModelInheritanceAssembler.java
  Log:
  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.
  
  Revision  Changes    Path
  1.2       +36 -1     maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java
  
  Index: DefaultModelInheritanceAssemblerTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultModelInheritanceAssemblerTest.java	23 Aug 2004 20:04:34 -0000	1.1
  +++ DefaultModelInheritanceAssemblerTest.java	23 Aug 2004 20:24:54 -0000	1.2
  @@ -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 @@
           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 @@
           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());
       }
   
   }
  
  
  
  1.4       +28 -1     maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
  
  Index: DefaultModelInheritanceAssembler.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultModelInheritanceAssembler.java	23 Aug 2004 20:04:34 -0000	1.3
  +++ DefaultModelInheritanceAssembler.java	23 Aug 2004 20:24:54 -0000	1.4
  @@ -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 @@
               {
                   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 )
               {
  @@ -182,6 +204,11 @@
                   if ( child.getBuild().getUnitTest().getExcludes().size() == 0 )
                   {
                       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());
                   }
               }
           }
  
  
  

Mime
View raw message