Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
0edac4fc37 | |||
f837e5d1c0 | |||
78e34d85e9 | |||
6e2a701c0d | |||
08498d4224 | |||
1c7997d85c | |||
9116d4bfd9 |
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<groupId>com.inteligr8</groupId>
|
<groupId>com.inteligr8</groupId>
|
||||||
<artifactId>ban-maven-plugin</artifactId>
|
<artifactId>ban-maven-plugin</artifactId>
|
||||||
<version>1.3.3</version>
|
<version>1.3.5</version>
|
||||||
<packaging>maven-plugin</packaging>
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
<name>Ban Dependencies Maven Plugin</name>
|
<name>Ban Dependencies Maven Plugin</name>
|
||||||
|
@@ -16,6 +16,7 @@ package com.inteligr8.maven.ban;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.DirectoryNotEmptyException;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
import java.nio.file.FileVisitor;
|
import java.nio.file.FileVisitor;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -281,7 +282,7 @@ public class PurgeRepoMojo extends AbstractMojo {
|
|||||||
|
|
||||||
private class DeleteNonMetadataVisitor implements FileVisitor<Path> {
|
private class DeleteNonMetadataVisitor implements FileVisitor<Path> {
|
||||||
|
|
||||||
private final Pattern versionPathPattern = Pattern.compile("/([^/]+)/([^/]+)$");
|
private final Pattern versionPathPattern = Pattern.compile("/([^/]+)/([^/]+)/[^/]+$");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||||
@@ -305,9 +306,12 @@ public class PurgeRepoMojo extends AbstractMojo {
|
|||||||
String version = matcher.group(2);
|
String version = matcher.group(2);
|
||||||
String includeName = artifactId + "-" + version;
|
String includeName = artifactId + "-" + version;
|
||||||
String excludeName = artifactId + "-" + version + ".pom";
|
String excludeName = artifactId + "-" + version + ".pom";
|
||||||
|
getLog().debug("artifact-version: " + includeName);
|
||||||
|
|
||||||
if (file.getFileName().toString().startsWith(includeName) &&
|
if (file.getFileName().toString().startsWith(includeName) &&
|
||||||
!file.getFileName().toString().startsWith(excludeName)) {
|
!file.getFileName().toString().startsWith(excludeName)) {
|
||||||
try {
|
try {
|
||||||
|
getLog().info("Deleting artifact: " + file);
|
||||||
Files.delete(file);
|
Files.delete(file);
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
getLog().debug(ie);
|
getLog().debug(ie);
|
||||||
@@ -328,6 +332,8 @@ public class PurgeRepoMojo extends AbstractMojo {
|
|||||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
||||||
try {
|
try {
|
||||||
Files.delete(dir);
|
Files.delete(dir);
|
||||||
|
} catch (DirectoryNotEmptyException dnee) {
|
||||||
|
getLog().debug("The folder will not be deleted as it is not empty: " + dir);
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
getLog().debug(ie);
|
getLog().debug(ie);
|
||||||
getLog().warn("The folder failed to delete: " + dir);
|
getLog().warn("The folder failed to delete: " + dir);
|
||||||
|
Reference in New Issue
Block a user