Skip to content

Commit 0dd0875

Browse files
committed
fix runnable jar generation
1 parent f8a6ccd commit 0dd0875

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main/java/io/github/fvarrui/javapackager/maven/CreateRunnableJar.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.github.fvarrui.javapackager.packagers.ArtifactGenerator;
2323
import io.github.fvarrui.javapackager.packagers.Context;
2424
import io.github.fvarrui.javapackager.packagers.Packager;
25+
import io.github.fvarrui.javapackager.utils.FileUtils;
2526
import io.github.fvarrui.javapackager.utils.Logger;
2627
import io.github.fvarrui.javapackager.utils.MojoExecutorUtils;
2728

@@ -44,8 +45,8 @@ protected File doApply(Packager packager) {
4445
File outputDirectory = packager.getOutputDirectory();
4546
ExecutionEnvironment env = Context.getMavenContext().getEnv();
4647
Manifest manifest = packager.getManifest();
47-
48-
File jarFile = new File(outputDirectory, name + "-" + version + "-" + classifier + ".jar");
48+
String artifactId = env.getMavenProject().getArtifactId();
49+
File jarFile = new File(outputDirectory, artifactId + "-" + classifier + ".jar");
4950

5051
List<Element> archive = new ArrayList<>();
5152
archive.add(
@@ -86,18 +87,21 @@ protected File doApply(Packager packager) {
8687
configuration(
8788
element("classifier", classifier),
8889
element("archive", archive.toArray(new Element[archive.size()])),
89-
element("outputDirectory", jarFile.getParentFile().getAbsolutePath())
90+
element("outputDirectory", outputDirectory.getAbsolutePath())
9091
),
91-
env);
92-
92+
env
93+
);
94+
9395
} catch (MojoExecutionException e) {
9496

9597
Logger.error("Runnable jar creation failed! " + e.getMessage());
9698
throw new RuntimeException(e);
9799

98100
}
99101

100-
return jarFile;
102+
File finalJarFile = new File(outputDirectory, name + "-" + version + "-" + classifier + ".jar");
103+
FileUtils.rename(jarFile, finalJarFile.getName());
104+
return finalJarFile;
101105
}
102106

103107
}

0 commit comments

Comments
 (0)