Skip to content

Commit

Permalink
Allow single dependency used as application jar.
Browse files Browse the repository at this point in the history
(cherry picked from commit bcc1f34)
  • Loading branch information
akuhtz committed May 4, 2022
1 parent 429e364 commit 3d53f68
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,28 @@ private void copyAdditionalAppResources(MavenProject project, List<FileSet> addi
private void copyApplicationClasses(MavenProject project, File appJavaDirectory) throws MojoExecutionException {
this.getLog().info("Copy application classes to: " + appJavaDirectory.getAbsolutePath());
try {
if (StringUtils.isNotEmpty(this.getPlistConfiguration().JVMMainClassName)) {
this.copyClasspathApplicationClasses(project, new File(appJavaDirectory, "classpath"));
} else if (StringUtils.isNotEmpty(this.getPlistConfiguration().JVMMainModuleName)) {
this.copyModulesApplicationClasses(project, new File(appJavaDirectory, "modules"));
}
if (this.getAppConfiguration().isSingleDependencyAsApplicationJar() && project.getArtifacts().size() > 0) {
this.getLog().info("Copy single dependency as application jar: " + project.getArtifacts().iterator().next());
this.copySingleApplicationDependency(project, new File(appJavaDirectory, "classpath"));
}
else {
if (StringUtils.isNotEmpty(this.getPlistConfiguration().JVMMainClassName)) {
this.copyClasspathApplicationClasses(project, new File(appJavaDirectory, "classpath"));
} else if (StringUtils.isNotEmpty(this.getPlistConfiguration().JVMMainModuleName)) {
this.copyModulesApplicationClasses(project, new File(appJavaDirectory, "modules"));
}
}
} catch (IOException e) {
throw new MojoExecutionException("Cannot copy dependencies", e);
}
}

private void copySingleApplicationDependency(MavenProject project, File classpathDirectory) throws IOException {
ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout();
Artifact artifact = project.getArtifacts().iterator().next();
this.copyClasspathApplicationDependencyArtifact(artifact, classpathDirectory, repositoryLayout);
}

private void copyClasspathApplicationClasses(MavenProject project, File classpathDirectory) throws IOException {
ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout();
this.copyClasspathApplicationDependencyArtifact(project.getArtifact(), classpathDirectory, repositoryLayout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,13 @@ public void setIncludeDependencies(boolean includeDependencies) {
this.includeDependencies = includeDependencies;
}


@Parameter
public boolean singleDependencyAsApplicationJar = false;

public boolean isSingleDependencyAsApplicationJar() {
return this.singleDependencyAsApplicationJar;
}
public void setSingleDependencyAsApplicationJar(boolean singleDependencyAsApplicationJar) {
this.singleDependencyAsApplicationJar = singleDependencyAsApplicationJar;
}
}

0 comments on commit 3d53f68

Please sign in to comment.