|
34 | 34 | import java.util.Map.Entry;
|
35 | 35 | import java.util.Set;
|
36 | 36 |
|
| 37 | +import org.apache.commons.io.IOUtils; |
| 38 | +import org.apache.commons.io.FileUtils; |
37 | 39 | import org.apache.maven.archiver.MavenArchiveConfiguration;
|
38 | 40 | import org.apache.maven.archiver.MavenArchiver;
|
39 | 41 | import org.apache.maven.artifact.Artifact;
|
|
48 | 50 | import org.apache.tools.ant.Project;
|
49 | 51 | import org.apache.tools.ant.taskdefs.Java;
|
50 | 52 | import org.codehaus.plexus.archiver.jar.JarArchiver;
|
51 |
| -import org.codehaus.plexus.util.FileUtils; |
52 |
| -import org.codehaus.plexus.util.IOUtil; |
53 | 53 |
|
54 | 54 | /**
|
55 | 55 | *
|
@@ -617,22 +617,36 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
617 | 617 | try{
|
618 | 618 | FileUtils.deleteDirectory(tempLibraryjarsDir);
|
619 | 619 | } catch(IOException ignored){
|
620 |
| - // NO-OP |
| 620 | + throw new MojoFailureException("Deleting failed libraryJars directory", ignored); |
621 | 621 | }
|
622 | 622 | }
|
623 | 623 | tempLibraryjarsDir.mkdir();
|
624 | 624 | if (!tempLibraryjarsDir.exists()) {
|
625 | 625 | throw new MojoFailureException("Can't create temporary libraryJars directory: " + tempLibraryjarsDir.getAbsolutePath());
|
626 | 626 | }
|
| 627 | + // Use this subdirectory for all libraries that are files, and not directories themselves |
| 628 | + File commonDir = new File(tempLibraryjarsDir, "0"); |
| 629 | + commonDir.mkdir(); |
| 630 | + |
| 631 | + int directoryIndex = 1; |
627 | 632 | for (File libraryJar : libraryJars) {
|
628 | 633 | try {
|
629 |
| - FileUtils.copyFileToDirectory(libraryJar, tempLibraryjarsDir); |
| 634 | + log.debug("Copying library: " + libraryJar); |
| 635 | + if (libraryJar.isFile()) { |
| 636 | + FileUtils.copyFileToDirectory(libraryJar, commonDir); |
| 637 | + } else { |
| 638 | + File subDir = new File(tempLibraryjarsDir, String.valueOf(directoryIndex)); |
| 639 | + FileUtils.copyDirectory(libraryJar, subDir); |
| 640 | + args.add("-libraryjars"); |
| 641 | + args.add(fileToString(subDir)); |
| 642 | + } |
630 | 643 | } catch (IOException e) {
|
631 | 644 | throw new MojoFailureException("Can't copy to temporary libraryJars directory", e);
|
632 | 645 | }
|
| 646 | + directoryIndex++; |
633 | 647 | }
|
634 | 648 | args.add("-libraryjars");
|
635 |
| - args.add(fileToString(tempLibraryjarsDir)); |
| 649 | + args.add(fileToString(commonDir)); |
636 | 650 | }
|
637 | 651 |
|
638 | 652 | File mappingFile = new File(outputDirectory, mappingFileName);
|
@@ -718,7 +732,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
718 | 732 | applyMappingFile.getParentFile().mkdirs();
|
719 | 733 | FileOutputStream mappingFileOut = new FileOutputStream(applyMappingFile, true);
|
720 | 734 | try {
|
721 |
| - IOUtil.copy(mappingFileIn, mappingFileOut); |
| 735 | + IOUtils.copy(mappingFileIn, mappingFileOut); |
722 | 736 | } finally {
|
723 | 737 | mappingFileOut.close();
|
724 | 738 | }
|
@@ -945,9 +959,12 @@ private File getClasspathElement(Artifact artifact, MavenProject mavenProject) t
|
945 | 959 | project = (MavenProject) mavenProject.getProjectReferences().get(refId);
|
946 | 960 | }
|
947 | 961 | if (project != null) {
|
948 |
| - return new File(project.getBuild().getOutputDirectory()); |
| 962 | + File file = new File(project.getBuild().getOutputDirectory()); |
| 963 | + log.debug("Found directory: " + file.getAbsolutePath()); |
| 964 | + return file; |
949 | 965 | } else {
|
950 | 966 | File file = artifact.getFile();
|
| 967 | + log.debug("Found file: " + file.getAbsolutePath()); |
951 | 968 | if ((file == null) || (!file.exists())) {
|
952 | 969 | throw new MojoExecutionException("Dependency Resolution Required " + artifact);
|
953 | 970 | }
|
|
0 commit comments