diff --git a/pom.xml b/pom.xml
index befdc5f..4581ac4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,6 +106,9 @@
descriptor
+
+ ban
+
help-descriptor
diff --git a/src/main/java/com/inteligr8/maven/ban/AbstractBanConfiguration.java b/src/main/java/com/inteligr8/maven/ban/AbstractBanConfiguration.java
index 418d354..14d7753 100644
--- a/src/main/java/com/inteligr8/maven/ban/AbstractBanConfiguration.java
+++ b/src/main/java/com/inteligr8/maven/ban/AbstractBanConfiguration.java
@@ -73,7 +73,7 @@ public abstract class AbstractBanConfiguration implements BanConfiguration {
downloader = new BanConfigurationDownloader(this.session, this.artifactResolver, url);
} else if (child.getName().equals("artifact")) {
Artifact artifact = new DefaultArtifact(child.getValue());
- if (artifact.getExtension() == null)
+ if (!"xml".equals(artifact.getExtension()))
artifact = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), "xml", artifact.getVersion());
ArtifactRequest request = new ArtifactRequest(artifact, this.session.getCurrentProject().getRemoteProjectRepositories(), null);
diff --git a/src/main/java/com/inteligr8/maven/ban/PurgeRepoMojo.java b/src/main/java/com/inteligr8/maven/ban/PurgeRepoMojo.java
index d544675..2ba8e9e 100644
--- a/src/main/java/com/inteligr8/maven/ban/PurgeRepoMojo.java
+++ b/src/main/java/com/inteligr8/maven/ban/PurgeRepoMojo.java
@@ -23,6 +23,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -90,10 +91,13 @@ public class PurgeRepoMojo extends AbstractMojo {
continue;
}
- Path groupPath = this.getGroupPath(afilter);
- List artifactPaths = this.getArtifactPaths(groupPath, afilter);
+ Path groupPath = this.resolveGroupPath(afilter);
+ if (groupPath == null)
+ continue;
+
+ List artifactPaths = this.resolveArtifactPaths(groupPath, afilter);
for (Path artifactPath : artifactPaths)
- includePaths.addAll(this.getVersionPaths(artifactPath, afilter.getVersionRange()));
+ includePaths.addAll(this.resolveVersionPaths(artifactPath, afilter.getVersionRange()));
}
this.getLog().debug("May be purging all files in " + includePaths.size() + " paths");
@@ -105,7 +109,7 @@ public class PurgeRepoMojo extends AbstractMojo {
StringBuilder regex = new StringBuilder();
if (afilter.getGroupId() != null) {
- regex.append('^').append(this.getGroupPath(afilter));
+ regex.append('^').append(this.resolveGroupPath(afilter));
} else if (afilter.getGroupIdRegex() != null) {
regex.append(afilter.getGroupIdRegex().replace("\\.", regexDirectorySeparator));
if (regex.charAt(0) != '^')
@@ -171,20 +175,39 @@ public class PurgeRepoMojo extends AbstractMojo {
return new BanConfigurationParser(this.session, this.artifactResolver, plugin);
}
- private Path getGroupPath(ArtifactFilter afilter) {
+ private Path resolveGroupPath(ArtifactFilter afilter) {
+ if (afilter.getGroupId() == null)
+ return null;
+
String[] pathElements = afilter.getGroupId().split("\\.");
Path groupPath = Paths.get("");
for (String pathElement : pathElements)
groupPath = groupPath.resolve(pathElement);
+
+ Path fullGroupPath = this.getRepositoryPath().resolve(groupPath);
+ if (!Files.exists(fullGroupPath)) {
+ this.getLog().debug("The group path does not exist, so nothing to purge: " + fullGroupPath);
+ return null;
+ }
+
return groupPath;
}
- private List getArtifactPaths(Path groupPath, ArtifactFilter afilter) throws IOException {
- if (afilter.getArtifactId() != null)
- return Arrays.asList(groupPath.resolve(afilter.getArtifactId()));
+ private List resolveArtifactPaths(Path groupPath, ArtifactFilter afilter) throws IOException {
+ Path repoPath = this.getRepositoryPath();
+
+ if (afilter.getArtifactId() != null) {
+ Path artifactPath = groupPath.resolve(afilter.getArtifactId());
+ Path fullArtifactPath = repoPath.resolve(artifactPath);
+ if (Files.exists(fullArtifactPath)) {
+ return Arrays.asList(artifactPath);
+ } else {
+ this.getLog().debug("The artifact path does not exist, so nothing to purge: " + fullArtifactPath);
+ return Collections.emptyList();
+ }
+ }
Pattern artifactPattern = afilter.getArtifactIdRegex() == null ? null : Pattern.compile(afilter.getArtifactIdRegex());
- Path repoPath = this.getRepositoryPath();
List paths = new LinkedList<>();
if (artifactPattern == null)
@@ -208,7 +231,7 @@ public class PurgeRepoMojo extends AbstractMojo {
return paths;
}
- private List getVersionPaths(Path artifactPath, VersionRange versionRange) throws IOException {
+ private List resolveVersionPaths(Path artifactPath, VersionRange versionRange) throws IOException {
Path repoPath = this.getRepositoryPath();
List paths = new LinkedList<>();