You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by mi...@apache.org on 2003/05/25 12:26:08 UTC

cvs commit: maven-new/core/src/test-input/overriding/legacy project.xml

michal      2003/05/25 03:26:08

  Modified:    core/src/java/org/apache/maven/artifact DefaultArtifact.java
               core/src/test/org/apache/maven/artifact/factory
                        DefaultArtifactFactoryTest.java
               core/src/java/org/apache/maven/artifact/factory
                        DefaultArtifactFactory.java
               core/src/java/org/apache/maven/artifact/layout
                        DefaultRepositoryLayout.java
               core/src/conf layout.properties
               core/src/test-input/overriding project.xml
               core/src/test-input/overriding/legacy project.xml
  Log:
  Fixed artifact overriding
  
  Revision  Changes    Path
  1.10      +11 -3     maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifact.java
  
  Index: DefaultArtifact.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/DefaultArtifact.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultArtifact.java	24 May 2003 13:00:06 -0000	1.9
  +++ DefaultArtifact.java	25 May 2003 10:26:07 -0000	1.10
  @@ -273,9 +273,17 @@
       /**
        * @see org.apache.maven.artifact.Artifact#setFile(java.lang.String)
        */
  -    public void setFile(String file)
  +    public void setFile(String fileStr)
       {
  -        setFile(new File(file));
  +        if ( fileStr != null )
  +        {
  +            setFile(new File(fileStr));
  +        }
  +        else
  +        {
  +           file = null;
  +        }
  +        
       }
   
       /**
  
  
  
  1.8       +6 -6      maven-new/core/src/test/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
  
  Index: DefaultArtifactFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/test/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultArtifactFactoryTest.java	24 May 2003 18:30:27 -0000	1.7
  +++ DefaultArtifactFactoryTest.java	25 May 2003 10:26:07 -0000	1.8
  @@ -248,14 +248,14 @@
   		String msg3="Artifact file has been set incorrectly.";                
   		
   		// a1 - file overrding in POM
  -		File expectedFile1 = new File ( "/foo/baa-1.1.jar" ) ;
  +		File expectedFile1 = new File ( repositoryPath, "g1/jars/lutefisk.fish" ) ;
   		File actualFile1= artifact1.getFile();
   		assertEquals( "File overriding in POM: " + msg3,
                         expectedFile1,
                         actualFile1 );
           
   		// a2 file overring in properties file
  -        File expectedFile2 = new File ( "/lib/d2.jar" ); 
  +        File expectedFile2 = new File (  "/lib/d2.jar" ); 
           File actualFile2= artifact2.getFile();                
           assertEquals( "File overrding in prop. file: " + msg3,
                         expectedFile2,
  @@ -269,7 +269,7 @@
                          actualFile3 );
           
           // a4 - version overrding in  POM 
  -        File expectedFile4 = new File (repositoryPath, "/g4/jars/d4-1.1.jar" ); 
  +        File expectedFile4 = new File ( repositoryPath, "/g4/jars/d4-1.1.jar" ); 
           File actualFile4= artifact4.getFile();                
           assertEquals( "Version overrding in prop. file: " + msg3 ,
                              expectedFile4,
  @@ -280,8 +280,8 @@
   		assertTrue( "Version was overriden." , artifact4.isVersionOverridden() );
   	    assertFalse( "File should not be overriden." , artifact4.isFileOverridden() );
   	    	   
  -		assertFalse( "Version should not be overriden." , artifact1.isVersionOverridden() );
  -	    assertTrue( "File was not overriden." , artifact1.isFileOverridden() );
  +		assertFalse( "Version should not be overriden." , artifact3.isVersionOverridden() );
  +	    assertTrue( "File was not overriden." , artifact3.isFileOverridden() );
   
   	}
   
  
  
  
  1.13      +11 -8     maven-new/core/src/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
  
  Index: DefaultArtifactFactory.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultArtifactFactory.java	24 May 2003 18:30:27 -0000	1.12
  +++ DefaultArtifactFactory.java	25 May 2003 10:26:07 -0000	1.13
  @@ -126,14 +126,17 @@
               artifact.setGroupId( dependency.getArtifactDirectory() );
               artifact.setType( dependency.getType() );                        
               artifact.setVersion( dependency.getVersion() );
  +            
  +            // If artifact has a file set but no 
  +            // file overriding  mechainsm was apllied
  +            // it measn that file sits in repository
  +            // and just last part of the path should
  +            // be replaced
  +            artifact.setFile(dependency.getFile());
             
               if (mavenJarOverride)
               {            
  -                 String file = getOverridenFile( artifact, project );
  -                 if ( file == null ) 
  -                 {
  -                    file = dependency.getFile();                    
  -                 }
  +                 String file = getOverridenFile( artifact, project );                 
                    if ( file != null )
                    {
                        artifact.setFile( file );
  @@ -152,8 +155,8 @@
               if ( artifact.isFileOverridden() == false )
               {    
                   String path = generatePath( artifact );
  -				artifact.setPath( path );
  -				String file = new File(  getMavenRepoLocal( project ) , path ).getAbsolutePath();
  +				artifact.setPath( path );				               
  +                String file = new File(  getMavenRepoLocal( project ) , path ).getAbsolutePath();
   				artifact.setFile( file );            	
               }
               artifacts.add( artifact );
  
  
  
  1.5       +15 -5     maven-new/core/src/java/org/apache/maven/artifact/layout/DefaultRepositoryLayout.java
  
  Index: DefaultRepositoryLayout.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/layout/DefaultRepositoryLayout.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultRepositoryLayout.java	24 May 2003 06:38:57 -0000	1.4
  +++ DefaultRepositoryLayout.java	25 May 2003 10:26:07 -0000	1.5
  @@ -101,10 +101,20 @@
        */
       public String generatePath( Artifact artifact ) throws Exception
       {
  -        // see if we have layout for this artifact type alredy in the cache
  -        String type = artifact.getType();
  -        String layout = getLayout(type);
  -
  +        String layout = null;               
  +        if ( artifact.getFile()!= null )
  +        {
  +            //it means that user is requesting to use a given file name
  +            // so path is: "{group directories}/{type}s/[user provided file]" 
  +            //in such case we will use special layout <<nameless>>
  +            // ( find a better name for this)
  +            layout = getLayout("nameless") + artifact.getFile();;
  +        }
  +        else
  +        {        
  +            // see if we have layout for this artifact type alredy in the cache                             
  +            layout = getLayout( artifact.getType() );
  +        } 
           // interpolation of layout
           layout = StringUtils.replace( layout, "${artifactId}", artifact.getArtifactId() );
           layout =
  
  
  
  1.7       +5 -0      maven-new/core/src/conf/layout.properties
  
  Index: layout.properties
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/conf/layout.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- layout.properties	24 May 2003 06:38:57 -0000	1.6
  +++ layout.properties	25 May 2003 10:26:07 -0000	1.7
  @@ -9,6 +9,11 @@
   # DEFAULT 
   default=${groupId}/${type}s/${artifactId}-${version}.${type}
   
  +# this is for case when user requests to use particular file name
  +nameless=${groupId}/${type}s/
  +
  +
  +
   # EJB
   ejb=${groupId}/ejbs/${artifactId}-${version}.jar
   
  
  
  
  1.3       +1 -1      maven-new/core/src/test-input/overriding/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/test-input/overriding/project.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.xml	24 May 2003 18:30:26 -0000	1.2
  +++ project.xml	25 May 2003 10:26:07 -0000	1.3
  @@ -11,7 +11,7 @@
         <groupId>g1</groupId>
         <artifactId>d1</artifactId>
         <version>v1</version>
  -      <file>/foo/baa-1.1.jar</file>
  +      <file>lutefisk.fish</file>
       </dependency>    
       
       
  
  
  
  1.2       +1 -1      maven-new/core/src/test-input/overriding/legacy/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/test-input/overriding/legacy/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	24 May 2003 18:30:27 -0000	1.1
  +++ project.xml	25 May 2003 10:26:08 -0000	1.2
  @@ -11,7 +11,7 @@
         <groupId>g1</groupId>
         <artifactId>d1</artifactId>
         <version>v1</version>
  -      <jar>/foo/baa-1.1.jar</jar>
  +      <jar>lutefisk.fish</jar>
       </dependency>    
       
       
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org