Extract logic for duplicate file removal so it can be shared

.. between Maven and Gradle plugins. Also fixed bug in recursive
scanning logic.

Really fixes gh-614
This commit is contained in:
Dave Syer
2014-04-02 11:02:06 +01:00
parent 5ded496dc3
commit 2b616fb7d9
4 changed files with 144 additions and 29 deletions

View File

@@ -38,6 +38,7 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.springframework.boot.loader.tools.AgentAttacher;
import org.springframework.boot.loader.tools.FileUtils;
import org.springframework.boot.loader.tools.MainClassFinder;
/**
@@ -197,23 +198,7 @@ public class RunMojo extends AbstractMojo {
for (Resource resource : this.project.getResources()) {
File directory = new File(resource.getDirectory());
urls.add(directory.toURI().toURL());
removeDuplicatesFromTarget(directory);
}
}
}
private void removeDuplicatesFromTarget(File directory) throws IOException {
if (directory.isDirectory()) {
for (String name : directory.list()) {
File targetFile = new File(this.classesDirectory, name);
if (targetFile.exists() && targetFile.canWrite()) {
if (!targetFile.isDirectory()) {
targetFile.delete();
}
else {
removeDuplicatesFromTarget(targetFile);
}
}
FileUtils.removeDuplicatesFromCopy(this.classesDirectory, directory);
}
}
}