Skip to content

Commit bcab734

Browse files
committed
U enhanced module dependency analysis v0.8.7
1 parent 9b56ea5 commit bcab734

File tree

9 files changed

+229
-54
lines changed

9 files changed

+229
-54
lines changed

README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ And the following `plugin` tag to your `pom.xml`.
3838
<plugin>
3939
<groupId>fvarrui.maven</groupId>
4040
<artifactId>javapackager</artifactId>
41-
<version>0.8.6</version>
41+
<version>0.8.7</version>
4242
<executions>
4343
<execution>
4444
<phase>package</phase>
@@ -54,6 +54,11 @@ And the following `plugin` tag to your `pom.xml`.
5454
<param>folder path</param>
5555
<param>...</param>
5656
</additionalResources>
57+
<additionalModules>
58+
<param>module1</param>
59+
<param>module2</param>
60+
<param>...</param>
61+
</additionalModules>
5762
<generateInstaller>true|false</generateInstaller>
5863
[...]
5964
</configuration>
@@ -64,24 +69,24 @@ And the following `plugin` tag to your `pom.xml`.
6469

6570
Where:
6671

67-
| Property | Mandatory | Default value | Description |
68-
| --------------------------------- | --------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69-
| `mainClass` | Yes | `null` | Full path to your app main class. |
70-
| `bundleJre` | No | `false` | Embed a customized JRE with the app. |
71-
| `forceJreOptimization` | No | `false` | Although JDK version < 13, it will try to reduce the bundled JRE. |
72-
| `jrePath` | No | `""` | 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. |
73-
| `moduleDependenceAnalysisOption` | No | `"--list-deps"` | When generating a customized JRE, this option allows to specify a different Module dependence analysis option other than the default (--list-deps) for jdeps |
74-
| `additionalModules` | No | `""` | When generating a customized JRE, allows adding aditional modules other than the ones identified by jdeps before calling jlink. |
75-
| `administratorRequired` | No | `false` | If true, app will run with administrator privileges. |
76-
| `additionalResources` | No | [] | Additional files and folders to include in the bundled app. |
77-
| `generateInstaller` | No | `true` | Generate an installer for the app. |
78-
| `displayName` | No | `${project.name}` | App name to show. |
79-
| `iconFile` | No | `null` | Path to the app icon file (PNG, ICO or ICNS). |
80-
| `licenseFile` | No | `${project.licenses[0].url}` | Path to project license file. |
81-
| `url` | No | `null` | App website URL. |
82-
| `organizationName` | No | `${project.organization.name}` | Organization name. |
83-
| `organizationUrl` | No | `${project.organization.url}` | Organization website URL. |
84-
| `organizationEmail` | No | `null` | Organization email. |
72+
| Property | Mandatory | Default value | Description |
73+
| -------------------------------- | --------- | ------------------------------ | ------------------------------------------------------------ |
74+
| `mainClass` | Yes | `null` | Full path to your app main class. |
75+
| `bundleJre` | No | `false` | Embed a customized JRE with the app. |
76+
| `forceJreOptimization` | No | `false` | Although JDK version < 13, it will try to reduce the bundled JRE. |
77+
| `jrePath` | No | `""` | 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. |
78+
| `moduleDependenceAnalysisOption` | No | `"--list-deps"` | When generating a customized JRE, this option allows to specify a different Module dependence analysis option other than the default (`--list-deps`) for `jdeps`. :warning: **DEPRECATED since v0.8.7** |
79+
| `additionalModules` | No | [] | When generating a customized JRE, allows adding aditional modules other than the ones identified by `jdeps` before calling `jlink`. |
80+
| `administratorRequired` | No | `false` | If `true`, app will run with administrator privileges. |
81+
| `additionalResources` | No | [] | Additional files and folders to include in the bundled app. |
82+
| `generateInstaller` | No | `true` | Generate an installer for the app. |
83+
| `displayName` | No | `${project.name}` | App name to show. |
84+
| `iconFile` | No | `null` | Path to the app icon file (PNG, ICO or ICNS). |
85+
| `licenseFile` | No | `${project.licenses[0].url}` | Path to project license file. |
86+
| `url` | No | `null` | App website URL. |
87+
| `organizationName` | No | `${project.organization.name}` | Organization name. |
88+
| `organizationUrl` | No | `${project.organization.url}` | Organization website URL. |
89+
| `organizationEmail` | No | `null` | Organization email. |
8590

8691
Some assets, such as application icons, could be located in `assets` folder organized by platform, and so it would not be necessary to specify the `iconFile` property:
8792

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>fvarrui.maven</groupId>
77
<artifactId>javapackager</artifactId>
8-
<version>0.8.6</version>
8+
<version>0.8.7</version>
99
<packaging>maven-plugin</packaging>
1010

1111
<name>JavaPackager Maven Plugin</name>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
2-
#Wed Jan 08 14:37:22 GMT 2020
2+
#Wed Jan 08 21:02:00 GMT 2020
33
javapackager-0.8.6.jar>=
44
javapackager-0.8.6.pom>=
809 Bytes
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
2+
#Thu Jan 09 11:01:56 GMT 2020
3+
javapackager-0.8.7.pom>=
4+
javapackager-0.8.7.jar>=
Binary file not shown.
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>fvarrui.maven</groupId>
7+
<artifactId>javapackager</artifactId>
8+
<version>0.8.7</version>
9+
<packaging>maven-plugin</packaging>
10+
11+
<name>JavaPackager Maven Plugin</name>
12+
13+
<url>https://github.com/fvarrui/javapackager</url>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.source>1.8</maven.compiler.source>
18+
<maven.compiler.target>1.8</maven.compiler.target>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.apache.maven</groupId>
24+
<artifactId>maven-plugin-api</artifactId>
25+
<version>3.6.0</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.apache.maven.plugin-tools</groupId>
29+
<artifactId>maven-plugin-annotations</artifactId>
30+
<version>3.6.0</version>
31+
<scope>provided</scope>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.codehaus.plexus</groupId>
35+
<artifactId>plexus-utils</artifactId>
36+
<version>3.1.1</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>junit</groupId>
40+
<artifactId>junit</artifactId>
41+
<version>4.12</version>
42+
<scope>test</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.twdata.maven</groupId>
46+
<artifactId>mojo-executor</artifactId>
47+
<version>2.3.0</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.apache.commons</groupId>
51+
<artifactId>commons-lang3</artifactId>
52+
<version>3.9</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>commons-io</groupId>
56+
<artifactId>commons-io</artifactId>
57+
<version>2.6</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.apache.velocity</groupId>
61+
<artifactId>velocity-engine-core</artifactId>
62+
<version>2.0</version>
63+
</dependency>
64+
</dependencies>
65+
66+
<build>
67+
<plugins>
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-plugin-plugin</artifactId>
71+
<version>3.6.0</version>
72+
<configuration>
73+
<goalPrefix>javapackager</goalPrefix>
74+
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
75+
</configuration>
76+
<executions>
77+
<execution>
78+
<id>help-goal</id>
79+
<goals>
80+
<goal>help</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-install-plugin</artifactId>
88+
<version>3.0.0-M1</version>
89+
<configuration>
90+
<localRepositoryPath>releases</localRepositoryPath>
91+
<file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
92+
</configuration>
93+
<executions>
94+
<execution>
95+
<id>release</id>
96+
<phase>install</phase>
97+
<goals>
98+
<goal>install-file</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
</plugins>
104+
</build>
105+
106+
<profiles>
107+
<profile>
108+
<id>run-its</id>
109+
<build>
110+
<plugins>
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-invoker-plugin</artifactId>
114+
<version>1.7</version>
115+
<configuration>
116+
<debug>true</debug>
117+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
118+
<pomIncludes>
119+
<pomInclude>*/pom.xml</pomInclude>
120+
</pomIncludes>
121+
<postBuildHookScript>verify</postBuildHookScript>
122+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
123+
<settingsFile>src/it/settings.xml</settingsFile>
124+
<goals>
125+
<goal>clean</goal>
126+
<goal>test-compile</goal>
127+
</goals>
128+
</configuration>
129+
<executions>
130+
<execution>
131+
<id>integration-test</id>
132+
<goals>
133+
<goal>install</goal>
134+
<goal>integration-test</goal>
135+
<goal>verify</goal>
136+
</goals>
137+
</execution>
138+
</executions>
139+
</plugin>
140+
</plugins>
141+
142+
</build>
143+
</profile>
144+
</profiles>
145+
146+
<distributionManagement>
147+
<repository>
148+
<id>repo</id>
149+
<url>file://${project.basedir}/releases</url>
150+
</repository>
151+
</distributionManagement>
152+
153+
</project>

releases/fvarrui/maven/javapackager/maven-metadata-local.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<groupId>fvarrui.maven</groupId>
44
<artifactId>javapackager</artifactId>
55
<versioning>
6-
<latest>0.8.6</latest>
7-
<release>0.8.6</release>
6+
<latest>0.8.7</latest>
7+
<release>0.8.7</release>
88
<versions>
99
<version>0.4.0</version>
1010
<version>0.5.0</version>
@@ -16,7 +16,8 @@
1616
<version>0.8.4</version>
1717
<version>0.8.5</version>
1818
<version>0.8.6</version>
19+
<version>0.8.7</version>
1920
</versions>
20-
<lastUpdated>20200108143722</lastUpdated>
21+
<lastUpdated>20200109110156</lastUpdated>
2122
</versioning>
2223
</metadata>

src/main/java/fvarrui/maven/plugin/javapackager/PackageMojo.java

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,8 @@ public class PackageMojo extends AbstractMojo {
126126
@Parameter(property = "additionalResources", required = false)
127127
private List<File> additionalResources;
128128

129-
@Parameter(defaultValue = "--print-module-deps", property = "moduleDependenceAnalysisOption", required = false)
130-
private String moduleDependenceAnalysisOption;
131-
132-
@Parameter(defaultValue = "", property = "additionalModules", required = false)
133-
private String additionalModules;
129+
@Parameter(property = "additionalModules", required = false)
130+
private List<String> additionalModules;
134131

135132
public PackageMojo() {
136133
super();
@@ -670,35 +667,50 @@ private String getRequiredModules(File libsFolder) throws MojoExecutionException
670667

671668
File jdeps = new File(System.getProperty("java.home"), "/bin/jdeps");
672669

673-
Object [] additionalArguments = {};
674-
675-
if (JavaUtils.getJavaMajorVersion() > 12) {
676-
additionalArguments = new Object [] { "--ignore-missing-deps" };
677-
}
670+
// File [] jarLibs = libsFolder.listFiles(new FilenameExtensionFilter("jar"));
671+
File jarLibs = new File(libsFolder, "*.jar");
678672

679-
File [] jarLibs = libsFolder.listFiles(new FilenameExtensionFilter("jar"));
680-
681-
String modules =
682-
ProcessUtils.execute(
683-
jdeps.getAbsolutePath(),
684-
"-q",
685-
additionalArguments,
686-
moduleDependenceAnalysisOption,
687-
"--multi-release", JavaUtils.getJavaMajorVersion(),
688-
jarLibs,
689-
jarFile
690-
);
691-
692-
String [] modulesArray = modules.split(",");
673+
List<String> modulesList;
693674

694-
List<String> modulesList = Arrays.asList(modulesArray).stream()
695-
.map(module -> module.trim())
696-
.filter(module -> !module.startsWith("JDK removed internal"))
697-
.collect(Collectors.toList());
675+
if (JavaUtils.getJavaMajorVersion() >= 13) {
676+
677+
String modules =
678+
ProcessUtils.execute(
679+
jdeps.getAbsolutePath(),
680+
"-q",
681+
"--ignore-missing-deps",
682+
"--print-module-deps",
683+
"--multi-release", JavaUtils.getJavaMajorVersion(),
684+
jarLibs,
685+
jarFile
686+
);
687+
688+
modulesList = Arrays.asList(modules.split(","))
689+
.stream()
690+
.collect(Collectors.toList());
691+
692+
693+
} else {
698694

699-
if (!StringUtils.isEmpty(additionalModules)) {
700-
modulesList.addAll(Arrays.asList(additionalModules.split(",")).stream().map(module->module.trim()).collect(Collectors.toList()));
695+
String modules =
696+
ProcessUtils.execute(
697+
jdeps.getAbsolutePath(),
698+
"-q",
699+
"--list-deps",
700+
"--multi-release", JavaUtils.getJavaMajorVersion(),
701+
jarLibs,
702+
jarFile
703+
);
704+
705+
modulesList = Arrays.asList(modules.split("\n"))
706+
.stream()
707+
.map(module -> module.trim())
708+
.filter(module -> !module.startsWith("JDK removed internal"))
709+
.collect(Collectors.toList());
710+
701711
}
712+
713+
modulesList.addAll(additionalModules);
702714

703715
return StringUtils.join(modulesList, ",");
704716
}

0 commit comments

Comments
 (0)