Skip to content

Commit

Permalink
Includes runtime artifacts in final class path, closes orphan-oss#5
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart authored and thomas3 committed Jul 8, 2015
1 parent d705285 commit 74d3ed5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void addToCp(List<String> cp, String cpStr) {
cp.addAll(Arrays.asList(cpStr.split("\\s*;\\s*")));
}

net.sf.launch4j.config.ClassPath toL4j(Set dependencies) {
net.sf.launch4j.config.ClassPath toL4j(Set dependencies, List runtimeDependencies) {
net.sf.launch4j.config.ClassPath ret = new net.sf.launch4j.config.ClassPath();
ret.setMainClass(mainClass);

Expand All @@ -89,6 +89,9 @@ net.sf.launch4j.config.ClassPath toL4j(Set dependencies) {
if (jarLocation == null) jarLocation = "";
else if ( ! jarLocation.endsWith("/")) jarLocation += "/";

// Add all runtime dependencies as we need them to run the wrapped jar
dependencies.addAll(runtimeDependencies);

for (Object dependency : dependencies) {
Artifact dep = (Artifact) dependency;
if (Artifact.SCOPE_COMPILE.equals(dep.getScope()) ||
Expand All @@ -108,4 +111,15 @@ net.sf.launch4j.config.ClassPath toL4j(Set dependencies) {
return ret;
}

@Override
public String toString() {
return "ClassPath{" +
"mainClass='" + mainClass + '\'' +
", addDependencies=" + addDependencies +
", jarLocation='" + jarLocation + '\'' +
", preCp='" + preCp + '\'' +
", postCp='" + postCp + '\'' +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void execute() throws MojoExecutionException {
c.setVariables(vars);

if (classPath != null) {
c.setClassPath(classPath.toL4j(dependencies));
c.setClassPath(classPath.toL4j(dependencies, project.getRuntimeArtifacts()));
}
if (jre != null) {
c.setJre(jre.toL4j());
Expand Down

0 comments on commit 74d3ed5

Please sign in to comment.