Skip to content

Commit 536c367

Browse files
authored
[MCLEAN-111] Fix fast delete feature for filesets (#32)
* Fix fast delete feature. * Add integration test for the fast delete feature. * Document the limitation of the fast delete method.
1 parent 4bb70fd commit 536c367

File tree

5 files changed

+105
-2
lines changed

5 files changed

+105
-2
lines changed

src/it/fast-delete/invoker.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = install clean -Dorg.slf4j.simpleLogger.showThreadName=true -X -e

src/it/fast-delete/pom.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
25+
<modelVersion>4.0.0</modelVersion>
26+
27+
<groupId>test</groupId>
28+
<artifactId>fast-delete</artifactId>
29+
<version>1.0-SNAPSHOT</version>
30+
31+
<name>Fast delete</name>
32+
<description>Check that fast delete is invoked.</description>
33+
34+
<properties>
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
</properties>
37+
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-clean-plugin</artifactId>
43+
<version>@project.version@</version>
44+
<configuration>
45+
<fast>true</fast>
46+
<fastDir>${project.basedir}${file.separator}.fastdir</fastDir>
47+
</configuration>
48+
</plugin>
49+
</plugins>
50+
</build>
51+
52+
</project>

src/it/fast-delete/verify.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
File buildLog = new File(basedir, 'build.log')
21+
return buildLog.text.contains('mvn-background-cleaner')

src/main/java/org/apache/maven/plugins/clean/CleanMojo.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,17 @@ public void execute() throws MojoExecutionException {
258258
if (fileset.getDirectory() == null) {
259259
throw new MojoExecutionException("Missing base directory for " + fileset);
260260
}
261-
GlobSelector selector = new GlobSelector(
262-
fileset.getIncludes(), fileset.getExcludes(), fileset.isUseDefaultExcludes());
261+
final String[] includes = fileset.getIncludes();
262+
final String[] excludes = fileset.getExcludes();
263+
final boolean useDefaultExcludes = fileset.isUseDefaultExcludes();
264+
final GlobSelector selector;
265+
if ((includes != null && includes.length != 0)
266+
|| (excludes != null && excludes.length != 0)
267+
|| useDefaultExcludes) {
268+
selector = new GlobSelector(includes, excludes, useDefaultExcludes);
269+
} else {
270+
selector = null;
271+
}
263272
cleaner.delete(
264273
fileset.getDirectory(), selector, fileset.isFollowSymlinks(), failOnError, retryOnError);
265274
}

src/site/apt/examples/delete_additional_files.apt.vm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,6 @@ Delete Additional Files Not Exposed to Maven
7373

7474
You could also define file set rules in a parent POM. In this case, the clean plugin adds the subproject
7575
basedir to the defined relative path.
76+
77+
<<Note:>> The <<<fast>>> delete method will not work for any <<<fileset>>> which defines any <<<includes>>>
78+
or <<<excludes>>>, or sets <<<followSymlinks>>> to <<<false>>>, or sets <<<useDefaultExcludes>>> to <<<true>>>.

0 commit comments

Comments
 (0)