Author: vsiveton
Date: Wed Nov 14 05:24:50 2007
New Revision: 594869
URL: http://svn.apache.org/viewvc?rev=594869&view=rev
Log:
MCLEAN-27: fileset directory does not work as expected when cleaning "modules"
in sub-directories
o adds the subproject basedir in the fileset directory
o updated documentation
Modified:
maven/plugins/trunk/maven-clean-plugin/pom.xml
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/delete_additional_files.apt
Modified: maven/plugins/trunk/maven-clean-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clean-plugin/pom.xml?rev=594869&r1=594868&r2=594869&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clean-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-clean-plugin/pom.xml Wed Nov 14 05:24:50 2007
@@ -45,6 +45,11 @@
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
Modified:
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java?rev=594869&r1=594868&r2=594869&view=diff
==============================================================================
---
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
(original)
+++
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
Wed Nov 14 05:24:50 2007
@@ -21,8 +21,10 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.model.fileset.FileSet;
import org.apache.maven.shared.model.fileset.util.FileSetManager;
+import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.IOException;
@@ -53,6 +55,16 @@
extends AbstractMojo
{
/**
+ * The Maven Project Object
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ * @since 2.2
+ */
+ protected MavenProject project;
+
+ /**
* This is where build results go.
*
* @parameter expression="${project.build.directory}"
@@ -193,6 +205,17 @@
try
{
getLog().info( "Deleting " + fileset );
+
+ if ( !project.isExecutionRoot() )
+ {
+ String projectBasedir = StringUtils.replace(
project.getBasedir().getAbsolutePath(), "\\", "/" );
+ String filesetDir = StringUtils.replace(
fileset.getDirectory(), "\\", "/" );
+
+ if ( filesetDir.indexOf( projectBasedir ) == -1 )
+ {
+ fileset.setDirectory( projectBasedir + "/" +
filesetDir );
+ }
+ }
fileSetManager.delete( fileset );
}
Modified:
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/delete_additional_files.apt
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/delete_additional_files.apt?rev=594869&r1=594868&r2=594869&view=diff
==============================================================================
---
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/delete_additional_files.apt
(original)
+++
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/delete_additional_files.apt
Wed Nov 14 05:24:50 2007
@@ -4,7 +4,8 @@
Mike Perham
<[EMAIL PROTECTED]>
------
- June 20th, 2006
+ November 2007
+ ------
~~ Licensed to the Apache Software Foundation (ASF) under one
~~ or more contributor license agreements. See the NOTICE file
@@ -56,3 +57,18 @@
[...]
</build>
+---------
+
+ <<Note:>> The <<<directory>>> in the <<<fileset>>> is a relative path inside
a project, in other words,
+
++--------
+ <directory>some/relative/path</directory>
++--------
+
+ is equivalent to:
+
++--------
+ <directory>${basedir}/some/relative/path</directory>
++--------
+
+ 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.