maven-file-management-1.2.1/0000755000175000017500000000000011226716142015610 5ustar twernertwernermaven-file-management-1.2.1/src/0000755000175000017500000000000011226716142016377 5ustar twernertwernermaven-file-management-1.2.1/src/site/0000755000175000017500000000000011226716142017343 5ustar twernertwernermaven-file-management-1.2.1/src/site/site.xml0000644000175000017500000000201611020006575021022 0ustar twernertwerner maven-file-management-1.2.1/src/site/apt/0000755000175000017500000000000011226716142020127 5ustar twernertwernermaven-file-management-1.2.1/src/site/apt/examples/0000755000175000017500000000000011226716142021745 5ustar twernertwernermaven-file-management-1.2.1/src/site/apt/examples/mojo.apt0000644000175000017500000000723411020006575023417 0ustar twernertwerner ------ Using Maven File Management API In A MOJO ------ Vincent Siveton ------ November 2007 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you 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. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Using Maven File Management API In A MOJO This part explains how to use the Maven File Management API in a Maven Plugin. * Add File Management API dependency The first step is to add the File Management API as a Maven dependency, i.e. in the <<>>: +-----+ ... org.apache.maven.shared file-management 1.2 ... ... +-----+ * Add FileSet in a MOJO The second step is to create your MOJO and add a <<>> object: +-----+ /** * My MOJO * * @goal myGoal */ public class MyMojo extends AbstractMojo { /** * A list of fileSet rules to select files and directories. * * @parameter */ private List filesets; /** * A specific fileSet rule to select files and directories. * * @parameter */ private FileSet fileset; ... } +-----+ To use the <<>> object, you need to instantiate the <<>>. +-----+ FileSetManager fileSetManager = new FileSetManager(); String[] includedFiles = fileSetManager.getIncludedFiles( fileset ); String[] includedDir = fileSetManager.getIncludedDirectories( fileset ); String[] excludedFiles = fileSetManager.getExcludedFiles( fileset ); String[] excludedDir = fileSetManager.getExcludedDirectories( fileset ); fileSetManager.delete( fileset ); +-----+ * Configure your Maven Plugin The last step is the Maven Plugin configuration. +-----+ ... your-plugin-groupId your-plugin-artifactId your-plugin-version some/relative/path **/*.txt **/log.log false some/relative/path **/*.txt **/log.log false ... ... ... +-----+ maven-file-management-1.2.1/src/site/apt/index.apt0000644000175000017500000000273311020006575021743 0ustar twernertwerner ------ Introduction ------ Vincent Siveton ------ November 2007 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you 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. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Maven File Management API The Maven File Management API provides an API to collect files from a given directory using several include/exclude rules. * Brief History This original code is based on the <<>> package from the {{{http://ant.apache.org/}Ant}} build tool. * Examples To provide you with better understanding on some usages of this API, you can take a look into the following examples: * {{{examples/mojo.html}Using the API in a Maven Plugin}} [] maven-file-management-1.2.1/src/test/0000755000175000017500000000000011226716141017355 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/0000755000175000017500000000000011226716141021367 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testIncludesDontFollowSymlinks/0000755000175000017500000000000011226716141027577 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testIncludesDontFollowSymlinks/excluded.txt0000644000175000017500000000003011020006575032121 0ustar twernertwernerthis should be excluded.maven-file-management-1.2.1/src/test/resources/testIncludesDontFollowSymlinks/included.txt0000644000175000017500000000003011020006575032113 0ustar twernertwernerthis should be included.maven-file-management-1.2.1/src/test/resources/testDelete/0000755000175000017500000000000011226716141023471 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDelete/excluded.txt0000644000175000017500000000003011020006575026013 0ustar twernertwernerthis should be excluded.maven-file-management-1.2.1/src/test/resources/testDelete/included.txt0000644000175000017500000000003011020006575026005 0ustar twernertwernerthis should be included.maven-file-management-1.2.1/src/test/resources/testDelete/subdir/0000755000175000017500000000000011226716141024761 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDelete/subdir/included.txt0000644000175000017500000000003011020006575027275 0ustar twernertwernerthis should be included.maven-file-management-1.2.1/src/test/resources/testGetIncludedFiles/0000755000175000017500000000000011226716141025441 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testGetIncludedFiles/stuff/0000755000175000017500000000000011226716141026570 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testGetIncludedFiles/stuff/excluded.txt0000644000175000017500000000003011020006575031112 0ustar twernertwernerthis should be excluded.maven-file-management-1.2.1/src/test/resources/testGetIncludedFiles/stuff/included.txt0000644000175000017500000000003011020006575031104 0ustar twernertwernerthis should be included.maven-file-management-1.2.1/src/test/resources/testGetIncludedFiles/otherStuff/0000755000175000017500000000000011226716141027572 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testGetIncludedFiles/otherStuff/excluded.txt0000644000175000017500000000003011020006575032114 0ustar twernertwernerthis should be excluded.maven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinks/0000755000175000017500000000000011226716141027233 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinks/included.txt0000644000175000017500000000003011020006575031547 0ustar twernertwernerthis should be included.maven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/0000755000175000017500000000000011226716141031647 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/excluded.txtmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/excluded.tx0000644000175000017500000000007511062235724034024 0ustar twernertwernerServes as the target for a symlink and should not be deleted.maven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/dir0/0000755000175000017500000000000011226716141032505 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/dir0/dummy.txtmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/dir0/dummy.0000644000175000017500000000006411062235724033642 0ustar twernertwernerThe Resources Plugin won't copy empty directories...maven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/dir1/0000755000175000017500000000000011226716141032506 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/dir1/dummy.txtmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/dir1/dummy.0000644000175000017500000000006411062235724033643 0ustar twernertwernerThe Resources Plugin won't copy empty directories...maven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/excluded/0000755000175000017500000000000011226716141033444 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/excluded/dummy.txtmaven-file-management-1.2.1/src/test/resources/testDeleteDontFollowSymlinksButDeleteThem/excluded/du0000644000175000017500000000006411062235724034000 0ustar twernertwernerThe Resources Plugin won't copy empty directories...maven-file-management-1.2.1/src/test/resources/testDeleteExcludeFollowSymlinks/0000755000175000017500000000000011226716141027720 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDeleteExcludeFollowSymlinks/excluded.txt0000644000175000017500000000002611062033344032247 0ustar twernertwernerShould not be deleted.maven-file-management-1.2.1/src/test/resources/testDeleteExcludeFollowSymlinks/excluded/0000755000175000017500000000000011226716141031515 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDeleteExcludeFollowSymlinks/excluded/dummy.txt0000644000175000017500000000006411062033344033404 0ustar twernertwernerThe Resources Plugin won't copy empty directories...maven-file-management-1.2.1/src/test/resources/testDeleteExcludeFollowSymlinks/included.txt0000644000175000017500000000002211062033344032235 0ustar twernertwernerShould be deleted.maven-file-management-1.2.1/src/test/resources/testDeleteExcludeDontFollowSymlinks/0000755000175000017500000000000011226716141030545 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDeleteExcludeDontFollowSymlinks/excluded.txt0000644000175000017500000000002611062033344033074 0ustar twernertwernerShould not be deleted.maven-file-management-1.2.1/src/test/resources/testDeleteExcludeDontFollowSymlinks/excluded/0000755000175000017500000000000011226716141032342 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven-file-management-1.2.1/src/test/resources/testDeleteExcludeDontFollowSymlinks/excluded/dummy.txtmaven-file-management-1.2.1/src/test/resources/testDeleteExcludeDontFollowSymlinks/excluded/dummy.tx0000644000175000017500000000006411062033344034045 0ustar twernertwernerThe Resources Plugin won't copy empty directories...maven-file-management-1.2.1/src/test/resources/testDeleteExcludeDontFollowSymlinks/included.txt0000644000175000017500000000002211062033344033062 0ustar twernertwernerShould be deleted.maven-file-management-1.2.1/src/test/resources/testDeleteExcludeParentOfExcludedFile/0000755000175000017500000000000011226716141030720 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDeleteExcludeParentOfExcludedFile/excluded.txt0000644000175000017500000000001511060771325033253 0ustar twernertwernerExcluded Filemaven-file-management-1.2.1/src/test/resources/testDeleteExcludeParentOfExcludedDir/0000755000175000017500000000000011226716141030557 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDeleteExcludeParentOfExcludedDir/excluded/0000755000175000017500000000000011226716141032354 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven-file-management-1.2.1/src/test/resources/testDeleteExcludeParentOfExcludedDir/excluded/dummy.txtmaven-file-management-1.2.1/src/test/resources/testDeleteExcludeParentOfExcludedDir/excluded/dummy.t0000644000175000017500000000016411060771325033676 0ustar twernertwernerEmpty directories are apparently excluded by the Resources Plugin, so we use this little dummy file as a workaround.maven-file-management-1.2.1/src/test/resources/testDeleteDanglingSymlink/0000755000175000017500000000000011226716141026504 5ustar twernertwernermaven-file-management-1.2.1/src/test/resources/testDeleteDanglingSymlink/test.txt0000644000175000017500000000000011057565504030221 0ustar twernertwernermaven-file-management-1.2.1/src/test/java/0000755000175000017500000000000011226716141020276 5ustar twernertwernermaven-file-management-1.2.1/src/test/java/org/0000755000175000017500000000000011226716141021065 5ustar twernertwernermaven-file-management-1.2.1/src/test/java/org/apache/0000755000175000017500000000000011226716141022306 5ustar twernertwernermaven-file-management-1.2.1/src/test/java/org/apache/maven/0000755000175000017500000000000011226716141023414 5ustar twernertwernermaven-file-management-1.2.1/src/test/java/org/apache/maven/shared/0000755000175000017500000000000011226716141024662 5ustar twernertwernermaven-file-management-1.2.1/src/test/java/org/apache/maven/shared/model/0000755000175000017500000000000011226716141025762 5ustar twernertwernermaven-file-management-1.2.1/src/test/java/org/apache/maven/shared/model/fileset/0000755000175000017500000000000011226716141027415 5ustar twernertwernermaven-file-management-1.2.1/src/test/java/org/apache/maven/shared/model/fileset/util/0000755000175000017500000000000011226716141030372 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven-file-management-1.2.1/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.javamaven-file-management-1.2.1/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTes0000644000175000017500000003000411062237677033354 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.util; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.io.File; import java.io.IOException; import java.net.URL; import java.net.URLDecoder; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import junit.framework.Assert; import junit.framework.TestCase; import org.apache.maven.shared.model.fileset.FileSet; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.Commandline; /** * Test the FileSet * * @version $Id: FileSetUtilsTest.java 694321 2008-09-11 15:56:47Z bentmann $ */ public class FileSetUtilsTest extends TestCase { private Set testDirectories = new HashSet(); private Set linkFiles = new HashSet(); /** {@inheritDoc} */ public void tearDown() throws IOException { for ( Iterator it = linkFiles.iterator(); it.hasNext(); ) { File linkFile = (File) it.next(); linkFile.delete(); } for ( Iterator it = testDirectories.iterator(); it.hasNext(); ) { File dir = (File) it.next(); FileUtils.deleteDirectory( dir ); } } /** * @throws IOException if any */ public void testGetIncludedFiles() throws IOException { File directory = setupTestDirectory( "testGetIncludedFiles" ); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addInclude( "**/included.txt" ); FileSetManager fileSetManager = new FileSetManager(); String[] included = fileSetManager.getIncludedFiles( set ); Assert.assertEquals( 1, included.length ); } /** * @throws IOException if any * @throws InterruptedException if any * @throws CommandLineException if any */ public void testIncludesDontFollowSymlinks() throws IOException, InterruptedException, CommandLineException { File directory = setupTestDirectory( "testIncludesDontFollowSymlinks" ); File subdir = new File( directory, directory.getName() ); if ( !createSymlink( directory, subdir ) ) { // assume failure to create a sym link is because the system does not support them // and not because the sym link creation failed. return; } FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addInclude( "**/included.txt" ); set.setFollowSymlinks( false ); FileSetManager fileSetManager = new FileSetManager(); String[] included = fileSetManager.getIncludedFiles( set ); Assert.assertEquals( 1, included.length ); } /** * @throws IOException if any * @throws InterruptedException if any * @throws CommandLineException if any */ public void testDeleteDontFollowSymlinks() throws IOException, InterruptedException, CommandLineException { File directory = setupTestDirectory( "testDeleteDontFollowSymlinks" ); File subdir = new File( directory, directory.getName() ); if ( !createSymlink( directory, subdir ) ) { // assume failure to create a sym link is because the system does not support them // and not because the sym link creation failed. return; } FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addInclude( "**/included.txt" ); set.addInclude( "**/" + subdir.getName() ); set.setFollowSymlinks( false ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertFalse( subdir.exists() ); } /** * @throws IOException if any */ public void testDelete() throws IOException { File directory = setupTestDirectory( "testDelete" ); File subdirFile = new File( directory, "subdir/excluded.txt" ); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addInclude( "**/included.txt" ); set.addInclude( "**/subdir" ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertFalse( "file in marked subdirectory still exists.", subdirFile.exists() ); } /** * @throws Exception if any */ public void testDeleteDanglingSymlink() throws Exception { File directory = setupTestDirectory( "testDeleteDanglingSymlink" ); File targetFile = new File( directory, "test.txt" ); File linkFile = new File( directory, "symlink" ); if ( !createSymlink( targetFile, linkFile ) ) { // symlinks apparently not supported, skip test return; } targetFile.delete(); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addInclude( "**" ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertFalse( "directory still exists", directory.exists() ); } /** * @throws Exception if any */ public void testDeleteExcludeParentOfExcludedFile() throws Exception { File directory = setupTestDirectory( "testDeleteExcludeParentOfExcludedFile" ); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addExclude( "*excluded*" ); set.setFollowSymlinks( true ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertTrue( "excluded file has been deleted", new File( directory, "excluded.txt" ).exists() ); } /** * @throws Exception if any */ public void testDeleteExcludeParentOfExcludedDir() throws Exception { File directory = setupTestDirectory( "testDeleteExcludeParentOfExcludedDir" ); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addExclude( "*excluded*" ); set.setFollowSymlinks( true ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertTrue( "excluded directory has been deleted", new File( directory, "excluded" ).exists() ); } /** * @throws Exception if any */ public void testDeleteExcludeFollowSymlinks() throws Exception { File directory = setupTestDirectory( "testDeleteExcludeFollowSymlinks" ); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addExclude( "*excluded*" ); set.setFollowSymlinks( true ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertTrue( "excluded file has been deleted", new File( directory, "excluded.txt" ).exists() ); Assert.assertTrue( "excluded directory has been deleted", new File( directory, "excluded" ).exists() ); Assert.assertFalse( "included file has not been deleted", new File( directory, "included.txt" ).exists() ); } /** * @throws Exception if any */ public void testDeleteExcludeDontFollowSymlinks() throws Exception { File directory = setupTestDirectory( "testDeleteExcludeDontFollowSymlinks" ); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addExclude( "*excluded*" ); set.setFollowSymlinks( false ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertTrue( "excluded file has been deleted", new File( directory, "excluded.txt" ).exists() ); Assert.assertTrue( "excluded directory has been deleted", new File( directory, "excluded" ).exists() ); Assert.assertFalse( "included file has not been deleted", new File( directory, "included.txt" ).exists() ); } /** * @throws Exception if any */ public void testDeleteDontFollowSymlinksButDeleteThem() throws Exception { File directory = setupTestDirectory( "testDeleteDontFollowSymlinksButDeleteThem" ); createSymlink( new File( directory, "excluded" ), new File( directory, "dirlink" ) ); createSymlink( new File( directory, "excluded.txt" ), new File( directory, "filelink" ) ); createSymlink( new File( directory, "excluded" ), new File( directory, "dir0/dirlink" ) ); createSymlink( new File( directory, "excluded.txt" ), new File( directory, "dir1/filelink" ) ); FileSet set = new FileSet(); set.setDirectory( directory.getPath() ); set.addExclude( "*excluded*" ); set.setFollowSymlinks( false ); FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( set ); Assert.assertTrue( "excluded file has been deleted", new File( directory, "excluded.txt" ).exists() ); Assert.assertTrue( "excluded directory has been deleted", new File( directory, "excluded" ).exists() ); Assert.assertFalse( "included dirlink has not been deleted", new File( directory, "dirlink" ).exists() ); Assert.assertFalse( "included filelink has not been deleted", new File( directory, "filelink" ).exists() ); Assert.assertFalse( "included directory has not been deleted", new File( directory, "dir0" ).exists() ); Assert.assertFalse( "included directory has not been deleted", new File( directory, "dir1" ).exists() ); } /** * @param target The target file/directory of the symlink, must not be null. * @param link The link to create, must not be null. * @return * @throws InterruptedException * @throws CommandLineException */ private boolean createSymlink( File target, File link ) throws InterruptedException, CommandLineException { if ( link.exists() ) { link.delete(); } Commandline cli = new Commandline(); cli.setExecutable( "ln" ); cli.createArg().setValue( "-s" ); cli.createArg().setValue( target.getPath() ); cli.createArg().setValue( link.getPath() ); int result = cli.execute().waitFor(); linkFiles.add( link ); return result == 0; } /** * @param directoryName * @return * @throws IOException */ private File setupTestDirectory( String directoryName ) throws IOException { System.out.println( "Setting up directory for test: " + directoryName ); URL sourceResource = getClass().getClassLoader().getResource( directoryName ); if ( sourceResource == null ) { Assert.fail( "Source directory for test: " + directoryName + " cannot be found." ); } File sourceDir = new File( URLDecoder.decode( sourceResource.getPath(), "UTF-8" ) ); String basedir = System.getProperty( "basedir", System.getProperty( "user.dir" ) ); String testBase = System.getProperty( "testBase", "target/test-directories" ); File testDir = new File( basedir, testBase + "/" + directoryName ); testDir.mkdirs(); FileUtils.copyDirectoryStructure( sourceDir, testDir ); testDirectories.add( testDir ); return testDir; } } maven-file-management-1.2.1/src/main/0000755000175000017500000000000011226716142017323 5ustar twernertwernermaven-file-management-1.2.1/src/main/mdo/0000755000175000017500000000000011226716141020101 5ustar twernertwernermaven-file-management-1.2.1/src/main/mdo/fileset.mdo0000644000175000017500000002550211020006575022234 0ustar twernertwerner fileset FileSet A definition of a file-set. This model defines how file-sets can be captured, using directory, includes, and excludes.

]]>
package org.apache.maven.shared.model.fileset SetBase 1.1.0 followSymlinks 1.0.0+ boolean false Specifies whether symbolic links should be traversed, or handled as-is. outputDirectory 1.0.0+ String Specifies the output directory relative to the root of the root directory of the assembly. For example, "log" will put the specified files in the log directory. useDefaultExcludes 1.1.0 boolean true Whether to include exclusion patterns for common temporary and SCM control files (true by default). includes 1.0.0+ String * excludes 1.0.0+ String * fileMode 1.0.0+ String 0644 (more on unix-style permissions) ]]> directoryMode 1.0.0+ String 0755 (more on unix-style permissions) ]]> mapper 1.1.0 Mapper new Mapper() Specifies the mapper used. 1.0.0+ Mapper 1.1.0 type 1.1.0 String identity Valid values:
  • "flatten" - The target file name is identical to the source file name, with all leading directory information stripped off. Both to and from will be ignored.
  • "glob" - Both to and from define patterns that may contain at most one *. For each source file that matches the from pattern, a target file name will be constructed from the to pattern by substituting the * in the to pattern with the text that matches the * in the from pattern. Source file names that don't match the from pattern will be ignored.
  • "regexp" - Both to and from define regular expressions. If the source file name matches the from pattern, the target file name will be constructed from the to pattern, using \0 to \9 as back-references for the full match (\0) or the matches of the subexpressions in parentheses. Source files not matching the from pattern will be ignored.
  • "merge" - The target file name will always be the same, as defined by to. from will be ignored.
  • "package" - Sharing the same syntax as the glob mapper, the package mapper replaces directory separators found in the matched source pattern with dots in the target pattern placeholder.
  • "unpackage" - This mapper is the inverse of the package mapper. It replaces the dots in a package name with directory separators. This is useful for matching XML formatter results against their JUnit test test cases. The mapper shares the sample syntax as the glob mapper.
]]>
from 1.1.0 String Specifies a type-specific pattern for matching source paths which should be mapped. to 1.1.0 String Specifies a type-specific pattern for producing paths based on source paths. classname 1.1.0 String Allows specification of a custom mapper implementation. The class must be of type org.apache.maven.shared.model.fileset.mappers.FileNameMapper, from the artifact org.apache.maven.shared:file-management.
FileSet 1.1.0 SetBase Defines the rules for matching and working with files in a given base directory. directory 1.0.0+ String Absolute or relative from the module's directory. For example, "src/main/bin" would select this subdirectory of the project in which this dependency is defined. true lineEnding 1.0.0+ String Valid values:
  • "keep" - Preserve all line endings
  • "unix" - Use Unix-style line endings
  • "lf" - Use a single line-feed line endings
  • "dos" - Use DOS-style line endings
  • "crlf" - Use Carraige-return, line-feed line endings
]]>
maven-file-management-1.2.1/src/main/resources/0000755000175000017500000000000011226716142021335 5ustar twernertwernermaven-file-management-1.2.1/src/main/resources/mappers.properties0000644000175000017500000000234011020006575025113 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. identity=org.apache.maven.plugin.assembly.mappers.IdentityMapper flatten=org.apache.maven.plugin.assembly.mappers.FlatFileNameMapper glob=org.apache.maven.plugin.assembly.mappers.GlobPatternMapper merge=org.apache.maven.plugin.assembly.mappers.MergingMapper regexp=org.apache.maven.plugin.assembly.mappers.RegexpPatternMapper package=org.apache.maven.plugin.assembly.mappers.PackageNameMapper unpackage=org.apache.maven.plugin.assembly.mappers.UnPackageNameMapper maven-file-management-1.2.1/src/main/javadoc/0000755000175000017500000000000011226716142020732 5ustar twernertwernermaven-file-management-1.2.1/src/main/javadoc/org/0000755000175000017500000000000011226716142021521 5ustar twernertwernermaven-file-management-1.2.1/src/main/javadoc/org/apache/0000755000175000017500000000000011226716142022742 5ustar twernertwernermaven-file-management-1.2.1/src/main/javadoc/org/apache/maven/0000755000175000017500000000000011226716142024050 5ustar twernertwernermaven-file-management-1.2.1/src/main/javadoc/org/apache/maven/shared/0000755000175000017500000000000011226716142025316 5ustar twernertwernermaven-file-management-1.2.1/src/main/javadoc/org/apache/maven/shared/model/0000755000175000017500000000000011226716142026416 5ustar twernertwernermaven-file-management-1.2.1/src/main/javadoc/org/apache/maven/shared/model/fileset/0000755000175000017500000000000011226716142030051 5ustar twernertwernermaven-file-management-1.2.1/src/main/javadoc/org/apache/maven/shared/model/fileset/mappers/0000755000175000017500000000000011226716142031520 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven-file-management-1.2.1/src/main/javadoc/org/apache/maven/shared/model/fileset/mappers/package.htmlmaven-file-management-1.2.1/src/main/javadoc/org/apache/maven/shared/model/fileset/mappers/package.h0000644000175000017500000000213210717162623033265 0ustar twernertwerner org.apache.maven.shared.model.fileset.mappers package

This original code comes from org.apache.tools.ant.util package.

maven-file-management-1.2.1/src/main/java/0000755000175000017500000000000011226716141020243 5ustar twernertwernermaven-file-management-1.2.1/src/main/java/org/0000755000175000017500000000000011226716141021032 5ustar twernertwernermaven-file-management-1.2.1/src/main/java/org/apache/0000755000175000017500000000000011226716141022253 5ustar twernertwernermaven-file-management-1.2.1/src/main/java/org/apache/maven/0000755000175000017500000000000011226716141023361 5ustar twernertwernermaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/0000755000175000017500000000000011226716141024627 5ustar twernertwernermaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/0000755000175000017500000000000011226716141025727 5ustar twernertwernermaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/0000755000175000017500000000000011226716142027363 5ustar twernertwernermaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/0000755000175000017500000000000011226716142031032 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/IdentityMapper.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/IdentityMapp0000644000175000017500000000270311020006575033360 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** * Implementation of FileNameMapper that always returns the source file name. * *

This is the default FileNameMapper for the copy and move * tasks.

* * @version $Id: IdentityMapper.java 661727 2008-05-30 14:21:49Z bentmann $ */ public class IdentityMapper implements FileNameMapper { /** {@inheritDoc} */ public void setFrom( String from ) { // nop } /** {@inheritDoc} */ public void setTo( String to ) { // nop } /** {@inheritDoc} */ public String mapFileName( String sourceFileName ) { return sourceFileName; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/UnPackageNameMapper.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/UnPackageNam0000644000175000017500000000313611020006575033244 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.io.File; /** * Maps dotted package name matches to a directory name. * This is the inverse of the package mapper. * This is useful for matching XML formatter results against their JUnit test * cases. *
 * <mapper classname="org.apache.tools.ant.util.UnPackageNameMapper"
 *         from="${test.data.dir}/TEST-*Test.xml" to="*Test.java">
 * 
* * @version $Id: UnPackageNameMapper.java 661727 2008-05-30 14:21:49Z bentmann $ */ public class UnPackageNameMapper extends GlobPatternMapper { /** {@inheritDoc} */ protected String extractVariablePart( String name ) { String var = name.substring( prefixLength, name.length() - postfixLength ); return var.replace( '.', File.separatorChar ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.j0000644000175000017500000000773611020006575033276 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.shared.model.fileset.Mapper; import org.codehaus.plexus.util.IOUtil; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * Element to define a FileNameMapper. * * @version $Id: MapperUtil.java 661727 2008-05-30 14:21:49Z bentmann $ */ public final class MapperUtil { private static final String MAPPER_PROPERTIES = "mapper.properties"; private static Properties implementations; private MapperUtil() { // nop } /** * Initializes a properties object to store the built-in classnames. */ private static void initializeBuiltIns() { if ( implementations == null ) { Properties props = new Properties(); ClassLoader cloader = Thread.currentThread().getContextClassLoader(); InputStream stream = null; try { stream = cloader.getResourceAsStream( MAPPER_PROPERTIES ); if ( stream == null ) { throw new IllegalStateException( "Cannot find classpath resource: " + MAPPER_PROPERTIES ); } try { props.load( stream ); } catch ( IOException e ) { throw new IllegalStateException( "Cannot find classpath resource: " + MAPPER_PROPERTIES ); } } finally { IOUtil.close( stream ); } } } /** * Returns a fully configured FileNameMapper implementation. * * @param mapper * @return * @throws MapperException */ public static FileNameMapper getFileNameMapper( Mapper mapper ) throws MapperException { if ( mapper == null ) { return null; } initializeBuiltIns(); String type = mapper.getType(); String classname = mapper.getClassname(); if ( type == null && classname == null ) { throw new MapperException( "nested mapper or " + "one of the attributes type or classname is required" ); } if ( type != null && classname != null ) { throw new MapperException( "must not specify both type and classname attribute" ); } if ( type != null ) { classname = implementations.getProperty( type ); } try { FileNameMapper m = (FileNameMapper) Class.forName( classname ).newInstance(); m.setFrom( mapper.getFrom() ); m.setTo( mapper.getTo() ); return m; } catch ( ClassNotFoundException e ) { throw new MapperException( "Cannot find mapper implementation: " + classname, e ); } catch ( InstantiationException e ) { throw new MapperException( "Cannot load mapper implementation: " + classname, e ); } catch ( IllegalAccessException e ) { throw new MapperException( "Cannot load mapper implementation: " + classname, e ); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/FlatFileNameMapper.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/FlatFileName0000644000175000017500000000311211020006575033233 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** * Implementation of FileNameMapper that always returns the source * file name without any leading directory information. * *

This is the default FileNameMapper for the copy and move * tasks if the flatten attribute has been set.

* * @version $Id: FlatFileNameMapper.java 661727 2008-05-30 14:21:49Z bentmann $ */ public class FlatFileNameMapper implements FileNameMapper { /** {@inheritDoc} */ public void setFrom( String from ) { // nop } /** {@inheritDoc} */ public void setTo( String to ) { // nop } /** {@inheritDoc} */ public String mapFileName( String sourceFileName ) { return new String( new java.io.File( sourceFileName ).getName() ); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/GlobPatternMapper.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/GlobPatternM0000644000175000017500000001131111020006575033302 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** * Implementation of FileNameMapper that does simple wildcard pattern * replacements. * *

This does simple translations like *.foo -> *.bar where the * prefix to .foo will be left unchanged. It only handles a single * * character, use regular expressions for more complicated * situations.

* *

This is one of the more useful Mappers, it is used by javac for * example.

* * @version $Id: GlobPatternMapper.java 661727 2008-05-30 14:21:49Z bentmann $ */ public class GlobPatternMapper implements FileNameMapper { /** * Part of "from" pattern before the *. */ protected String fromPrefix = null; /** * Part of "from" pattern after the *. */ protected String fromPostfix = null; /** * Length of the prefix ("from" pattern). */ protected int prefixLength; /** * Length of the postfix ("from" pattern). */ protected int postfixLength; /** * Part of "to" pattern before the *. */ protected String toPrefix = null; /** * Part of "to" pattern after the *. */ protected String toPostfix = null; private boolean handleDirSep = false; private boolean caseSensitive = true; /** * Attribute specifing whether to ignore the difference * between / and \ (the two common directory characters). * @param handleDirSep a boolean, default is false. */ public void setHandleDirSep( boolean handleDirSep ) { this.handleDirSep = handleDirSep; } /** * Attribute specifing whether to ignore the case difference * in the names. * * @param caseSensitive a boolean, default is false. */ public void setCaseSensitive( boolean caseSensitive ) { this.caseSensitive = caseSensitive; } /** {@inheritDoc} */ public void setFrom( String from ) { int index = from.lastIndexOf( "*" ); if ( index == -1 ) { fromPrefix = from; fromPostfix = ""; } else { fromPrefix = from.substring( 0, index ); fromPostfix = from.substring( index + 1 ); } prefixLength = fromPrefix.length(); postfixLength = fromPostfix.length(); } /** {@inheritDoc} */ public void setTo( String to ) { int index = to.lastIndexOf( "*" ); if ( index == -1 ) { toPrefix = to; toPostfix = ""; } else { toPrefix = to.substring( 0, index ); toPostfix = to.substring( index + 1 ); } } /** {@inheritDoc} */ public String mapFileName( String sourceFileName ) { if ( fromPrefix == null || !modifyName( sourceFileName ).startsWith( modifyName( fromPrefix ) ) || !modifyName( sourceFileName ).endsWith( modifyName( fromPostfix ) ) ) { return null; } return new String( toPrefix + extractVariablePart( sourceFileName ) + toPostfix ); } /** * Returns the part of the given string that matches the * in the * "from" pattern. * @param name the source file name * @return the variable part of the name */ protected String extractVariablePart( String name ) { return name.substring( prefixLength, name.length() - postfixLength ); } /** * modify string based on dir char mapping and case sensitivity * @param name the name to convert * @return the converted name */ private String modifyName( String name ) { if ( !caseSensitive ) { name = name.toLowerCase(); } if ( handleDirSep ) { if ( name.indexOf( '\\' ) != -1 ) { name = name.replace( '\\', '/' ); } } return name; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/PackageNameMapper.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/PackageNameM0000644000175000017500000000305411020006575033222 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.io.File; /** * Maps directory name matches into a dotted package name. This is * useful for matching JUnit test cases againt their XML formatter * results. *
 * <mapper classname="org.apache.tools.ant.util.PackageNameMapper"
 *         from="*Test.java" to="${test.data.dir}/TEST-*Test.xml"/>
 * 
* * @version $Id: PackageNameMapper.java 661727 2008-05-30 14:21:49Z bentmann $ */ public class PackageNameMapper extends GlobPatternMapper { /** {@inheritDoc} */ protected String extractVariablePart( String name ) { String var = name.substring( prefixLength, name.length() - postfixLength ); return var.replace( File.separatorChar, '.' ); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/MergingMapper.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/MergingMappe0000644000175000017500000000300111020006575033314 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** * Implementation of FileNameMapper that always returns the same * target file name. * *

This is the default FileNameMapper for the archiving tasks and * uptodate.

* * @version $Id: MergingMapper.java 661727 2008-05-30 14:21:49Z bentmann $ */ public class MergingMapper implements FileNameMapper { protected String mergedFile = null; /** {@inheritDoc} */ public void setFrom( String from ) { // nop } /** {@inheritDoc} */ public void setTo( String to ) { mergedFile = to; } /** {@inheritDoc} */ public String mapFileName( String sourceFileName ) { return mergedFile; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperException.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperExcept0000644000175000017500000000262511020006575033351 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** * Mapper Exception * * @version $Id: MapperException.java 661727 2008-05-30 14:21:49Z bentmann $ */ public class MapperException extends Exception { static final long serialVersionUID = 20064059145045044L; /** * Constructor * * @param message * @param cause */ public MapperException( String message, Throwable cause ) { super( message, cause ); } /** * Constructor * * @param message */ public MapperException( String message ) { super( message ); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/FileNameMapper.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/mappers/FileNameMapp0000644000175000017500000000375611020006575033260 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.mappers; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** * Interface to be used by SourceFileScanner. * *

Used to find the name of the target file(s) corresponding to a * source file.

* *

The rule by which the file names are transformed is specified * via the setFrom and setTo methods. The exact meaning of these is * implementation dependent.

* * @version $Id: FileNameMapper.java 661727 2008-05-30 14:21:49Z bentmann $ */ public interface FileNameMapper { /** * Sets the from part of the transformation rule. * * @param from */ void setFrom( String from ); /** * Sets the to part of the transformation rule. * * @param to */ void setTo( String to ); /** * Returns the target filename for the * given source file. * *

if the given rule doesn't apply to the source file, * implementation must return null. SourceFileScanner will then * omit the source file in question.

* * @param sourceFileName the name of the source file relative to some given basedirectory. * @return the target filename for the given source file. */ String mapFileName( String sourceFileName ); } maven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/util/0000755000175000017500000000000011226716142030340 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.javamaven-file-management-1.2.1/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.0000644000175000017500000005523311062236507033177 0ustar twernertwernerpackage org.apache.maven.shared.model.fileset.util; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.plugin.logging.Log; import org.apache.maven.shared.io.logging.DefaultMessageHolder; import org.apache.maven.shared.io.logging.MessageHolder; import org.apache.maven.shared.io.logging.MessageLevels; import org.apache.maven.shared.io.logging.MojoLogSink; import org.apache.maven.shared.io.logging.PlexusLoggerSink; import org.apache.maven.shared.model.fileset.FileSet; import org.apache.maven.shared.model.fileset.mappers.FileNameMapper; import org.apache.maven.shared.model.fileset.mappers.MapperException; import org.apache.maven.shared.model.fileset.mappers.MapperUtil; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; /** * Provides operations for use with FileSet instances, such as retrieving the included/excluded files, deleting all * matching entries, etc. * * @author jdcasey * @version $Id: FileSetManager.java 694312 2008-09-11 15:46:15Z bentmann $ */ public class FileSetManager { private static final String[] EMPTY_STRING_ARRAY = new String[0]; private final boolean verbose; private MessageHolder messages; // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- /** * Create a new manager instance with the supplied log instance and flag for whether to output verbose messages. * * @param log The mojo log instance * @param verbose Whether to output verbose messages */ public FileSetManager( Log log, boolean verbose ) { if ( verbose ) { this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) ); } else { this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) ); } this.verbose = verbose; } /** * Create a new manager instance with the supplied log instance. Verbose flag is set to false. * * @param log The mojo log instance */ public FileSetManager( Log log ) { this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) ); this.verbose = false; } /** * Create a new manager instance with the supplied log instance and flag for whether to output verbose messages. * * @param log The mojo log instance * @param verbose Whether to output verbose messages */ public FileSetManager( Logger log, boolean verbose ) { if ( verbose ) { this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO, new PlexusLoggerSink( log ) ); } else { this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new PlexusLoggerSink( log ) ); } this.verbose = verbose; } /** * Create a new manager instance with the supplied log instance. Verbose flag is set to false. * * @param log The mojo log instance */ public FileSetManager( Logger log ) { this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new PlexusLoggerSink( log ) ); this.verbose = false; } /** * Create a new manager instance with an empty messages. Verbose flag is set to false. */ public FileSetManager() { this.verbose = false; } // ---------------------------------------------------------------------- // Public methods // ---------------------------------------------------------------------- /** * * @param fileSet * @return the included files as map * @throws MapperException if any * @see #getIncludedFiles(FileSet) */ public Map mapIncludedFiles( FileSet fileSet ) throws MapperException { String[] sourcePaths = getIncludedFiles( fileSet ); Map mappedPaths = new LinkedHashMap(); FileNameMapper fileMapper = MapperUtil.getFileNameMapper( fileSet.getMapper() ); for ( int i = 0; i < sourcePaths.length; i++ ) { String sourcePath = sourcePaths[i]; String destPath; if ( fileMapper != null ) { destPath = fileMapper.mapFileName( sourcePath ); } else { destPath = sourcePath; } mappedPaths.put( sourcePath, destPath ); } return mappedPaths; } /** * Get all the filenames which have been included by the rules in this fileset. * * @param fileSet * The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of matching filenames, relative to the basedir of the file-set. */ public String[] getIncludedFiles( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getIncludedFiles(); } return EMPTY_STRING_ARRAY; } /** * Get all the directory names which have been included by the rules in this fileset. * * @param fileSet * The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of matching dirnames, relative to the basedir of the file-set. */ public String[] getIncludedDirectories( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getIncludedDirectories(); } return EMPTY_STRING_ARRAY; } /** * Get all the filenames which have been excluded by the rules in this fileset. * * @param fileSet * The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of non-matching filenames, relative to the basedir of the file-set. */ public String[] getExcludedFiles( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getExcludedFiles(); } return EMPTY_STRING_ARRAY; } /** * Get all the directory names which have been excluded by the rules in this fileset. * * @param fileSet * The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of non-matching dirnames, relative to the basedir of the file-set. */ public String[] getExcludedDirectories( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getExcludedDirectories(); } return EMPTY_STRING_ARRAY; } /** * Delete the matching files and directories for the given file-set definition. * * @param fileSet The file-set matching rules, along with search base directory * @throws IOException If a matching file cannot be deleted */ public void delete( FileSet fileSet ) throws IOException { delete( fileSet, true ); } /** * Delete the matching files and directories for the given file-set definition. * * @param fileSet The file-set matching rules, along with search base directory. * @param throwsError Throw IOException when errors have occurred by deleting files or directories. * @throws IOException If a matching file cannot be deleted and throwsError=true, otherwise * print warning messages. */ public void delete( FileSet fileSet, boolean throwsError ) throws IOException { Set deletablePaths = findDeletablePaths( fileSet ); if ( messages != null && messages.isDebugEnabled() ) { messages .addDebugMessage( "Found deletable paths: " + String.valueOf( deletablePaths ).replace( ',', '\n' ) ).flush(); } List warnMessages = new LinkedList(); for ( Iterator it = deletablePaths.iterator(); it.hasNext(); ) { String path = (String) it.next(); File file = new File( fileSet.getDirectory(), path ); if ( file.exists() ) { if ( file.isDirectory() ) { if ( fileSet.isFollowSymlinks() || !isSymlink( file ) ) { if ( verbose && messages != null ) { messages.addInfoMessage( "Deleting directory: " + file ).flush(); } removeDir( file, fileSet.isFollowSymlinks(), throwsError, warnMessages ); } else { // delete a symlink to a directory without follow if ( verbose && messages != null ) { messages.addInfoMessage( "Deleting symlink to directory: " + file ).flush(); } if ( !file.delete() ) { String message = "Unable to delete symlink " + file.getAbsolutePath(); if ( throwsError ) { throw new IOException( message ); } if ( !warnMessages.contains( message ) ) { warnMessages.add( message ); } } } } else { if ( verbose && messages != null ) { messages.addInfoMessage( "Deleting file: " + file ).flush(); } if ( !delete( file ) ) { String message = "Failed to delete file " + file.getAbsolutePath() + ". Reason is unknown."; if ( throwsError ) { throw new IOException( message ); } warnMessages.add( message ); } } } } if ( messages != null && messages.isWarningEnabled() && !throwsError && ( warnMessages.size() > 0 ) ) { for ( Iterator it = warnMessages.iterator(); it.hasNext(); ) { String msg = (String) it.next(); messages.addWarningMessage( msg ).flush(); } } } // ---------------------------------------------------------------------- // Private methods // ---------------------------------------------------------------------- private boolean isSymlink( File file ) throws IOException { File fileInCanonicalParent = null; File parentDir = file.getParentFile(); if ( parentDir == null ) { fileInCanonicalParent = file; } else { fileInCanonicalParent = new File( parentDir.getCanonicalPath(), file.getName() ); } if ( messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Checking for symlink:\nFile's canonical path: " + fileInCanonicalParent.getCanonicalPath() + "\nFile's absolute path with canonical parent: " + fileInCanonicalParent.getPath() ).flush(); } return !fileInCanonicalParent.getCanonicalFile().equals( fileInCanonicalParent.getAbsoluteFile() ); } private Set findDeletablePaths( FileSet fileSet ) { Set includes = findDeletableDirectories( fileSet ); includes.addAll( findDeletableFiles( fileSet, includes ) ); return includes; } private Set findDeletableDirectories( FileSet fileSet ) { if ( verbose && messages != null ) { messages.addInfoMessage( "Scanning for deletable directories." ).flush(); } DirectoryScanner scanner = scan( fileSet ); if ( scanner == null ) { return Collections.EMPTY_SET; } Set includes = new HashSet( Arrays.asList( scanner.getIncludedDirectories() ) ); Collection excludes = new ArrayList( Arrays.asList( scanner.getExcludedDirectories() ) ); Collection linksForDeletion = new ArrayList(); if ( !fileSet.isFollowSymlinks() ) { if ( verbose && messages != null ) { messages .addInfoMessage( "Adding symbolic link dirs which were previously excluded to the list being deleted." ).flush(); } // we need to see which entries were only excluded because they're symlinks... scanner.setFollowSymlinks( true ); scanner.scan(); if ( messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Originally marked for delete: " + includes ).flush(); messages.addDebugMessage( "Marked for preserve (with followSymlinks == false): " + excludes ).flush(); } List includedDirsAndSymlinks = Arrays.asList( scanner.getIncludedDirectories() ); linksForDeletion.addAll( excludes ); linksForDeletion.retainAll( includedDirsAndSymlinks ); if ( messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Symlinks marked for deletion (originally mismarked): " + linksForDeletion ).flush(); } excludes.removeAll( includedDirsAndSymlinks ); } excludeParentDirectoriesOfExcludedPaths( excludes, includes ); includes.addAll( linksForDeletion ); return includes; } private Set findDeletableFiles( FileSet fileSet, Set deletableDirectories ) { if ( verbose && messages != null ) { messages.addInfoMessage( "Re-scanning for deletable files." ).flush(); } DirectoryScanner scanner = scan( fileSet ); if ( scanner == null ) { return deletableDirectories; } Set includes = deletableDirectories; includes.addAll( Arrays.asList( scanner.getIncludedFiles() ) ); Collection excludes = new ArrayList( Arrays.asList( scanner.getExcludedFiles() ) ); Collection linksForDeletion = new ArrayList(); if ( !fileSet.isFollowSymlinks() ) { if ( verbose && messages != null ) { messages .addInfoMessage( "Adding symbolic link files which were previously excluded to the list being deleted." ).flush(); } // we need to see which entries were only excluded because they're symlinks... scanner.setFollowSymlinks( true ); scanner.scan(); if ( messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Originally marked for delete: " + includes ).flush(); messages.addDebugMessage( "Marked for preserve (with followSymlinks == false): " + excludes ).flush(); } List includedFilesAndSymlinks = Arrays.asList( scanner.getIncludedFiles() ); linksForDeletion.addAll( excludes ); linksForDeletion.retainAll( includedFilesAndSymlinks ); if ( messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Symlinks marked for deletion (originally mismarked): " + linksForDeletion ).flush(); } excludes.removeAll( includedFilesAndSymlinks ); } excludeParentDirectoriesOfExcludedPaths( excludes, includes ); includes.addAll( linksForDeletion ); return includes; } /** * Removes all parent directories of the already excluded files/directories from the given set of deletable * directories. I.e. if "subdir/excluded.txt" should not be deleted, "subdir" should be excluded from deletion, too. * * @param excludedPaths The relative paths of the files/directories which are excluded from deletion, must not be * null. * @param deletablePaths The relative paths to files/directories which are scheduled for deletion, must not be * null. */ private void excludeParentDirectoriesOfExcludedPaths( Collection excludedPaths, Set deletablePaths ) { for ( Iterator it = excludedPaths.iterator(); it.hasNext(); ) { String path = (String) it.next(); String parentPath = new File( path ).getParent(); while ( parentPath != null ) { if ( messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Verifying path " + parentPath + " is not present; contains file which is excluded." ).flush(); } boolean removed = deletablePaths.remove( parentPath ); if ( removed && messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Path " + parentPath + " was removed from delete list." ).flush(); } parentPath = new File( parentPath ).getParent(); } } if ( !excludedPaths.isEmpty() ) { if ( messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Verifying path " + "." + " is not present; contains file which is excluded." ).flush(); } boolean removed = deletablePaths.remove( "" ); if ( removed && messages != null && messages.isDebugEnabled() ) { messages.addDebugMessage( "Path " + "." + " was removed from delete list." ).flush(); } } } /** * Delete a directory * * @param dir the directory to delete * @param followSymlinks whether to follow symbolic links, or simply delete the link * @param throwsError Throw IOException when errors have occurred by deleting files or directories. * @param warnMessages A list of warning messages used when throwsError=false. * @throws IOException If a matching file cannot be deleted and throwsError=true. */ private void removeDir( File dir, boolean followSymlinks, boolean throwsError, List warnMessages ) throws IOException { String[] list = dir.list(); if ( list == null ) { list = new String[0]; } for ( int i = 0; i < list.length; i++ ) { String s = list[i]; File f = new File( dir, s ); if ( f.isDirectory() && ( followSymlinks || !isSymlink( f ) ) ) { removeDir( f, followSymlinks, throwsError, warnMessages ); } else { if ( !delete( f ) ) { String message = "Unable to delete file " + f.getAbsolutePath(); if ( throwsError ) { throw new IOException( message ); } if ( !warnMessages.contains( message ) ) { warnMessages.add( message ); } } } } if ( !delete( dir ) ) { String message = "Unable to delete directory " + dir.getAbsolutePath(); if ( throwsError ) { throw new IOException( message ); } if ( !warnMessages.contains( message ) ) { warnMessages.add( message ); } } } /** * Delete a file * * @param f a file */ private boolean delete( File f ) { try { FileUtils.forceDelete( f ); } catch ( IOException e ) { return false; } return true; } private DirectoryScanner scan( FileSet fileSet ) { File basedir = new File( fileSet.getDirectory() ); if ( !basedir.exists() || !basedir.isDirectory() ) { return null; } DirectoryScanner scanner = new DirectoryScanner(); String[] includesArray = fileSet.getIncludesArray(); String[] excludesArray = fileSet.getExcludesArray(); if ( includesArray.length > 0 ) { scanner.setIncludes( includesArray ); } if ( excludesArray.length > 0 ) { scanner.setExcludes( excludesArray ); } if ( fileSet.isUseDefaultExcludes() ) { scanner.addDefaultExcludes(); } scanner.setBasedir( basedir ); scanner.setFollowSymlinks( fileSet.isFollowSymlinks() ); scanner.scan(); return scanner; } } maven-file-management-1.2.1/pom.xml0000644000175000017500000000726211131007134017121 0ustar twernertwerner 4.0.0 org.apache.maven.shared maven-shared-components 10 file-management 1.2.1 Maven File Management API API to collect files from a given directory using several include/exclude rules. Joakim Erdfelt joakim@erdfelt.com 2.0.6 scm:svn:http://svn.apache.org/repos/asf/maven/shared/tags/file-management-1.2.1 scm:svn:https://svn.apache.org/repos/asf/maven/shared/tags/file-management-1.2.1 http://svn.apache.org/viewvc/maven/shared/tags/file-management-1.2.1 org.apache.maven maven-plugin-api 2.0.6 org.apache.maven.shared maven-shared-io 1.1 org.codehaus.plexus plexus-utils 1.5.6 org.codehaus.plexus plexus-container-default 1.0-alpha-9 junit junit 3.8.2 test org.codehaus.modello modello-maven-plugin 1.0-alpha-21 fileset xpp3-reader xpp3-writer java xsd src/main/mdo/fileset.mdo 1.1.0 maven-surefire-plugin 2.4.3