maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-core/src/test/java/org/apache/maven/project DefaultProjectDefaultsInjectorTest.java
Date Thu, 24 Feb 2005 04:16:18 GMT
brett       2005/02/23 20:16:18

  Modified:    maven-model maven.mdo
               maven-core/src/main/java/org/apache/maven/project/injection
                        DefaultModelDefaultsInjector.java
               maven-core/src/test/java/org/apache/maven/project
                        DefaultProjectDefaultsInjectorTest.java
  Log:
  add file to dependency, and handle in injection
  
  Revision  Changes    Path
  1.75      +6 -0      maven-components/maven-model/maven.mdo
  
  Index: maven.mdo
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-model/maven.mdo,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- maven.mdo	24 Feb 2005 04:01:14 -0000	1.74
  +++ maven.mdo	24 Feb 2005 04:16:18 -0000	1.75
  @@ -807,6 +807,12 @@
               <multiplicity>*</multiplicity>
             </association>
           </field>
  +        <field>
  +          <name>file</name>
  +          <version>4.0.0</version>
  +          <description>Override the use of a repository - retrieve it from this file</description>
  +          <type>String</type>
  +        </field>
         </fields>
         <codeSegments>
           <codeSegment>
  
  
  
  1.2       +5 -0      maven-components/maven-core/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java
  
  Index: DefaultModelDefaultsInjector.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultModelDefaultsInjector.java	23 Feb 2005 03:26:59 -0000	1.1
  +++ DefaultModelDefaultsInjector.java	24 Feb 2005 04:16:18 -0000	1.2
  @@ -82,6 +82,11 @@
               dep.setVersion( def.getVersion() );
           }
   
  +        if ( dep.getFile() == null && def.getFile() != null )
  +        {
  +            dep.setFile( def.getFile() );
  +        }
  +
           Properties props = new Properties( def.getProperties() );
           props.putAll( dep.getProperties() );
           dep.setProperties( props );
  
  
  
  1.6       +65 -2     maven-components/maven-core/src/test/java/org/apache/maven/project/DefaultProjectDefaultsInjectorTest.java
  
  Index: DefaultProjectDefaultsInjectorTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/DefaultProjectDefaultsInjectorTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultProjectDefaultsInjectorTest.java	23 Feb 2005 03:27:00 -0000	1.5
  +++ DefaultProjectDefaultsInjectorTest.java	24 Feb 2005 04:16:18 -0000	1.6
  @@ -27,8 +27,6 @@
   
   /**
    * @author jdcasey
  - *         <p/>
  - *         Created on Feb 1, 2005
    */
   public class DefaultProjectDefaultsInjectorTest
   extends TestCase
  @@ -53,6 +51,7 @@
           def.setGroupId( dep.getGroupId() );
           def.setArtifactId( dep.getArtifactId() );
           def.setVersion( "1.0.1" );
  +        def.setFile( "file" );
   
           DependencyManagement depMgmt = new DependencyManagement();
   
  @@ -205,6 +204,70 @@
           assertEquals( "value", result.getProperties().getProperty( "test" ) );
       }
   
  +    public void testShouldMergeDefaultFileWhenDependencyDoesntSupplyFile()
  +    {
  +        Model model = new Model();
  +
  +        Dependency dep = new Dependency();
  +        dep.setGroupId( "myGroup" );
  +        dep.setArtifactId( "myArtifact" );
  +        dep.setVersion( "1.0.1" );
  +        dep.setFile( "file" );
  +
  +        model.addDependency( dep );
  +
  +        Dependency def = new Dependency();
  +        def.setGroupId( dep.getGroupId() );
  +        def.setArtifactId( dep.getArtifactId() );
  +
  +        DependencyManagement depMgmt = new DependencyManagement();
  +
  +        depMgmt.addDependency( def );
  +
  +        model.setDependencyManagement( depMgmt );
  +
  +        new DefaultModelDefaultsInjector().injectDefaults( model );
  +
  +        List deps = model.getDependencies();
  +        assertEquals( 1, deps.size() );
  +
  +        Dependency result = (Dependency) deps.get( 0 );
  +
  +        assertEquals( "file", result.getFile() );
  +    }
  +
  +    public void testShouldNotMergeDefaultFileWhenDependencySuppliesFile()
  +    {
  +        Model model = new Model();
  +
  +        Dependency dep = new Dependency();
  +        dep.setGroupId( "myGroup" );
  +        dep.setArtifactId( "myArtifact" );
  +        dep.setVersion( "1.0.1" );
  +        dep.setFile( "file" );
  +
  +        model.addDependency( dep );
  +
  +        Dependency def = new Dependency();
  +        def.setGroupId( dep.getGroupId() );
  +        def.setArtifactId( dep.getArtifactId() );
  +        def.setFile( "default" );
  +
  +        DependencyManagement depMgmt = new DependencyManagement();
  +
  +        depMgmt.addDependency( def );
  +
  +        model.setDependencyManagement( depMgmt );
  +
  +        new DefaultModelDefaultsInjector().injectDefaults( model );
  +
  +        List deps = model.getDependencies();
  +        assertEquals( 1, deps.size() );
  +
  +        Dependency result = (Dependency) deps.get( 0 );
  +        assertEquals( "file", result.getFile() );
  +    }
  +
       public void testShouldRejectDependencyWhereNoVersionIsFoundAfterDefaultsInjection()
       {
           Model model = new Model();
  
  
  

Mime
View raw message