Skip to content

Commit cb2912c

Browse files
committed
replaced default jdkVersion 17 with latest
1 parent 1b4dd9a commit cb2912c

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
175175
| `forceInstaller` | :x: | `false` | If `true`, skips operating system check when generating installers. |
176176
| `nativeImage` | :x: | `false` | If `true`, generates a native-image. Note that `jdkVendor` must be set to `graalvm` for this to work. |
177177
| `generateInstaller` | :x: | `true` | Generates an installer for the app. |
178-
| `jdkVersion` | :x: | `17` | JDK version to download and use. Available versions for [adoptium](https://api.adoptium.net/v3/info/available_releases). |
178+
| `jdkVersion` | :x: | `latest` | JDK version to download and use. The latest version is used by default. See all available versions here: [adoptium](https://api.adoptium.net/v3/info/available_releases). |
179179
| `jdkVendor` | :x: | `adoptium` | JDK vendor to download the JDK from. Currently supported: `adoptium` |
180180
| `jdkPath` | :x: | `null` | If null downloads (if necessary and also updates it if needed) the right JDK for the selected platform and sets this value to `<temp-dir>/jdk/win` or `<temp-dir>/jdk/linux` or `<temp-dir>/jdk/mac`. The downloaded JDK will be used to generate a customized JRE. |
181181
| `jreDirectoryName` | :x: | `"jre"` | Bundled JRE directory name. |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.maven.plugins.annotations.ResolutionScope;
1515
import org.apache.maven.project.MavenProject;
1616

17+
import java.io.IOException;
1718
import java.util.Map;
1819

1920
import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment;
@@ -30,6 +31,9 @@ public class MavenPackageTask extends PackageTask implements Mojo, ContextEnable
3031
private Log log;
3132
private Map pluginContext;
3233

34+
public MavenPackageTask() throws IOException {
35+
}
36+
3337
@Override
3438
public void execute() throws MojoExecutionException, MojoFailureException {
3539
Context.setContext(

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import io.github.fvarrui.javapackager.model.*;
44
import io.github.fvarrui.javapackager.packagers.PackagerFactory;
5+
import io.github.fvarrui.javapackager.utils.updater.AdoptV3API;
56
import org.apache.commons.lang3.StringUtils;
67
import org.apache.maven.plugins.annotations.Parameter;
78
import org.gradle.api.tasks.*;
89

910
import java.io.File;
11+
import java.io.IOException;
1012
import java.util.ArrayList;
1113
import java.util.HashMap;
1214
import java.util.List;
@@ -349,7 +351,7 @@ public class PackageTask {
349351
@Optional
350352
protected Scripts scripts;
351353

352-
public PackageTask() {
354+
public PackageTask() throws IOException {
353355
//this.outputDirectory = (isGradle ? gradleProject.getBuildDir() : new File("${project.build.directory}"));
354356
this.platform = Platform.getCurrentPlatform();
355357
this.bundleJre = true;
@@ -378,7 +380,7 @@ public PackageTask() {
378380
this.customizedJre = true;
379381
this.jrePath = null;
380382
this.jdkPath = null;
381-
this.jdkVersion = "17";
383+
this.jdkVersion = new AdoptV3API().getLatestRelease();
382384
this.jdkVendor = "adoptium";
383385
this.additionalResources = new ArrayList<>();
384386
this.modules = new ArrayList<>();

src/main/java/io/github/fvarrui/javapackager/utils/updater/AdoptV3API.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package io.github.fvarrui.javapackager.utils.updater;
1010

1111
import com.google.gson.JsonArray;
12+
import com.google.gson.JsonElement;
1213
import com.google.gson.JsonObject;
1314

1415
import java.io.IOException;
@@ -17,9 +18,24 @@
1718
* Details here: https://api.adoptium.net/q/swagger-ui
1819
*/
1920
public class AdoptV3API {
20-
private final String START_DOWNLOAD_URL = "https://api.adoptium.net/v3/binary/version/";
21-
private final String START_RELEASES_URL = "https://api.adoptium.net/v3/info/release_versions?architecture=";
22-
private final String START_ASSETS_URL = "https://api.adoptium.net/v3/assets/version/";
21+
private final String BASE = "https://api.adoptium.net/v3";
22+
private final String START_DOWNLOAD_URL = BASE + "/binary/version/";
23+
private final String START_RELEASES_URL = BASE + "/info/release_versions?architecture=";
24+
private final String START_ASSETS_URL = BASE + "/assets/version/";
25+
26+
public JsonObject getAvailableReleases() throws IOException {
27+
return Json.fromUrlAsObject(BASE + "/info/available_releases");
28+
}
29+
30+
public String getLatestLTSRelease() throws IOException {
31+
JsonArray arr = getAvailableReleases().getAsJsonArray("available_lts_releases");
32+
return arr.get(arr.size()-1).getAsString();
33+
}
34+
35+
public String getLatestRelease() throws IOException {
36+
JsonArray arr = getAvailableReleases().getAsJsonArray("available_releases");
37+
return arr.get(arr.size()-1).getAsString();
38+
}
2339

2440
/**
2541
* Creates and returns a new url from the provided parameters. <br>

0 commit comments

Comments
 (0)