-
Notifications
You must be signed in to change notification settings - Fork 12
L2p Service Migration v1.1.1 to v1.2.0 (Java 17)
This wiki page documents the required changes to update a las2peer service from v1.1.1 (or v1.1.2) to the first version of las2peer that supports Java 17 (v1.2.0).
The service should already be using Gradle. If this is not the case, please migrate from Ant to Gradle first.
Most of the services that followed the Gradle migration guide when las2peer v1.1.1 was released should be using Gradle 6.8. To work with Java 17, Gradle needs to be updated to version 7.2.
-
Before updating, you should run
./gradlew build --warning-mode=all
to see the deprecation warnings in the console. These warnings contain useful information helping to update your buildscript to be working with Gradle 7.2. Here are the changes that were necessary in the template-project:
- In the repositories, replace
jcenter()
withmavenCentral()
. - In the dependencies, replace
compileOnly
withimplementation
. - In the configurations, replace
testCompile.extendsFrom compileOnly
withtestImplementation.extendsFrom implementation
. - In the application configuration, replace
with
mainClassName = "i5.las2peer.tools.L2pNodeLauncher"
mainClass.set("i5.las2peer.tools.L2pNodeLauncher")
- Replace
with
tasks.withType(Jar) { destinationDir = file("$projectDir/export/jars") }
tasks.withType(Jar) { destinationDirectory = file("$projectDir/export/jars") }
- When using Jacoco, update the toolVersion to 0.8.7.
- In the repositories, replace
-
Update Gradle plugins (if any plugins are used).
-
Update the Gradle wrapper by running
gradle wrapper --gradle-version 7.2
- Update the GitHub workflow files (if there are any) to use Java 17.
- Set
java.version
to 17 ingradle.properties
file. - Set
core.version
to 1.2.0 ingradle.properties
file. - Update the Java base image version used in the Dockerfile.
- If you run a CI pipeline, don't forget to also update the java version to 17
The build.gradle
file contains a task named startscripts
that generates the files start_network.sh
and start_network.bat
.
These startscripts contain the Java command which is starting the service.
For las2peer to work with Java 17, we need to use the --add-opens
argument in the start command to open the packages java.lang
and java.util
.
You can just replace the existing startscripts
task with the following one:
task startscripts {
new File("$rootDir/bin", "start_network.sh").text = """#!/bin/bash
# this script is autogenerated by 'gradle startscripts'
# it starts a las2peer node providing the service '${project.property('service.name')}.${project.property('service.class')}' of this project
# pls execute it from the root folder of your deployment, e. g. ./bin/start_network.sh
java -cp "lib/*" --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED i5.las2peer.tools.L2pNodeLauncher --port 9011 --service-directory service uploadStartupDirectory startService\\(\\'${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}\\'\\) startWebConnector interactive
"""
new File("$rootDir/bin", "start_network.bat").text = """:: this script is autogenerated by 'gradle startscripts'
:: it starts a las2peer node providing the service '${project.property('service.name')}.${project.property('service.class')}' of this project
:: pls execute it from the bin folder of your deployment by double-clicking on it
%~d0
cd %~p0
cd ..
set BASE=%CD%
set CLASSPATH="%BASE%/lib/*;"
set ADD_OPENS=--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED
java -cp %CLASSPATH% %ADD_OPENS% i5.las2peer.tools.L2pNodeLauncher --port 9011 --service-directory service uploadStartupDirectory startService('${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}') startWebConnector interactive
pause
"""
}
The --add-opens
argument also needs to be set in the start command inside the docker-entrypoint
.
Modify the start command by adding
--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED
to it. In a start command like
LAUNCH_COMMAND='java -cp lib/* i5.las2peer.tools.L2pNodeLauncher -s service -p '"${LAS2PEER_PORT} ${SERVICE_EXTRA_ARGS}"
this would yield to
LAUNCH_COMMAND='java -cp lib/* --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED i5.las2peer.tools.L2pNodeLauncher -s service -p '"${LAS2PEER_PORT} ${SERVICE_EXTRA_ARGS}"