Author: dantran Date: Wed May 17 09:32:30 2006 New Revision: 407308 URL: http://svn.apache.org/viewvc?rev=407308&view=rev Log: MASSEMBLY-100: Convert FileItem's source to absolute path if needed by prepend ${basedir}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java?rev=407308&r1=407307&r2=407308&view=diff ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java (original) +++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java Wed May 17 09:32:30 2006 @@ -1267,25 +1267,24 @@ protected void processFileList( Archiver archiver, List fileList, boolean includeBaseDirecetory ) throws MojoExecutionException, MojoFailureException { - String sourceFileItem = null; - for ( Iterator i = fileList.iterator(); i.hasNext(); ) { FileItem fileItem = (FileItem) i.next(); + //ensure source file is in absolute path for reactor build to work + File source = new File ( fileItem.getSource() ); + if ( ! source.isAbsolute() ) + { + source = new File( this.basedir, fileItem.getSource() ); + } + if ( fileItem.isFiltered() ) { - sourceFileItem = fileItem.getSource(); - - File filteredFile = filterFile( new File( sourceFileItem ) ); - - fileItem.setSource( filteredFile.getAbsolutePath() ); + source = filterFile( source ).getAbsoluteFile(); } String outputDirectory = fileItem.getOutputDirectory(); - File source = new File( fileItem.getSource() ); - if ( outputDirectory == null ) { outputDirectory = ""; @@ -1339,13 +1338,6 @@ catch ( ArchiverException e ) { throw new MojoExecutionException( "Error adding file to archive: " + e.getMessage(), e ); - } - - // @todo delete this part - // return to original source - if ( fileItem.isFiltered() ) - { - fileItem.setSource( sourceFileItem ); } } } Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java?rev=407308&r1=407307&r2=407308&view=diff ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java (original) +++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java Wed May 17 09:32:30 2006 @@ -663,7 +663,7 @@ { generateTestFileSets( "\r\n" ); - AssemblyMojo mojo = executeMojo( "fileItem-output-name-plugin-config.xml" ); + executeMojo( "fileItem-output-name-plugin-config.xml" ); Map archiverFiles = ArchiverManagerStub.archiverStub.getFiles(); @@ -678,7 +678,7 @@ assertTrue( "Test if archived file exists", archivedFile.exists() ); String contents = FileUtils.fileRead( archivedFile.getAbsolutePath() ); - + assertTrue( "Test if file filtering is disabled", contents.indexOf( "${project.artifactId}" ) >= 0 ); } @@ -1148,11 +1148,11 @@ File fileSetDir = new File( PlexusTestCase.getBasedir(), "target/test-classes/fileSet" ); assertNotNull( "Test if FileSet is in the archive", archivedFiles.remove( fileSetDir ) ); - - File readme = new File( "target/test-classes/fileSet/README.txt" ); + + File readme = new File( PlexusTestCase.getBasedir(), "target/test-classes/fileSet/README.txt" ); assertNotNull( "Test if FileItem README.txt is in the archive", archivedFiles.remove( readme ) ); - File license = new File( "target/test-classes/fileSet/LICENSE.txt" ); + File license = new File( PlexusTestCase.getBasedir(), "target/test-classes/fileSet/LICENSE.txt" ); assertNotNull( "Test if FileItem LICENSE.txt is in the archive", archivedFiles.remove( license ) ); assertTrue( "Test there are no more files in the archive", archivedFiles.isEmpty() );