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/resources/projects/base-directory-alignment project-which-needs-directory-alignment.xml
Date Thu, 24 Feb 2005 04:37:54 GMT
brett       2005/02/23 20:37:54

  Modified:    maven-core/src/main/java/org/apache/maven/project/path
                        DefaultPathTranslator.java
               maven-core/src/test/java/org/apache/maven/project
                        ProjectBaseDirectoryAlignmentTest.java
               maven-core/src/test/resources/projects/base-directory-alignment
                        project-which-needs-directory-alignment.xml
  Log:
  path alignment for files in dependency
  
  Revision  Changes    Path
  1.6       +20 -0     maven-components/maven-core/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
  
  Index: DefaultPathTranslator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultPathTranslator.java	24 Feb 2005 04:15:47 -0000	1.5
  +++ DefaultPathTranslator.java	24 Feb 2005 04:37:54 -0000	1.6
  @@ -18,6 +18,7 @@
    */
   
   import org.apache.maven.model.Build;
  +import org.apache.maven.model.Dependency;
   import org.apache.maven.model.Model;
   import org.apache.maven.model.Resource;
   
  @@ -95,6 +96,25 @@
                   }
               }
   
  +            List dependencies = model.getDependencies();
  +
  +            for ( Iterator i = dependencies.iterator(); i.hasNext(); )
  +            {
  +                Dependency dependency = (Dependency) i.next();
  +
  +                s = dependency.getFile();
  +
  +                if ( s != null )
  +                {
  +                    s = stripBasedirToken( s );
  +
  +                    if ( requiresBaseDirectoryAlignment( s ) )
  +                    {
  +                        dependency.setFile( new File( projectFile.getParentFile(), s ).getPath()
);
  +                    }
  +                }
  +            }
  +
               s = stripBasedirToken( build.getOutput() );
   
               if ( requiresBaseDirectoryAlignment( s ) )
  
  
  
  1.7       +35 -5     maven-components/maven-core/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java
  
  Index: ProjectBaseDirectoryAlignmentTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ProjectBaseDirectoryAlignmentTest.java	23 Dec 2004 23:46:42 -0000	1.6
  +++ ProjectBaseDirectoryAlignmentTest.java	24 Feb 2005 04:37:54 -0000	1.7
  @@ -1,22 +1,24 @@
   package org.apache.maven.project;
   
  +import org.apache.maven.MavenTestCase;
   import org.apache.maven.model.Build;
  +import org.apache.maven.model.Dependency;
   import org.apache.maven.model.Resource;
  -import org.apache.maven.MavenTestCase;
   
   import java.io.File;
  +import java.util.Iterator;
   
   public class ProjectBaseDirectoryAlignmentTest
       extends MavenTestCase
  -{        
  -    
  +{
  +
       private String dir = "src/test/resources/projects/base-directory-alignment/";
  -        
  +
       public void testProjectDirectoryBaseDirectoryAlignment()
           throws Exception
       {
           File f = getTestFile( dir + "project-which-needs-directory-alignment.xml" );
  -        
  +
           MavenProject project = getProject( f, false );
   
           assertNotNull( "Test project can't be null!", project );
  @@ -30,5 +32,33 @@
           Resource resource = (Resource) build.getResources().get( 0 );
   
           assertTrue( resource.getDirectory().startsWith( getBasedir() ) );
  +
  +        String relativeFile = null;
  +        String absoluteFile = null;
  +        String managedDependencyFile = null;
  +        for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
  +        {
  +            Dependency d = (Dependency) i.next();
  +            if ( d.getGroupId().equals( "g1" ) )
  +            {
  +                relativeFile = d.getFile();
  +            }
  +            else if ( d.getGroupId().equals( "g2" ) )
  +            {
  +                absoluteFile = d.getFile();
  +            }
  +            else if ( d.getGroupId().equals( "g3" ) )
  +            {
  +                managedDependencyFile = d.getFile();
  +            }
  +        }
  +
  +        assertNotNull( "Required dependency missing: g1:d1", relativeFile );
  +        assertNotNull( "Required dependency missing: g2:d2", absoluteFile );
  +        assertNotNull( "Required dependency missing: g3:d3", managedDependencyFile );
  +
  +        assertTrue( "Relative file not adjusted", relativeFile.startsWith( getBasedir()
) );
  +        assertEquals( "Absolute file was incorrectly modified", "/top/level/path", absoluteFile
);
  +        assertTrue( "Managed dependency not adjusted", managedDependencyFile.startsWith(
getBasedir() ) );
       }
   }
  
  
  
  1.3       +19 -0     maven-components/maven-core/src/test/resources/projects/base-directory-alignment/project-which-needs-directory-alignment.xml
  
  Index: project-which-needs-directory-alignment.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/resources/projects/base-directory-alignment/project-which-needs-directory-alignment.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project-which-needs-directory-alignment.xml	5 Dec 2004 04:16:06 -0000	1.2
  +++ project-which-needs-directory-alignment.xml	24 Feb 2005 04:37:54 -0000	1.3
  @@ -64,6 +64,7 @@
         <artifactId>d1</artifactId>
         <version>1.0</version>
         <url>d1-url</url>
  +      <file>foo/bar</file>
       </dependency>
   
       <dependency>
  @@ -71,10 +72,28 @@
         <artifactId>d2</artifactId>
         <version>2.0</version>
         <url>d2-url</url>
  +      <file>/top/level/path</file>
  +    </dependency>
  +
  +    <dependency>
  +      <groupId>g3</groupId>
  +      <artifactId>d3</artifactId>
       </dependency>
   
     </dependencies>
   
  +  <dependencyManagement>
  +    <dependencies>
  +      <dependency>
  +        <groupId>g3</groupId>
  +        <artifactId>d3</artifactId>
  +        <version>3.0</version>
  +        <url>d3-url</url>
  +        <file>g3/d3</file>
  +      </dependency>      
  +    </dependencies>
  +  </dependencyManagement>
  +
     <build>
       <nagEmailAddress>jason@maven.org</nagEmailAddress>
       <sourceDirectory>sourceDirectory</sourceDirectory>
  
  
  

Mime
View raw message