Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 33fd761

Browse files
author
Guillaume Boué
committed
[MANTRUN-192] filterArtifacts in DependencyFilesetsTask includes entire maven.local.repository
When there are no artifacts after filtering, Ant will include by default everything under the local repository (since there are no include patterns). Therefore, in this case, we need to exclude everything explicitly. For performance reasons, we need to add a dummy file to the include patterns, otherwise Ant will still traverse the whole directory before applying the exclusions. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1799020 13f79535-47bb-0310-9956-ffa450edef68
1 parent 87b24ea commit 33fd761

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
<groupId>org.apache.maven.plugins.antrun</groupId>
27+
<artifactId>MANTRUN-192</artifactId>
28+
<packaging>pom</packaging>
29+
<version>1.0</version>
30+
<url>https://issues.apache.org/jira/browse/MANTRUN-192</url>
31+
<description>Checks that creating a FileSet of the project dependencies also works when there are no dependencies.</description>
32+
<build>
33+
<plugins>
34+
<plugin>
35+
<artifactId>maven-antrun-plugin</artifactId>
36+
<version>@pom.version@</version>
37+
<executions>
38+
<execution>
39+
<goals>
40+
<goal>run</goal>
41+
</goals>
42+
<phase>validate</phase>
43+
<configuration>
44+
<target>
45+
<dependencyfilesets />
46+
<property name="deps" refid="maven.project.dependencies"/>
47+
<fail message="Dependency list should have been empty: ${deps}">
48+
<condition>
49+
<not>
50+
<equals arg1="${deps}" arg2=""/>
51+
</not>
52+
</condition>
53+
</fail>
54+
</target>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
</project>

maven-antrun-plugin/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public void execute()
116116
ArtifactRepository localRepository = (ArtifactRepository) getProject().getReference( "maven.local.repository" );
117117
dependenciesFileSet.setDir( new File( localRepository.getBasedir() ) );
118118

119+
if ( depArtifacts.isEmpty() )
120+
{
121+
// For performance reasons in case of huge local repo, tell Ant to include a single thing, otherwise the
122+
// whole directory is scanned (even though ** is excluded).
123+
dependenciesFileSet.createInclude().setName( "." );
124+
dependenciesFileSet.createExclude().setName( "**" );
125+
}
126+
119127
for ( Artifact artifact : depArtifacts )
120128
{
121129
String relativeArtifactPath = localRepository.pathOf( artifact );

0 commit comments

Comments
 (0)