diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java b/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java index 622d507..07283a9 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java @@ -78,7 +78,7 @@ private void addToCp(List 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); @@ -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()) || @@ -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 + '\'' + + '}'; + } + } diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java index 69df02f..a8ea5dc 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java @@ -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());