Skip to content

Commit d99928e

Browse files
committed
U add comments
1 parent 1990101 commit d99928e

File tree

3 files changed

+93
-19
lines changed

3 files changed

+93
-19
lines changed

.classpath

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
</classpathentry>
1414
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
1515
<attributes>
16-
<attribute name="module" value="true"/>
1716
<attribute name="maven.pomderived" value="true"/>
1817
</attributes>
1918
</classpathentry>
@@ -27,5 +26,18 @@
2726
<attribute name="optional" value="true"/>
2827
</attributes>
2928
</classpathentry>
29+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
30+
<attributes>
31+
<attribute name="optional" value="true"/>
32+
<attribute name="maven.pomderived" value="true"/>
33+
<attribute name="test" value="true"/>
34+
</attributes>
35+
</classpathentry>
36+
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
37+
<attributes>
38+
<attribute name="optional" value="true"/>
39+
<attribute name="test" value="true"/>
40+
</attributes>
41+
</classpathentry>
3042
<classpathentry kind="output" path="target/classes"/>
3143
</classpath>

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<maven.compiler.source>1.8</maven.compiler.source>
1616
<maven.compiler.target>1.8</maven.compiler.target>
17+
<line.separator>&#10;</line.separator>
1718
</properties>
1819

1920
<licenses>

src/main/java/io/github/fvarrui/javapackager/PackageMojo.java

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,72 +61,129 @@ public class PackageMojo extends AbstractMojo {
6161
// private variables
6262

6363
private ExecutionEnvironment env;
64-
6564
private Map<String, Object> info;
66-
67-
private Platform currentPlatform;
68-
65+
private Platform hostPlatform;
6966
private File debFile, appFolder, assetsFolder, jarFile, executable;
7067

7168
// plugin configuration properties
72-
69+
70+
/**
71+
* Output directory.
72+
*/
7373
@Parameter(defaultValue = "${project.build.directory}", property = "outputDirectory", required = false)
7474
private File outputDirectory;
7575

76+
/**
77+
* Path to project license file.
78+
*/
7679
@Parameter(property = "licenseFile", required = false)
7780
private File licenseFile;
7881

82+
/**
83+
* Path to the app icon file (PNG, ICO or ICNS).
84+
*/
7985
@Parameter(property = "iconFile", required = false)
8086
private File iconFile;
8187

88+
/**
89+
* Generates an installer for the app.
90+
*/
8291
@Parameter(defaultValue = "true", property = "generateInstaller", required = false)
8392
private Boolean generateInstaller;
8493

94+
/**
95+
* Full path to your app main class.
96+
*/
8597
@Parameter(defaultValue = "${exec.mainClass}", property = "mainClass", required = true)
8698
private String mainClass;
8799

100+
/**
101+
* App name.
102+
*/
88103
@Parameter(defaultValue = "${project.name}", property = "name", required = false)
89104
private String name;
90105

106+
/**
107+
* App name to show.
108+
*/
91109
@Parameter(defaultValue = "${project.name}", property = "displayName", required = false)
92110
private String displayName;
93111

112+
/**
113+
* Project version.
114+
*/
94115
@Parameter(defaultValue = "${project.version}", property = "version", required = false)
95116
private String version;
96117

118+
/**
119+
* Project description.
120+
*/
97121
@Parameter(defaultValue = "${project.description}", property = "description", required = false)
98122
private String description;
99123

124+
/**
125+
* App website URL.
126+
*/
100127
@Parameter(defaultValue = "${project.url}", property = "url", required = false)
101128
private String url;
102129

130+
/**
131+
* App will run as administrator (with elevated privileges).
132+
*/
103133
@Parameter(defaultValue = "false", property = "administratorRequired", required = false)
104134
private Boolean administratorRequired;
105135

136+
/**
137+
* Organization name.
138+
*/
106139
@Parameter(defaultValue = "${project.organization.name}", property = "organizationName", required = false)
107140
private String organizationName;
108141

142+
/**
143+
* Organization website URL.
144+
*/
109145
@Parameter(defaultValue = "${project.organization.url}", property = "organizationUrl", required = false)
110146
private String organizationUrl;
111147

148+
/**
149+
* Organization email.
150+
*/
112151
@Parameter(defaultValue = "", property = "organizationEmail", required = false)
113152
private String organizationEmail;
114153

154+
/**
155+
* Embeds a customized JRE with the app.
156+
*/
115157
@Parameter(defaultValue = "false", property = "bundleJre", required = false)
116158
private Boolean bundleJre;
117159

160+
/**
161+
* Generates a customized JRE, including only identified or specified modules. Otherwise, all modules will be included.
162+
*/
118163
@Parameter(defaultValue = "true", property = "customizedJre", required = false)
119164
private Boolean customizedJre;
120165

166+
/**
167+
* Path to JRE folder. If specified, it will bundle this JRE with the app, and won't generate a customized JRE. For Java 8 version or least.
168+
*/
121169
@Parameter(defaultValue = "", property = "jrePath", required = false)
122170
private String jrePath;
123171

172+
/**
173+
* Additional files and folders to include in the bundled app.
174+
*/
124175
@Parameter(property = "additionalResources", required = false)
125176
private List<File> additionalResources;
126177

178+
/**
179+
* Defines modules to customize the bundled JRE. Don't use jdeps to get module dependencies.
180+
*/
127181
@Parameter(property = "modules", required = false)
128182
private List<String> modules;
129183

184+
/**
185+
* Additional modules to the ones identified by jdeps or the specified with modules property.
186+
*/
130187
@Parameter(property = "additionalModules", required = false)
131188
private List<String> additionalModules;
132189

@@ -143,6 +200,9 @@ public class PackageMojo extends AbstractMojo {
143200
@Parameter(defaultValue = "auto", property = "platform", required = true)
144201
private Platform platform;
145202

203+
/**
204+
* Defines PATH environment variable in GNU/Linux and Mac OS X startup scripts.
205+
*/
146206
@Parameter(property = "envPath", required = false)
147207
private String envPath;
148208

@@ -201,11 +261,11 @@ public void execute() throws MojoExecutionException {
201261
}
202262

203263
// determines current platform
204-
currentPlatform = getCurrentPlatform();
264+
hostPlatform = getCurrentPlatform();
205265

206266
// determines target platform if not specified
207267
if (platform == null || platform == Platform.auto) {
208-
platform = currentPlatform;
268+
platform = hostPlatform;
209269
}
210270

211271
getLog().info("Packaging app for " + platform);
@@ -377,7 +437,7 @@ private Map<String, Object> getInfo() {
377437
* @throws MojoExecutionException
378438
*/
379439
private void generateRpmPackage() throws MojoExecutionException {
380-
if (!generateInstaller || currentPlatform != Platform.linux) return;
440+
if (!generateInstaller || hostPlatform != Platform.linux) return;
381441

382442
getLog().info("Generating RPM package...");
383443

@@ -462,7 +522,7 @@ private void createMacApp() throws MojoExecutionException {
462522
copyAdditionalResources(additionalResources, resourcesFolder);
463523

464524
// codesigns app folder
465-
if (currentPlatform == Platform.mac) {
525+
if (hostPlatform == Platform.mac) {
466526
CommandUtils.execute("codesign", "--force", "--deep", "--sign", "-", appFile);
467527
}
468528

@@ -580,7 +640,7 @@ private void createWindowsApp() throws MojoExecutionException {
580640
* @throws MojoExecutionException
581641
*/
582642
private void generateWindowsInstaller() throws MojoExecutionException {
583-
if (!generateInstaller || currentPlatform != Platform.windows) return;
643+
if (!generateInstaller || hostPlatform != Platform.windows) return;
584644

585645
getLog().info("Generating Windows installer...");
586646

@@ -603,7 +663,7 @@ private void generateWindowsInstaller() throws MojoExecutionException {
603663
* @throws MojoExecutionException
604664
*/
605665
private void generateDebPackage() throws MojoExecutionException {
606-
if (!generateInstaller || currentPlatform != Platform.linux) return;
666+
if (!generateInstaller || hostPlatform != Platform.linux) return;
607667

608668
getLog().info("Generating DEB package ...");
609669

@@ -691,7 +751,7 @@ private void generateDebPackage() throws MojoExecutionException {
691751
* @throws MojoExecutionException
692752
*/
693753
private void generateDmgImage() throws MojoExecutionException {
694-
if (!generateInstaller || currentPlatform != Platform.mac) return;
754+
if (!generateInstaller || hostPlatform != Platform.mac) return;
695755

696756
getLog().info("Generating DMG disk image file");
697757

@@ -715,9 +775,9 @@ private void generateDmgImage() throws MojoExecutionException {
715775
*/
716776
private void copyAllDependencies(File libsFolder) throws MojoExecutionException {
717777
if (copyDependencies != null && !copyDependencies) return;
718-
719-
getLog().info("Copying all dependencies to app folder ...");
720778

779+
getLog().info("Copying all dependencies to " + appFolder.getName() + " folder ...");
780+
721781
// invokes plugin to copy dependecies to app libs folder
722782
executeMojo(
723783
plugin(
@@ -728,10 +788,11 @@ private void copyAllDependencies(File libsFolder) throws MojoExecutionException
728788
goal("copy-dependencies"),
729789
configuration(
730790
element("outputDirectory", libsFolder.getAbsolutePath())
731-
),
791+
),
732792
env);
793+
733794
}
734-
795+
735796
/**
736797
* Bundle a Java Runtime Enrironment with the app.
737798
*
@@ -772,9 +833,9 @@ private boolean bundleJre(File jreFolder, File libsFolder) throws MojoExecutionE
772833

773834
throw new MojoExecutionException("Could not create a customized JRE due to JDK version is " + SystemUtils.JAVA_VERSION + ". Must use jrePath property to specify JRE location to be embedded");
774835

775-
} else if (platform != currentPlatform) {
836+
} else if (platform != hostPlatform) {
776837

777-
getLog().warn("Cannot create a customized JRE ... target platform (" + platform + ") is different than execution platform (" + currentPlatform + ")");
838+
getLog().warn("Cannot create a customized JRE ... target platform (" + platform + ") is different than execution platform (" + hostPlatform + ")");
778839

779840
info.put("bundleJre", false);
780841

0 commit comments

Comments
 (0)