Skip to content

Commit

Permalink
Add workaround for computing the jar size
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarsotovalero committed Dec 6, 2020
1 parent f99d1cc commit 7d6b4ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}


/* Build Maven model to manipulate the pom */
Model model;
FileReader reader;
Expand All @@ -190,7 +189,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}


/* Copy direct dependencies locally */
try {
MavenInvoker.runCommand("mvn dependency:copy-dependencies -DoutputDirectory=" +
Expand All @@ -200,6 +198,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}

// TODO remove this workaround later
if (new File(project.getBuild().getDirectory() + File.separator + "libs").exists()) {
try {
FileUtils.copyDirectory(new File(project.getBuild().getDirectory() + File.separator + "libs"),
new File(project.getBuild().getDirectory() + File.separator + "dependency")
);
} catch (IOException e) {
getLog().error("Error copying directory libs to dependency");
}
}

/* Get the size of all the dependencies */
Map<String, Long> sizeOfDependencies = new HashMap<>();
Expand Down Expand Up @@ -527,7 +535,7 @@ private String getSize(String dependency, Map<String, Long> sizeOfDependencies)
return FileUtils.byteCountToDisplaySize(sizeOfDependencies.get(dep));
} else {
// The size cannot be obtained.
return "unknown";
return "size unknown";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

@Slf4j
public final class MavenInvoker {

private MavenInvoker() {
}

Expand Down

0 comments on commit 7d6b4ce

Please sign in to comment.