maven-clean-plugin-2.5/0000755000175000017500000000000012147674233014403 5ustar ebourgebourgmaven-clean-plugin-2.5/pom.xml0000644000175000017500000000751711757175044015734 0ustar ebourgebourg 4.0.0 org.apache.maven.plugins maven-plugins 22 ../maven-plugins/pom.xml maven-clean-plugin 2.5 maven-plugin Maven Clean Plugin The Maven Clean Plugin is a plugin that removes files generated at build-time in a project's directory. 2001 ${mavenVersion} scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-clean-plugin-2.5 scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-clean-plugin-2.5 http://svn.apache.org/viewvc/maven/plugins/tags/maven-clean-plugin-2.5 JIRA http://jira.codehaus.org/browse/MCLEAN 2.0.6 org.apache.maven maven-plugin-api ${mavenVersion} org.codehaus.plexus plexus-utils 3.0 org.apache.maven.shared maven-plugin-testing-harness 1.1 test run-its org.apache.maven.plugins maven-invoker-plugin true true src/it ${project.build.directory}/it */pom.xml setup verify ${project.build.directory}/local-repo src/it/settings.xml clean maven-clean-plugin-2.5/src/0000755000175000017500000000000012147674233015172 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/0000755000175000017500000000000012147674233015606 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/0000755000175000017500000000000012147674233021620 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/delete-me/0000755000175000017500000000000012147674233023461 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/pom.xml0000644000175000017500000000351411060556404023130 0ustar ebourgebourg 4.0.0 test exclude-default-dirs 1.0-SNAPSHOT Check for exclusion of default directories from cleaning if requested. UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ true delete-me maven-clean-plugin-2.5/src/it/exclude-default-dirs/verify.bsh0000644000175000017500000000210711060556404023612 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { String[] expected = { "target", "target/test-1.0-SNAPSHOT.jar", "target/classes", "target/classes/main.properties", "target/test-classes", "target/test-classes/test.properties", "target/site", "target/site/index.html", }; for ( String path : expected ) { File file = new File( basedir, path ); System.out.println( "Checking for existence of " + file ); if ( !file.exists() ) { System.out.println( "FAILURE!" ); return false; } } String[] unexpected = { "delete-me", }; for ( String path : unexpected ) { File file = new File( basedir, path ); System.out.println( "Checking for absence of " + file ); if ( file.exists() ) { System.out.println( "FAILURE!" ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/exclude-default-dirs/target/0000755000175000017500000000000012147674233023106 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/target/classes/0000755000175000017500000000000012147674233024543 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/target/classes/main.properties0000644000175000017500000000000011060556404027563 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/target/test-classes/0000755000175000017500000000000012147674233025520 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/target/test-classes/test.properties0000644000175000017500000000000011060556404030573 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/target/site/0000755000175000017500000000000012147674233024052 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/exclude-default-dirs/target/site/index.html0000644000175000017500000000000011060556404026025 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/0000755000175000017500000000000012147674233017232 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/pom.xml0000644000175000017500000000311311057573715020547 0ustar ebourgebourg 4.0.0 test default 1.0-SNAPSHOT Test for clean Check for proper cleaning of default output files. UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ maven-clean-plugin-2.5/src/it/default/setup.bsh0000644000175000017500000000063311047656041021065 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { File targetDir = new File( basedir, "target" ); System.out.println( "Checking for existence of " + targetDir ); if ( !targetDir.isDirectory() ) { System.out.println( "FAILURE!" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/default/verify.bsh0000644000175000017500000000062311047656041021230 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { File targetDir = new File( basedir, "target" ); System.out.println( "Checking for absence of " + targetDir ); if ( targetDir.exists() ) { System.out.println( "FAILURE!" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/default/target/0000755000175000017500000000000012147674233020520 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/target/classes/0000755000175000017500000000000012147674233022155 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/target/classes/main.properties0000644000175000017500000000000011047656041025200 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/target/test-classes/0000755000175000017500000000000012147674233023132 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/target/test-classes/test.properties0000644000175000017500000000000011047656041026210 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/target/site/0000755000175000017500000000000012147674233021464 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/default/target/site/index.html0000644000175000017500000000000011047656041023442 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/0000755000175000017500000000000012147674233021536 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/pom.xml0000644000175000017500000000354611322421205023042 0ustar ebourgebourg 4.0.0 test symlinks-dont-follow 1.0-SNAPSHOT Check that symlinks are not followed if requested (MCLEAN-39). UTF-8 org.apache.maven.plugins maven-clean-plugin @project.version@ false target2 false maven-clean-plugin-2.5/src/it/symlink-dont-follow/ext/0000755000175000017500000000000012147674233022336 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/ext/file.txt0000644000175000017500000000000011322421205023763 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/ext/dir/0000755000175000017500000000000012147674233023114 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/ext/dir/file.txt0000644000175000017500000000000011322421205024541 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/target2/0000755000175000017500000000000012147674233023106 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/target2/dummy.txt0000644000175000017500000000000011322421205024747 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/setup.bsh0000644000175000017500000000127111322421205023354 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; import org.apache.maven.plugin.clean.*; String[][] pairs = { { "ext/file.txt", "target/link.txt" }, { "ext/dir", "target/link" }, { "ext/file.txt", "target2/link.txt" }, { "ext/dir", "target2/link" }, }; for ( String[] pair : pairs ) { File target = new File( basedir, pair[0] ); File link = new File( basedir, pair[1] ); System.out.println( "Creating symlink " + link + " -> " + target ); if ( !Utils.createSymlink( target, link ) || !link.exists() ) { System.out.println( "FAILURE, platform does not support symlinks, skipping test." ); return; } } maven-clean-plugin-2.5/src/it/symlink-dont-follow/verify.bsh0000644000175000017500000000143711322421205023524 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; String[] expected = { "ext", "ext/file.txt", "ext/dir/file.txt", }; for ( String path : expected ) { File file = new File( basedir, path ); System.out.println( "Checking for existence of " + file ); if ( !file.exists() ) { System.out.println( "FAILURE!" ); return false; } } String[] unexpected = { "target/link.txt", "target/link", "target", "target2/link.txt", "target2/link", "target2", }; for ( String path : unexpected ) { File file = new File( basedir, path ); System.out.println( "Checking for absence of " + file ); if ( file.exists() ) { System.out.println( "FAILURE!" ); return false; } } maven-clean-plugin-2.5/src/it/symlink-dont-follow/target/0000755000175000017500000000000012147674233023024 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/symlink-dont-follow/target/dummy.txt0000644000175000017500000000000011322421205024665 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/0000755000175000017500000000000012147674233020624 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/pom.xml0000644000175000017500000000465511751041053022137 0ustar ebourgebourg 4.0.0 test default 1.0-SNAPSHOT Test for clean Check for proper cleaning of default output files. UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ test-clean org.apache.maven.plugins maven-clean-plugin @pom.version@ true ${project.build.testOutputDirectory} maven-clean-plugin-2.5/src/it/only-test-clean/invoker.properties0000644000175000017500000000004211751041053024377 0ustar ebourgebourginvoker.goals = clean -Ptest-cleanmaven-clean-plugin-2.5/src/it/only-test-clean/setup.bsh0000644000175000017500000000063311751041053022450 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { File targetDir = new File( basedir, "target" ); System.out.println( "Checking for existence of " + targetDir ); if ( !targetDir.isDirectory() ) { System.out.println( "FAILURE!" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/only-test-clean/verify.bsh0000644000175000017500000000151611751041053022615 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { File targetDir = new File( basedir, "target" ); System.out.println( "Checking for absence of " + targetDir ); if ( !targetDir.exists() ) { System.out.println( "FAILURE! target must exists" ); return false; } File targetClasses = new File( targetDir, "classes" ); if ( !targetClasses.exists() ) { System.out.println( "FAILURE! target/classes must exists" ); return false; } File targetTestsClasses = new File( targetDir, "test-classes" ); if ( targetTestsClasses.exists() ) { System.out.println( "FAILURE! target/test-classes must not exists" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/only-test-clean/target/0000755000175000017500000000000012147674233022112 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/target/classes/0000755000175000017500000000000012147674233023547 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/target/classes/main.properties0000644000175000017500000000000011751041053026563 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/target/test-classes/0000755000175000017500000000000012147674233024524 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/target/test-classes/test.properties0000644000175000017500000000000011751041053027573 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/target/site/0000755000175000017500000000000012147674233023056 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/only-test-clean/target/site/index.html0000644000175000017500000000000011751041053025025 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/0000755000175000017500000000000012147674233022427 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-b/0000755000175000017500000000000012147674233023731 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-b/pom.xml0000644000175000017500000000400111057573715025243 0ustar ebourgebourg 4.0.0 test parent 1.0-SNAPSHOT test child-b 1.0-SNAPSHOT Child B Check for proper cleaning of file sets with relative paths during reactor build. UTF-8 deploy org.apache.maven.plugins maven-clean-plugin ${deploy.dir} maven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-b/deploy/0000755000175000017500000000000012147674233025225 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-b/deploy/test.txt0000644000175000017500000000000411057573715026741 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-b/target/0000755000175000017500000000000012147674233025217 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-b/target/test.txt0000644000175000017500000000000411057573715026733 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/pom.xml0000644000175000017500000000325011057573715023746 0ustar ebourgebourg 4.0.0 test parent 1.0-SNAPSHOT pom Test for clean child-a child-b UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ maven-clean-plugin-2.5/src/it/file-sets-relative-paths/temp-stuff/0000755000175000017500000000000012147674233024521 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/temp-stuff/test.txt0000644000175000017500000000000411057573715026235 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-a/0000755000175000017500000000000012147674233023730 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-a/pom.xml0000644000175000017500000000374411057573715025257 0ustar ebourgebourg 4.0.0 test parent 1.0-SNAPSHOT test child-a 1.0-SNAPSHOT Child A Check for proper cleaning of file sets with relative paths during reactor build. UTF-8 org.apache.maven.plugins maven-clean-plugin temp-stuff maven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-a/temp-stuff/0000755000175000017500000000000012147674233026022 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-a/temp-stuff/test.txt0000644000175000017500000000000411057573715027536 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-a/target/0000755000175000017500000000000012147674233025216 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/child-a/target/test.txt0000644000175000017500000000000411057573715026732 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/deploy/0000755000175000017500000000000012147674233023723 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/deploy/test.txt0000644000175000017500000000000411057573715025437 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/verify.bsh0000644000175000017500000000174511057573715024442 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { String[] expected = { "temp-stuff/test.txt", "deploy/test.txt", }; for ( String path : expected ) { File file = new File( basedir, path ); System.out.println( "Checking for existence of " + file ); if ( !file.exists() ) { System.out.println( "FAILURE!" ); return false; } } String[] unexpected = { "target", "child-a/target", "child-a/temp-stuff", "child-b/target", "child-b/deploy", }; for ( String path : unexpected ) { File file = new File( basedir, path ); System.out.println( "Checking for absence of " + file ); if ( file.exists() ) { System.out.println( "FAILURE!" ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/file-sets-relative-paths/target/0000755000175000017500000000000012147674233023715 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-relative-paths/target/test.txt0000644000175000017500000000000411057573715025431 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/settings.xml0000644000175000017500000000317411257425203020165 0ustar ebourgebourg it-repo true local.central @localRepositoryUrl@ true true local.central @localRepositoryUrl@ true true maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/0000755000175000017500000000000012147674233023117 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/0000755000175000017500000000000012147674233024060 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/0000755000175000017500000000000012147674233024716 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/included.txt0000644000175000017500000000001411062261037027226 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/excluded.txt0000644000175000017500000000001411062261037027234 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/sub2/0000755000175000017500000000000012147674233025571 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/sub2/excluded.txt0000644000175000017500000000001411062261037030107 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/sub1/0000755000175000017500000000000012147674233025570 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/sub1/included.txt0000644000175000017500000000001411062261037030100 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/sub0/0000755000175000017500000000000012147674233025567 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/sub0/included.txt0000644000175000017500000000001411062261037030077 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir0/sub0/excluded.txt0000644000175000017500000000001411062261037030105 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/0000755000175000017500000000000012147674233024720 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/included.txt0000644000175000017500000000001411062261037027230 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/excluded.txt0000644000175000017500000000001411062261037027236 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/sub2/0000755000175000017500000000000012147674233025573 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/sub2/excluded.txt0000644000175000017500000000001411062261037030111 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/sub1/0000755000175000017500000000000012147674233025572 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/sub1/included.txt0000644000175000017500000000001411062261037030102 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/sub0/0000755000175000017500000000000012147674233025571 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/sub0/included.txt0000644000175000017500000000001411062261037030101 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir2/sub0/excluded.txt0000644000175000017500000000001411062261037030107 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/0000755000175000017500000000000012147674233024721 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/included.txt0000644000175000017500000000001411062261037027231 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/excluded.txt0000644000175000017500000000001411062261037027237 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/sub2/0000755000175000017500000000000012147674233025574 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/sub2/excluded.txt0000644000175000017500000000001411062261037030112 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/sub1/0000755000175000017500000000000012147674233025573 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/sub1/included.txt0000644000175000017500000000001411062261037030103 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/sub0/0000755000175000017500000000000012147674233025572 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/sub0/included.txt0000644000175000017500000000001411062261037030102 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir3/sub0/excluded.txt0000644000175000017500000000001411062261037030110 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/0000755000175000017500000000000012147674233024717 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/included.txt0000644000175000017500000000001411062261037027227 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/excluded.txt0000644000175000017500000000001411062261037027235 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/sub2/0000755000175000017500000000000012147674233025572 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/sub2/excluded.txt0000644000175000017500000000001411062261037030110 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/sub1/0000755000175000017500000000000012147674233025571 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/sub1/included.txt0000644000175000017500000000001411062261037030101 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/sub0/0000755000175000017500000000000012147674233025570 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/sub0/included.txt0000644000175000017500000000001411062261037030100 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/dirs/dir1/sub0/excluded.txt0000644000175000017500000000001411062261037030106 0ustar ebourgebourgJust a file.maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/pom.xml0000644000175000017500000000533611062261037024430 0ustar ebourgebourg 4.0.0 test file-sets-includes-excludes 1.0-SNAPSHOT Check for proper handling of includes/excludes during cleaning, especially with varying symlink handling. UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ ${basedir}/dirs/dir0 **/*included*/** true ${basedir}/dirs/dir1 **/*included*/** false ${basedir}/dirs/dir2 **/*excluded*/** true ${basedir}/dirs/dir3 **/*excluded*/** false maven-clean-plugin-2.5/src/it/file-sets-includes-excludes/verify.bsh0000644000175000017500000000316311062261037025111 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { String[] expected = { "dir0/excluded.txt", "dir0/sub0/excluded.txt", "dir0/sub1", "dir0/sub2/excluded.txt", "dir1/excluded.txt", "dir1/sub0/excluded.txt", "dir1/sub1", "dir1/sub2/excluded.txt", "dir2/excluded.txt", "dir2/sub0/excluded.txt", "dir2/sub2/excluded.txt", "dir3/excluded.txt", "dir3/sub0/excluded.txt", "dir3/sub2/excluded.txt", }; for ( String path : expected ) { File file = new File( new File( basedir, "dirs" ), path ); System.out.println( "Checking for existence of " + file ); if ( !file.exists() ) { System.out.println( "FAILURE!" ); return false; } } String[] unexpected = { "dir0/included.txt", "dir0/sub0/included.txt", "dir0/sub1/included.txt", "dir1/included.txt", "dir1/sub0/included.txt", "dir1/sub1/included.txt", "dir2/included.txt", "dir2/sub0/included.txt", "dir2/sub1", "dir3/included.txt", "dir3/sub0/included.txt", "dir3/sub1", }; for ( String path : unexpected ) { File file = new File( new File( basedir, "dirs" ), path ); System.out.println( "Checking for absence of " + file ); if ( file.exists() ) { System.out.println( "FAILURE!" ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/dangling-symlinks/0000755000175000017500000000000012147674233021240 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/dangling-symlinks/pom.xml0000644000175000017500000000310011322421205022526 0ustar ebourgebourg 4.0.0 test dangling-symlinks 1.0-SNAPSHOT Check for proper cleaning of dangling symlinks (MCLEAN-28). UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ maven-clean-plugin-2.5/src/it/dangling-symlinks/setup.bsh0000644000175000017500000000130311322421205023052 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; import org.apache.maven.plugin.clean.*; try { File targetDir = new File( basedir, "target" ); File link = new File( targetDir, "link" ); File target = new File( targetDir, "link-target.txt" ); System.out.println( "Creating symlink " + link + " -> " + target ); if ( !Utils.createSymlink( target, link ) || !link.exists() ) { System.out.println( "FAILURE, platform does not support symlinks, skipping test." ); } System.out.println( "Deleting symlink target " + target ); target.delete(); } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/dangling-symlinks/verify.bsh0000644000175000017500000000062311060563121023225 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { File targetDir = new File( basedir, "target" ); System.out.println( "Checking for absence of " + targetDir ); if ( targetDir.exists() ) { System.out.println( "FAILURE!" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/dangling-symlinks/target/0000755000175000017500000000000012147674233022526 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/dangling-symlinks/target/link-target.txt0000644000175000017500000000000011060563121025460 0ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-absolute-paths/0000755000175000017500000000000012147674233022432 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-absolute-paths/delete-me/0000755000175000017500000000000012147674233024273 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-absolute-paths/delete-me/test.txt0000644000175000017500000000000411057605007025775 0ustar ebourgebourgTestmaven-clean-plugin-2.5/src/it/file-sets-absolute-paths/pom.xml0000644000175000017500000000335011057605007023740 0ustar ebourgebourg 4.0.0 test parent 1.0-SNAPSHOT pom Test for clean child-a UTF-8 @project.build.directory@/it/file-sets-absolute-paths/delete-me org.apache.maven.plugins maven-clean-plugin @pom.version@ maven-clean-plugin-2.5/src/it/file-sets-absolute-paths/child-a/0000755000175000017500000000000012147674233023733 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/file-sets-absolute-paths/child-a/pom.xml0000644000175000017500000000356111057605007025245 0ustar ebourgebourg 4.0.0 test parent 1.0-SNAPSHOT test child-a 1.0-SNAPSHOT Child A Check for proper cleaning of file sets with absolute paths during reactor build. UTF-8 org.apache.maven.plugins maven-clean-plugin ${deploy.dir} maven-clean-plugin-2.5/src/it/file-sets-absolute-paths/verify.bsh0000644000175000017500000000100511057605007024420 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { String[] unexpected = { "delete-me", }; for ( String path : unexpected ) { File file = new File( basedir, path ); System.out.println( "Checking for absence of " + file ); if ( file.exists() ) { System.out.println( "FAILURE!" ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/it/non-existent-base-dirs/0000755000175000017500000000000012147674233022110 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/non-existent-base-dirs/pom.xml0000644000175000017500000000342211057776761023436 0ustar ebourgebourg 4.0.0 test non-existent-base-dirs 1.0-SNAPSHOT Check that non-existing base directories for clean do not fail the build. UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ non-existing-dir maven-clean-plugin-2.5/src/it/special-characters/0000755000175000017500000000000012147674233021343 5ustar ebourgebourgmaven-clean-plugin-2.5/src/it/special-characters/pom.xml0000644000175000017500000000323511754770702022664 0ustar ebourgebourg 4.0.0 org.apache.maven.plugins.clean.its mrelease-48 1.0-SNAPSHOT Test for clean Check for proper cleaning of default output files. UTF-8 org.apache.maven.plugins maven-clean-plugin @pom.version@ maven-clean-plugin-2.5/src/it/special-characters/setup.bsh0000644000175000017500000000054511757161563023210 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; import org.apache.maven.plugin.clean.*; File parentDir = new File( basedir, "target" ); File target = new File( parentDir, "Pep\u00E9 le Pew" ); target.mkdirs(); target = new File( parentDir, "Conditions_g\u00E9n\u00E9rales_d'isalaire.txt" ); target.createNewFile(); maven-clean-plugin-2.5/src/it/special-characters/verify.bsh0000644000175000017500000000071111754770702023345 0ustar ebourgebourgimport java.io.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; try { // this confirms that special character file and directory are deleted File targetDir = new File( basedir, "target" ); if ( targetDir.exists() ) { System.out.println( "FAILURE! target must not exist" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; maven-clean-plugin-2.5/src/site/0000755000175000017500000000000012147674233016136 5ustar ebourgebourgmaven-clean-plugin-2.5/src/site/fml/0000755000175000017500000000000012147674233016714 5ustar ebourgebourgmaven-clean-plugin-2.5/src/site/fml/faq.fml0000644000175000017500000000562511236277743020176 0ustar ebourgebourg I already ran mvn clean but the directory (put dir name here) is still there. What should I do?

Some files-generating plugins can generate their files outside of the default directories being deleted by the clean plugin. You should add the location of such files in the clean plugin configuration or change the configuration of those plugins to put their files inside the project.build.directory which is by default, the target directory.

On Windows, I got "Unable to delete directory". What's wrong?

For instance, clean could fail if you already have opened a command line with target as the current dir. Windows locks some ressources and you need to close the handles on these ressources. To skip these errors, you could call clean with the command line parameter -Dmaven.clean.failOnError=false. For more information, refer to Ignoring Errors page.

Sysinternals produced a number of utilities, like Process Explorer or Handle that help you to deal with Windows handles.

maven-clean-plugin-2.5/src/site/site.xml0000644000175000017500000000307211236277743017631 0ustar ebourgebourg maven-clean-plugin-2.5/src/site/apt/0000755000175000017500000000000012147674233016722 5ustar ebourgebourgmaven-clean-plugin-2.5/src/site/apt/index.apt0000644000175000017500000000663211236277743020551 0ustar ebourgebourg ------ Introduction ------ Edwin Punzalan ------ 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 Clean Plugin The Clean Plugin is used when you want to remove files generated at build-time in a project's directory. * Goals Overview The Clean Plugin only has one goal. * {{{./clean-mojo.html}clean:clean}} attempts to clean a project's working directory of the files that we're generated at build-time. By default, it discovers and deletes the directories configured in <<>>, <<>>, <<>>, and <<>>. * Usage General instructions on how to use the Clean Plugin can be found on the {{{./usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/Clean+Plugin}plugin's wiki page}}. In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel free to contact the {{{./mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{./mail-lists.html}mail archive}}. If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our {{{./issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{./source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples To provide you with better understanding on some usages of the Clean Plugin, you can take a look into the following examples: * {{{./examples/delete_additional_files.html}How to delete additional files outside of the default directories?}} * {{{./examples/ignoring-errors.html}How to ignore clean errors?}} * {{{./examples/skipping-clean.html}How to skipping clean execution?}} [] maven-clean-plugin-2.5/src/site/apt/examples/0000755000175000017500000000000012147674233020540 5ustar ebourgebourgmaven-clean-plugin-2.5/src/site/apt/examples/delete_additional_files.apt.vm0000644000175000017500000000443611236277635026515 0ustar ebourgebourg ------ Delete Additional Files Not Exposed to Maven ------ Mike Perham ------ 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 Delete Additional Files Not Exposed to Maven The Maven Clean Plugin will delete the <<>> directory by default. You may configure it to delete additional directories and files. The following example shows how: +-------- [...] maven-clean-plugin ${project.version} some/relative/path **/*.tmp **/*.log **/important.log **/another-important.log false [...] +--------- <> The <<>> in the <<>> is a relative path inside a project, in other words, +-------- some/relative/path +-------- is equivalent to: +-------- ${basedir}/some/relative/path +-------- You could also define file set rules in a parent POM. In this case, the clean plugin adds the subproject basedir to the defined relative path. maven-clean-plugin-2.5/src/site/apt/examples/skipping-clean.apt.vm0000644000175000017500000000273311236277635024603 0ustar ebourgebourg ------ Skipping Clean ------ Vincent Siveton ------ 13 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 Skipping Clean To skip running the cleanup for a particular project, set the <<>> property to <<>>. +-------- [...] maven-clean-plugin ${project.version} true [...] +--------- You can also skip the cleaning via command line by executing the following command: +-------- mvn clean -Dclean.skip=true +--------- maven-clean-plugin-2.5/src/site/apt/examples/ignoring-errors.apt.vm0000644000175000017500000000302611236277635025021 0ustar ebourgebourg ------ Ignoring Clean Errors ------ Vincent Siveton ------ 13 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 Ignoring Clean Errors To ignore errors when running the cleanup for a particular project, set the <<>> property to <<>>. +-------- [...] maven-clean-plugin ${project.version} false [...] +--------- You can also ignore them via command line by executing the following command: +-------- mvn clean -Dmaven.clean.failOnError=false +--------- maven-clean-plugin-2.5/src/site/apt/usage.apt.vm0000644000175000017500000000531311236277635021162 0ustar ebourgebourg ------ Usage ------ Edwin Punzalan ------ June 29th, 2006 ~~ 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 Usage The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build. While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the <<>> directory. * Cleaning a Maven project using the command-line The Clean Plugin can be called to execute in the command-line without any additional configurations. Like the other plugins, to run the Clean Plugin, you use: +----- mvn clean:clean +----- where the first <<>> refers to the plugin's alias, and the second <<>> refers to the plugin goal. However, the Clean Plugin is a special plugin and is bound to its own special lifecycyle phase called <<>>. Thus, for simplicity, it can also be executed by using: +----- mvn clean +----- or with other phases/goals like: +----- mvn clean package site +----- * Running the Clean Plugin automatically during a build If for some reason, adding <<>> to the command-line is not option, the Clean Plugin can be put into a project's <<>> so that it gets executed everytime the project is built. Below is a sample <<>> for running the Clean Plugin in the <<>> phase everytime the project is built: +----- [...] maven-clean-plugin ${project.version} auto-clean initialize clean [...] +----- maven-clean-plugin-2.5/src/test/0000755000175000017500000000000012147674233016151 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/java/0000755000175000017500000000000012147674233017072 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/java/org/0000755000175000017500000000000012147674233017661 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/java/org/apache/0000755000175000017500000000000012147674233021102 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/java/org/apache/maven/0000755000175000017500000000000012147674233022210 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/java/org/apache/maven/plugin/0000755000175000017500000000000012147674233023506 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/java/org/apache/maven/plugin/clean/0000755000175000017500000000000012147674233024570 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/java/org/apache/maven/plugin/clean/Utils.java0000644000175000017500000000444311326636120026527 0ustar ebourgebourgpackage org.apache.maven.plugin.clean; /* * 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 org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.StreamConsumer; /** * Testing helpers for the IT scripts. * * @author Benjamin Bentmann */ public class Utils { /** * Creates a symbolic link. * * @param target The target (file or directory) of the link, must not be null. * @param link The path to the link, must not be null. * @return true if the symlink could be created, false otherwise. */ public static boolean createSymlink( File target, File link ) { try { Commandline cli = new Commandline(); cli.setExecutable( "ln" ); cli.createArg().setValue( "-s" ); cli.createArg().setFile( target ); cli.createArg().setFile( link ); int code = CommandLineUtils.executeCommandLine( cli, new StreamConsumer() { public void consumeLine( String line ) { System.out.println( line ); } }, new StreamConsumer() { public void consumeLine( String line ) { System.err.println( line ); } } ); return 0 == code; } catch ( Exception e ) { return false; } } } maven-clean-plugin-2.5/src/test/java/org/apache/maven/plugin/clean/CleanMojoTest.java0000644000175000017500000003030411371275767030151 0ustar ebourgebourgpackage org.apache.maven.plugin.clean; /* * 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.RandomAccessFile; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.codehaus.plexus.util.FileUtils; /** * Test the clean mojo. * * @author Vincent Siveton * @version $Id: CleanMojoTest.java 942398 2010-05-08 14:57:59Z bentmann $ */ public class CleanMojoTest extends AbstractMojoTestCase { /** {@inheritDoc} */ protected void setUp() throws Exception { super.setUp(); } /** {@inheritDoc} */ protected void tearDown() throws Exception { super.tearDown(); } /** * Tests the simple removal of directories * * @throws Exception */ public void testBasicClean() throws Exception { String pluginPom = getBasedir() + "/src/test/resources/unit/basic-clean-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/basic-clean-test" ), new File( getBasedir(), "target/test-classes/unit/basic-clean-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom ); assertNotNull( mojo ); mojo.execute(); assertFalse( "Directory exists", checkExists( getBasedir() + "/target/test-classes/unit/" + "basic-clean-test/buildDirectory" ) ); assertFalse( "Directory exists", checkExists( getBasedir() + "/target/test-classes/unit/basic-clean-test/" + "buildOutputDirectory" ) ); assertFalse( "Directory exists", checkExists( getBasedir() + "/target/test-classes/unit/basic-clean-test/" + "buildTestDirectory" ) ); } /** * Tests the removal of files and nested directories * * @throws Exception */ public void testCleanNestedStructure() throws Exception { String pluginPom = getBasedir() + "/src/test/resources/unit/nested-clean-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/nested-clean-test" ), new File( getBasedir(), "target/test-classes/unit/nested-clean-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom ); assertNotNull( mojo ); mojo.execute(); assertFalse( checkExists( getBasedir() + "/target/test-classes/unit/nested-clean-test/target" ) ); assertFalse( checkExists( getBasedir() + "/target/test-classes/unit/nested-clean-test/target/classes" ) ); assertFalse( checkExists( getBasedir() + "/target/test-classes/unit/nested-clean-test/target/test-classes" ) ); } /** * Tests that no exception is thrown when all internal variables are empty and that it doesn't * just remove whats there * * @throws Exception */ public void testCleanEmptyDirectories() throws Exception { String pluginPom = getBasedir() + "/src/test/resources/unit/empty-clean-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/empty-clean-test" ), new File( getBasedir(), "target/test-classes/unit/empty-clean-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupEmptyMojo( "clean", pluginPom ); assertNotNull( mojo ); mojo.execute(); assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/empty-clean-test/testDirectoryStructure" ) ); assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/empty-clean-test/" + "testDirectoryStructure/file.txt" ) ); assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/empty-clean-test/" + "testDirectoryStructure/outputDirectory" ) ); assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/empty-clean-test/" + "testDirectoryStructure/outputDirectory/file.txt" ) ); } /** * Tests the removal of files using fileset * * @throws Exception */ public void testFilesetsClean() throws Exception { String pluginPom = getBasedir() + "/src/test/resources/unit/fileset-clean-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/fileset-clean-test" ), new File( getBasedir(), "target/test-classes/unit/fileset-clean-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom ); assertNotNull( mojo ); mojo.execute(); // fileset 1 assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/fileset-clean-test/target" ) ); assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/classes" ) ); assertFalse( checkExists( getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/test-classes" ) ); assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/subdir" ) ); assertFalse( checkExists( getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/classes/file.txt" ) ); assertTrue( checkEmpty( getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/classes" ) ); assertTrue( checkEmpty( getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/subdir" ) ); // fileset 2 assertTrue( checkExists( getBasedir() + "/target/test-classes/unit/fileset-clean-test/" + "buildOutputDirectory" ) ); assertFalse( checkExists( getBasedir() + "/target/test-classes/unit/fileset-clean-test/" + "buildOutputDirectory/file.txt" ) ); } /** * Tests the removal of a directory as file * * @throws Exception */ public void testCleanInvalidDirectory() throws Exception { String pluginPom = getBasedir() + "/src/test/resources/unit/invalid-directory-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/invalid-directory-test" ), new File( getBasedir(), "target/test-classes/unit/invalid-directory-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom ); assertNotNull( mojo ); try { mojo.execute(); fail( "Should fail to delete a file treated as a directory" ); } catch ( MojoExecutionException expected ) { assertTrue( true ); } } /** * Tests the removal of a missing directory * * @throws Exception */ public void testMissingDirectory() throws Exception { String pluginPom = getBasedir() + "/src/test/resources/unit/missing-directory-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/missing-directory-test" ), new File( getBasedir(), "target/test-classes/unit/missing-directory-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom ); assertNotNull( mojo ); mojo.execute(); assertFalse( checkExists( getBasedir() + "/target/test-classes/unit/missing-directory-test/does-not-exist" ) ); } /** * Test the removal of a locked file on Windows systems. *
* Note: Unix systems doesn't lock any files. * * @throws Exception */ public void testCleanLockedFile() throws Exception { if ( System.getProperty( "os.name" ).toLowerCase().indexOf( "windows" ) == -1 ) { assertTrue( "Ignored this test on none Windows based systems", true ); return; } String pluginPom = getBasedir() + "/src/test/resources/unit/locked-file-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/locked-file-test" ), new File( getBasedir(), "target/test-classes/unit/locked-file-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom ); assertNotNull( mojo ); File f = new File( getBasedir(), "target/test-classes/unit/locked-file-test/buildDirectory/file.txt" ); FileChannel channel = null; FileLock lock = null; try { channel = new RandomAccessFile( f, "rw" ).getChannel(); lock = channel.lock(); mojo.execute(); fail( "Should fail to delete a file that is locked" ); } catch ( MojoExecutionException expected ) { assertTrue( true ); } finally { if ( lock != null ) { lock.release(); } if ( channel != null ) { channel.close(); } } } /** * Test the removal of a locked file on Windows systems. *
* Note: Unix systems doesn't lock any files. * * @throws Exception */ public void testCleanLockedFileWithNoError() throws Exception { if ( System.getProperty( "os.name" ).toLowerCase().indexOf( "windows" ) == -1 ) { assertTrue( "Ignored this test on none Windows based systems", true ); return; } String pluginPom = getBasedir() + "/src/test/resources/unit/locked-file-test/plugin-pom.xml"; // safety FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/locked-file-test" ), new File( getBasedir(), "target/test-classes/unit/locked-file-test" ), null, "**/.svn,**/.svn/**" ); CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom ); setVariableValueToObject( mojo, "failOnError", Boolean.FALSE ); assertNotNull( mojo ); File f = new File( getBasedir(), "target/test-classes/unit/locked-file-test/buildDirectory/file.txt" ); FileChannel channel = null; FileLock lock = null; try { channel = new RandomAccessFile( f, "rw" ).getChannel(); lock = channel.lock(); mojo.execute(); assertTrue( true ); } catch ( MojoExecutionException expected ) { fail( "Should display a warning when deleting a file that is locked" ); } finally { if ( lock != null ) { lock.release(); } if ( channel != null ) { channel.close(); } } } /** * @param dir a dir or a file * @return true if a file/dir exists, false otherwise */ private boolean checkExists( String dir ) { return FileUtils.fileExists( new File( dir ).getAbsolutePath() ); } /** * @param dir a directory * @return true if a dir is empty, false otherwise */ private boolean checkEmpty( String dir ) { return FileUtils.sizeOfDirectory( new File( dir ).getAbsolutePath() ) == 0; } } maven-clean-plugin-2.5/src/test/resources/0000755000175000017500000000000012147674233020163 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/0000755000175000017500000000000012147674233021142 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/0000755000175000017500000000000012147674233024335 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/testDirectoryStructure/0000755000175000017500000000000012147674233031122 5ustar ebourgebourg././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/testDirectoryStructure/outputDirectory/maven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/testDirectoryStructure/outputDirecto0000755000175000017500000000000012147674233033715 5ustar ebourgebourg././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/testDirectoryStructure/outputDirectory/file.txtmaven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/testDirectoryStructure/outputDirecto0000644000175000017500000000000010717034175033701 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/testDirectoryStructure/file.txt0000644000175000017500000000000010717034175032564 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/empty-clean-test/plugin-pom.xml0000644000175000017500000000211211322421205027121 0ustar ebourgebourg maven-clean-plugin true true maven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/0000755000175000017500000000000012147674233024632 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/buildOutputDirectory/0000755000175000017500000000000012147674233031037 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/buildOutputDirectory/file.txt0000644000175000017500000000000010717034175032501 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/plugin-pom.xml0000644000175000017500000000351611371275767027457 0ustar ebourgebourg maven-clean-plugin ${basedir}/target/test-classes/unit/fileset-clean-test/target **/file.txt **/test-classes/** **/subdir/** ${basedir}/target/test-classes/unit/fileset-clean-test/buildOutputDirectory ** true true maven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/0000755000175000017500000000000012147674233026120 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/classes/0000755000175000017500000000000012147674233027555 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/classes/file.txt0000644000175000017500000000000010717034175031217 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/test-classes/0000755000175000017500000000000012147674233030532 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/test-classes/file.txt0000644000175000017500000000000010717034175032174 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/file.txt0000644000175000017500000000000010717034175027562 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/subdir/0000755000175000017500000000000012147674233027410 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/fileset-clean-test/target/subdir/file.txt0000644000175000017500000000000010717034175031052 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/invalid-directory-test/0000755000175000017500000000000012147674233025547 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/invalid-directory-test/this-is-a-file0000644000175000017500000000000010717034175030167 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/invalid-directory-test/plugin-pom.xml0000644000175000017500000000226511322421205030344 0ustar ebourgebourg maven-clean-plugin ${basedir}/target/test-classes/unit/invalid-directory-test/this-is-a-file true true maven-clean-plugin-2.5/src/test/resources/unit/locked-file-test/0000755000175000017500000000000012147674233024275 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/locked-file-test/buildDirectory/0000755000175000017500000000000012147674233027261 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/locked-file-test/buildDirectory/file.txt0000644000175000017500000000000010717034175030723 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/locked-file-test/plugin-pom.xml0000644000175000017500000000225711322421205027073 0ustar ebourgebourg maven-clean-plugin ${basedir}/target/test-classes/unit/locked-file-test/buildDirectory true true maven-clean-plugin-2.5/src/test/resources/unit/missing-directory-test/0000755000175000017500000000000012147674233025572 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/missing-directory-test/plugin-pom.xml0000644000175000017500000000226111322421205030363 0ustar ebourgebourg maven-clean-plugin ${basedir}/target/test-classes/unit/missing-clean-test/does-not-exist true true maven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/0000755000175000017500000000000012147674233024260 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/buildDirectory/0000755000175000017500000000000012147674233027244 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/buildDirectory/file.txt0000644000175000017500000000000010717034175030706 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/buildOutputDirectory/0000755000175000017500000000000012147674233030465 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/buildOutputDirectory/file.txt0000644000175000017500000000000010717034175032127 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/plugin-pom.xml0000644000175000017500000000264311322421205027055 0ustar ebourgebourg maven-clean-plugin ${basedir}/target/test-classes/unit/basic-clean-test/buildDirectory ${basedir}/target/test-classes/unit/basic-clean-test/buildOutputDirectory ${basedir}/target/test-classes/unit/basic-clean-test/buildTestDirectory true true maven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/buildTestDirectory/0000755000175000017500000000000012147674233030104 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/basic-clean-test/buildTestDirectory/file.txt0000644000175000017500000000000010717034175031546 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/0000755000175000017500000000000012147674233024461 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/plugin-pom.xml0000644000175000017500000000263111322421205027253 0ustar ebourgebourg maven-clean-plugin ${basedir}/target/test-classes/unit/nested-clean-test/target ${basedir}/target/test-classes/unit/nested-clean-test/target/classes ${basedir}/target/test-classes/unit/nested-clean-test/target/test-classes true true maven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/0000755000175000017500000000000012147674233025747 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/classes/0000755000175000017500000000000012147674233027404 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/classes/file.txt0000644000175000017500000000000010717034175031046 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/test-classes/0000755000175000017500000000000012147674233030361 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/test-classes/file.txt0000644000175000017500000000000010717034175032023 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/file.txt0000644000175000017500000000000010717034175027411 0ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/subdir/0000755000175000017500000000000012147674233027237 5ustar ebourgebourgmaven-clean-plugin-2.5/src/test/resources/unit/nested-clean-test/target/subdir/file.txt0000644000175000017500000000000010717034175030701 0ustar ebourgebourgmaven-clean-plugin-2.5/src/main/0000755000175000017500000000000012147674233016116 5ustar ebourgebourgmaven-clean-plugin-2.5/src/main/java/0000755000175000017500000000000012147674233017037 5ustar ebourgebourgmaven-clean-plugin-2.5/src/main/java/org/0000755000175000017500000000000012147674233017626 5ustar ebourgebourgmaven-clean-plugin-2.5/src/main/java/org/apache/0000755000175000017500000000000012147674233021047 5ustar ebourgebourgmaven-clean-plugin-2.5/src/main/java/org/apache/maven/0000755000175000017500000000000012147674233022155 5ustar ebourgebourgmaven-clean-plugin-2.5/src/main/java/org/apache/maven/plugin/0000755000175000017500000000000012147674233023453 5ustar ebourgebourgmaven-clean-plugin-2.5/src/main/java/org/apache/maven/plugin/clean/0000755000175000017500000000000012147674233024535 5ustar ebourgebourgmaven-clean-plugin-2.5/src/main/java/org/apache/maven/plugin/clean/GlobSelector.java0000644000175000017500000001043611371275767027777 0ustar ebourgebourgpackage org.apache.maven.plugin.clean; /* * 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.util.Arrays; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.SelectorUtils; /** * Selects paths based on Ant-like glob patterns. * * @author Benjamin Bentmann */ class GlobSelector implements Selector { private final String[] includes; private final String[] excludes; private final String str; public GlobSelector( String[] includes, String[] excludes ) { this( includes, excludes, false ); } public GlobSelector( String[] includes, String[] excludes, boolean useDefaultExcludes ) { this.str = "includes = " + toString( includes ) + ", excludes = " + toString( excludes ); this.includes = normalizePatterns( includes ); this.excludes = normalizePatterns( addDefaultExcludes( excludes, useDefaultExcludes ) ); } private static String toString( String[] patterns ) { return ( patterns == null ) ? "[]" : Arrays.asList( patterns ).toString(); } private static String[] addDefaultExcludes( String[] excludes, boolean useDefaultExcludes ) { String[] defaults = DirectoryScanner.DEFAULTEXCLUDES; if ( !useDefaultExcludes ) { return excludes; } else if ( excludes == null || excludes.length <= 0 ) { return defaults; } else { String[] patterns = new String[excludes.length + defaults.length]; System.arraycopy( excludes, 0, patterns, 0, excludes.length ); System.arraycopy( defaults, 0, patterns, excludes.length, defaults.length ); return patterns; } } private static String[] normalizePatterns( String[] patterns ) { String[] normalized; if ( patterns != null ) { normalized = new String[patterns.length]; for ( int i = patterns.length - 1; i >= 0; i-- ) { normalized[i] = normalizePattern( patterns[i] ); } } else { normalized = new String[0]; } return normalized; } private static String normalizePattern( String pattern ) { if ( pattern == null ) { return ""; } String normalized = pattern.replace( ( File.separatorChar == '/' ) ? '\\' : '/', File.separatorChar ); if ( normalized.endsWith( File.separator ) ) { normalized += "**"; } return normalized; } public boolean isSelected( String pathname ) { return ( includes.length <= 0 || isMatched( pathname, includes ) ) && ( excludes.length <= 0 || !isMatched( pathname, excludes ) ); } private static boolean isMatched( String pathname, String[] patterns ) { for ( int i = patterns.length - 1; i >= 0; i-- ) { String pattern = patterns[i]; if ( SelectorUtils.matchPath( pattern, pathname ) ) { return true; } } return false; } public boolean couldHoldSelected( String pathname ) { for ( int i = includes.length - 1; i >= 0; i-- ) { String include = includes[i]; if ( SelectorUtils.matchPatternStart( include, pathname ) ) { return true; } } return includes.length <= 0; } public String toString() { return str; } } maven-clean-plugin-2.5/src/main/java/org/apache/maven/plugin/clean/Cleaner.java0000644000175000017500000002315011431504035026735 0ustar ebourgebourgpackage org.apache.maven.plugin.clean; /* * 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 org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.util.Os; /** * Cleans directories. * * @author Benjamin Bentmann */ class Cleaner { private static final boolean ON_WINDOWS = Os.isFamily( Os.FAMILY_WINDOWS ); private final Logger logDebug; private final Logger logInfo; private final Logger logVerbose; private final Logger logWarn; /** * Creates a new cleaner. * * @param log The logger to use, may be null to disable logging. * @param verbose Whether to perform verbose logging. */ public Cleaner( final Log log, boolean verbose ) { logDebug = ( log == null || !log.isDebugEnabled() ) ? null : new Logger() { public void log( CharSequence message ) { log.debug( message ); } }; logInfo = ( log == null || !log.isInfoEnabled() ) ? null : new Logger() { public void log( CharSequence message ) { log.info( message ); } }; logWarn = ( log == null || !log.isWarnEnabled() ) ? null : new Logger() { public void log( CharSequence message ) { log.warn( message ); } }; logVerbose = verbose ? logInfo : logDebug; } /** * Deletes the specified directories and its contents. * * @param basedir The directory to delete, must not be null. Non-existing directories will be silently * ignored. * @param selector The selector used to determine what contents to delete, may be null to delete * everything. * @param followSymlinks Whether to follow symlinks. * @param failOnError Whether to abort with an exception in case a selected file/directory could not be deleted. * @param retryOnError Whether to undertake additional delete attempts in case the first attempt failed. * @throws IOException If a file/directory could not be deleted and failOnError is true. */ public void delete( File basedir, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError ) throws IOException { if ( !basedir.isDirectory() ) { if ( !basedir.exists() ) { if ( logDebug != null ) { logDebug.log( "Skipping non-existing directory " + basedir ); } return; } throw new IOException( "Invalid base directory " + basedir ); } if ( logInfo != null ) { logInfo.log( "Deleting " + basedir + ( selector != null ? " (" + selector + ")" : "" ) ); } File file = followSymlinks ? basedir : basedir.getCanonicalFile(); delete( file, "", selector, followSymlinks, failOnError, retryOnError ); } /** * Deletes the specified file or directory. * * @param file The file/directory to delete, must not be null. If followSymlinks is * false, it is assumed that the parent file is canonical. * @param pathname The relative pathname of the file, using {@link File#separatorChar}, must not be * null. * @param selector The selector used to determine what contents to delete, may be null to delete * everything. * @param followSymlinks Whether to follow symlinks. * @param failOnError Whether to abort with an exception in case a selected file/directory could not be deleted. * @param retryOnError Whether to undertake additional delete attempts in case the first attempt failed. * @return The result of the cleaning, never null. * @throws IOException If a file/directory could not be deleted and failOnError is true. */ private Result delete( File file, String pathname, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError ) throws IOException { Result result = new Result(); boolean isDirectory = file.isDirectory(); if ( isDirectory ) { if ( selector == null || selector.couldHoldSelected( pathname ) ) { File canonical = followSymlinks ? file : file.getCanonicalFile(); if ( followSymlinks || file.equals( canonical ) ) { String[] filenames = canonical.list(); if ( filenames != null ) { String prefix = ( pathname.length() > 0 ) ? pathname + File.separatorChar : ""; for ( int i = filenames.length - 1; i >= 0; i-- ) { String filename = filenames[i]; File child = new File( canonical, filename ); result.update( delete( child, prefix + filename, selector, followSymlinks, failOnError, retryOnError ) ); } } } else if ( logDebug != null ) { logDebug.log( "Not recursing into symlink " + file ); } } else if ( logDebug != null ) { logDebug.log( "Not recursing into directory without included files " + file ); } } if ( !result.excluded && ( selector == null || selector.isSelected( pathname ) ) ) { if ( logVerbose != null ) { if ( isDirectory ) { logVerbose.log( "Deleting directory " + file ); } else if ( file.exists() ) { logVerbose.log( "Deleting file " + file ); } else { logVerbose.log( "Deleting dangling symlink " + file ); } } result.failures += delete( file, failOnError, retryOnError ); } else { result.excluded = true; } return result; } /** * Deletes the specified file, directory. If the path denotes a symlink, only the link is removed, its target is * left untouched. * * @param file The file/directory to delete, must not be null. * @param failOnError Whether to abort with an exception in case the file/directory could not be deleted. * @param retryOnError Whether to undertake additional delete attempts in case the first attempt failed. * @return 0 if the file was deleted, 1 otherwise. * @throws IOException If a file/directory could not be deleted and failOnError is true. */ private int delete( File file, boolean failOnError, boolean retryOnError ) throws IOException { if ( !file.delete() ) { boolean deleted = false; if ( retryOnError ) { if ( ON_WINDOWS ) { // try to release any locks held by non-closed files System.gc(); } int[] delays = { 50, 250, 750 }; for ( int i = 0; !deleted && i < delays.length; i++ ) { try { Thread.sleep( delays[i] ); } catch ( InterruptedException e ) { // ignore } deleted = file.delete() || !file.exists(); } } else { deleted = !file.exists(); } if ( !deleted ) { if ( failOnError ) { throw new IOException( "Failed to delete " + file ); } else { if ( logWarn != null ) { logWarn.log( "Failed to delete " + file ); } return 1; } } } return 0; } private static class Result { public int failures; public boolean excluded; public void update( Result result ) { failures += result.failures; excluded |= result.excluded; } } private static interface Logger { public void log( CharSequence message ); } } maven-clean-plugin-2.5/src/main/java/org/apache/maven/plugin/clean/Selector.java0000644000175000017500000000345111322421205027142 0ustar ebourgebourgpackage org.apache.maven.plugin.clean; /* * 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. */ /** * Determines whether a path is selected for deletion. The pathnames used for method parameters will be relative to some * base directory and use {@link java.io.File#separatorChar} as separator. * * @author Benjamin Bentmann */ interface Selector { /** * Determines whether a path is selected for deletion. * * @param pathname The pathname to test, must not be null. * @return true if the given path is selected for deletion, false otherwise. */ boolean isSelected( String pathname ); /** * Determines whether a directory could contain selected paths. * * @param pathname The directory pathname to test, must not be null. * @return true if the given directory might contain selected paths, false if the * directory will definitively not contain selected paths.. */ boolean couldHoldSelected( String pathname ); } maven-clean-plugin-2.5/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java0000644000175000017500000002011611460606631027241 0ustar ebourgebourgpackage org.apache.maven.plugin.clean; /* * 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.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import java.io.File; import java.io.IOException; /** * Goal which cleans the build. * *

This attempts to clean a project's working directory of the files that * were generated at build-time. By default, it discovers and deletes the * directories configured in project.build.directory, * project.build.outputDirectory, * project.build.testOutputDirectory, and * project.reporting.outputDirectory.

* *

Files outside the default may also be included in the deletion by * configuring the filesets tag.

* * @author Emmanuel Venisse * @version $Id: CleanMojo.java 1026638 2010-10-23 16:30:17Z bentmann $ * @goal clean * @threadSafe * @since 2.0 * @see org.apache.maven.plugin.clean.Fileset */ public class CleanMojo extends AbstractMojo { /** * This is where build results go. * * @parameter default-value="${project.build.directory}" * @required * @readonly */ private File directory; /** * This is where compiled classes go. * * @parameter default-value="${project.build.outputDirectory}" * @required * @readonly */ private File outputDirectory; /** * This is where compiled test classes go. * * @parameter default-value="${project.build.testOutputDirectory}" * @required * @readonly */ private File testOutputDirectory; /** * This is where the site plugin generates its pages. * * @parameter default-value="${project.reporting.outputDirectory}" * @required * @readonly * @since 2.1.1 */ private File reportDirectory; /** * Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's * global debug flag (compare command line switch -X). * * @parameter expression="${clean.verbose}" * @since 2.1 */ private Boolean verbose; /** * The list of file sets to delete, in addition to the default directories. For example: *
     * <filesets>
     *   <fileset>
     *     <directory>src/main/generated</directory>
     *     <followSymlinks>false</followSymlinks>
     *     <useDefaultExcludes>true</useDefaultExcludes>
     *     <includes>
     *       <include>*.java</include>
     *     </includes>
     *     <excludes>
     *       <exclude>Template*</exclude>
     *     </excludes>
     *   </fileset>
     * </filesets>
     * 
* * @parameter * @since 2.1 */ private Fileset[] filesets; /** * Sets whether the plugin should follow symbolic links while deleting files from the default output directories of * the project. Not following symlinks requires more IO operations and heap memory, regardless whether symlinks are * actually present. So projects with a huge output directory that knowingly does not contain symlinks can improve * performance by setting this parameter to true. * * @parameter expression="${clean.followSymLinks}" default-value="false" * @since 2.1 */ private boolean followSymLinks; /** * Disables the plugin execution. * * @parameter expression="${clean.skip}" default-value="false" * @since 2.2 */ private boolean skip; /** * Indicates whether the build will continue even if there are clean errors. * * @parameter expression="${maven.clean.failOnError}" default-value="true" * @since 2.2 */ private boolean failOnError; /** * Indicates whether the plugin should undertake additional attempts (after a short delay) to delete a file if the * first attempt failed. This is meant to help deleting files that are temporarily locked by third-party tools like * virus scanners or search indexing. * * @parameter expression="${maven.clean.retryOnError}" default-value="true" * @since 2.4.2 */ private boolean retryOnError; /** * Disables the deletion of the default output directories configured for a project. If set to true, * only the files/directories selected via the parameter {@link #filesets} will be deleted. * * @parameter expression="${clean.excludeDefaultDirectories}" default-value="false" * @since 2.3 */ private boolean excludeDefaultDirectories; /** * Deletes file-sets in the following project build directory order: (source) directory, output directory, test * directory, report directory, and then the additional file-sets. * * @see org.apache.maven.plugin.Mojo#execute() * @throws MojoExecutionException When a directory failed to get deleted. */ public void execute() throws MojoExecutionException { if ( skip ) { getLog().info( "Clean is skipped." ); return; } Cleaner cleaner = new Cleaner( getLog(), isVerbose() ); try { File[] directories = getDirectories(); for ( int i = 0; i < directories.length; i++ ) { File directory = directories[i]; if ( directory != null ) { cleaner.delete( directory, null, followSymLinks, failOnError, retryOnError ); } } if ( filesets != null ) { for ( int i = 0; i < filesets.length; i++ ) { Fileset fileset = filesets[i]; if ( fileset.getDirectory() == null ) { throw new MojoExecutionException( "Missing base directory for " + fileset ); } GlobSelector selector = new GlobSelector( fileset.getIncludes(), fileset.getExcludes(), fileset.isUseDefaultExcludes() ); cleaner.delete( fileset.getDirectory(), selector, fileset.isFollowSymlinks(), failOnError, retryOnError ); } } } catch ( IOException e ) { throw new MojoExecutionException( "Failed to clean project: " + e.getMessage(), e ); } } /** * Indicates whether verbose output is enabled. * * @return true if verbose output is enabled, false otherwise. */ private boolean isVerbose() { return ( verbose != null ) ? verbose.booleanValue() : getLog().isDebugEnabled(); } /** * Gets the directories to clean (if any). The returned array may contain null entries. * * @return The directories to clean or an empty array if none, never null. */ private File[] getDirectories() { File[] directories; if ( excludeDefaultDirectories ) { directories = new File[0]; } else { directories = new File[] { directory, outputDirectory, testOutputDirectory, reportDirectory }; } return directories; } } maven-clean-plugin-2.5/src/main/java/org/apache/maven/plugin/clean/Fileset.java0000644000175000017500000000517311460604662026775 0ustar ebourgebourgpackage org.apache.maven.plugin.clean; /* * 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.util.Arrays; /** * Customizes the string representation of * org.apache.maven.shared.model.fileset.FileSet to return the * included and excluded files from the file-set's directory. Specifically, * "file-set: [directory] (included: [included files], * excluded: [excluded files])" * * @version $Id: Fileset.java 1026633 2010-10-23 16:13:38Z bentmann $ * @since 2.1 */ public class Fileset { private File directory; private String[] includes; private String[] excludes; private boolean followSymlinks; private boolean useDefaultExcludes; public File getDirectory() { return directory; } public String[] getIncludes() { return ( includes != null ) ? includes : new String[0]; } public String[] getExcludes() { return ( excludes != null ) ? excludes : new String[0]; } public boolean isFollowSymlinks() { return followSymlinks; } public boolean isUseDefaultExcludes() { return useDefaultExcludes; } /** * Retrieves the included and excluded files from this file-set's directory. * Specifically, "file-set: [directory] (included: * [included files], excluded: [excluded files])" * * @return The included and excluded files from this file-set's directory. * Specifically, "file-set: [directory] (included: * [included files], excluded: [excluded files])" * @see java.lang.Object#toString() */ public String toString() { return "file set: " + getDirectory() + " (included: " + Arrays.asList( getIncludes() ) + ", excluded: " + Arrays.asList( getExcludes() ) + ")"; } }