Skip to content

Commit 1253faa

Browse files
committed
build: Add instructions for Java modules
1 parent 4b60e1e commit 1253faa

File tree

5 files changed

+86
-4
lines changed

5 files changed

+86
-4
lines changed

README.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This repository shows how to configure link:https://github.com/features/actions[GitHub Actions] and link:https://jreleaser.org/[JReleaser] to:
44

55
* compile a helloworld app with bundled Java Runtimes using jlink for:
6+
** `linux_musl-x86_64`
67
** `linux-x86_64`
78
** `linux-aarch_64`
89
** `osx-x86_64`
@@ -11,3 +12,19 @@ This repository shows how to configure link:https://github.com/features/actions[
1112
** `windows-aarch_64`
1213
* assemble zip distributions with JReleaser
1314
* create rolling early-access releases with JReleaser on every push to `main` branch
15+
16+
There are two modes for packaging this application: classpath & modulepath.
17+
18+
*classpath*
19+
20+
1. `./mvnw verify`
21+
2. `./mvnw -Pjdks`
22+
3. `jreleaser assemble`
23+
24+
*modulepath*
25+
26+
1. `./mvnw verify`
27+
2. `./mvnw -Pjdks`
28+
3. `jreleaser assemble --config-file jreleaser-modules.yml`
29+
30+
In both cases the assembled archive is placed at `out/jreleaser/assemble/helloworld/jlink`.

jreleaser-modules.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
environment:
2+
properties:
3+
jdkPathPrefix: 'target/jdks'
4+
jdkFilePrefix: 'zulu17.32.13-ca-jdk17.0.2'
5+
6+
project:
7+
name: helloworld
8+
description: HelloWorld in Java
9+
longDescription: HelloWorld in Java
10+
links:
11+
homepage: https://github.com/jreleaser/helloworld-java-jlink
12+
authors:
13+
- Andres Almiray
14+
license: APACHE-2.0
15+
inceptionYear: 2023
16+
stereotype: cli
17+
java:
18+
version: 11
19+
groupId: org.jreleaser.examples
20+
artifactId: helloworld
21+
mainClass: org.jreleaser.examples.HelloWorld
22+
mainModule: org.jreleaser.examples
23+
24+
release:
25+
github:
26+
overwrite: true
27+
changelog:
28+
formatted: ALWAYS
29+
preset: conventional-commits
30+
contributors:
31+
format: '- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}'
32+
33+
assemble:
34+
jlink:
35+
helloworld:
36+
active: ALWAYS
37+
imageName: '{{distributionName}}-{{projectVersion}}'
38+
targetJdks:
39+
- path: '{{jdkPathPrefix}}/zulu17OsxIntel/{{jdkFilePrefix}}-macosx_x64/zulu-17.jdk/Contents/Home'
40+
platform: 'osx-x86_64'
41+
- path: '{{jdkPathPrefix}}/zulu17OsxArm/{{jdkFilePrefix}}-macosx_aarch64/zulu-17.jdk/Contents/Home'
42+
platform: 'osx-aarch_64'
43+
- path: '{{jdkPathPrefix}}/zulu17LinuxIntel/{{jdkFilePrefix}}-linux_x64'
44+
platform: 'linux-x86_64'
45+
- path: '{{jdkPathPrefix}}/zulu17LinuxMuslIntel/{{jdkFilePrefix}}-linux_musl_x64'
46+
platform: 'linux_musl-x86_64'
47+
- path: '{{jdkPathPrefix}}/zulu17LinuxArm/{{jdkFilePrefix}}-linux_aarch64'
48+
platform: 'linux-aarch_64'
49+
- path: '{{jdkPathPrefix}}/zulu17WindowsIntel/{{jdkFilePrefix}}-win_x64'
50+
platform: 'windows-x86_64'
51+
- path: '{{jdkPathPrefix}}/zulu17WindowsArm/{{jdkFilePrefix}}-win_aarch64'
52+
platform: 'windows-aarch_64'
53+
mainJar:
54+
path: 'target/{{distributionName}}-{{projectVersion}}.jar'

jreleaser.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ project:
1515
inceptionYear: 2023
1616
stereotype: cli
1717
java:
18+
version: 11
1819
groupId: org.jreleaser.examples
1920
artifactId: helloworld
2021
mainClass: org.jreleaser.examples.HelloWorld
21-
version: 11
2222

2323
release:
2424
github:
@@ -41,6 +41,8 @@ assemble:
4141
platform: 'osx-aarch_64'
4242
- path: '{{jdkPathPrefix}}/zulu17LinuxIntel/{{jdkFilePrefix}}-linux_x64'
4343
platform: 'linux-x86_64'
44+
- path: '{{jdkPathPrefix}}/zulu17LinuxMuslIntel/{{jdkFilePrefix}}-linux_musl_x64'
45+
platform: 'linux_musl-x86_64'
4446
- path: '{{jdkPathPrefix}}/zulu17LinuxArm/{{jdkFilePrefix}}-linux_aarch64'
4547
platform: 'linux-aarch_64'
4648
- path: '{{jdkPathPrefix}}/zulu17WindowsIntel/{{jdkFilePrefix}}-win_x64'
@@ -49,4 +51,3 @@ assemble:
4951
platform: 'windows-aarch_64'
5052
mainJar:
5153
path: 'target/{{distributionName}}-{{projectVersion}}.jar'
52-

pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<plugin>
6868
<groupId>org.apache.maven.plugins</groupId>
6969
<artifactId>maven-compiler-plugin</artifactId>
70-
<version>3.10.1</version>
70+
<version>3.11.0</version>
7171
</plugin>
7272
<plugin>
7373
<groupId>org.apache.maven.plugins</groupId>
@@ -92,9 +92,16 @@
9292
<plugin>
9393
<groupId>org.jreleaser</groupId>
9494
<artifactId>jdks-maven-plugin</artifactId>
95-
<version>1.4.0</version>
95+
<version>1.5.1</version>
9696
<configuration>
9797
<pkgs>
98+
<pkg>
99+
<name>zulu17LinuxMuslIntel</name>
100+
<platform>linux-x86_64</platform>
101+
<version>${jdk.version}</version>
102+
<libcType>musl</libcType>
103+
<archiveType>tar.gz</archiveType>
104+
</pkg>
98105
<pkg>
99106
<name>zulu17LinuxIntel</name>
100107
<platform>linux-x86_64</platform>

src/main/java/module-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module org.jreleaser.examples {
2+
exports org.jreleaser.examples;
3+
}

0 commit comments

Comments
 (0)