-
Notifications
You must be signed in to change notification settings - Fork 12
L2p Service Migration v1.1.1 to v1.2.0 (Java 17)
WIP: This wiki page will be used to document the required changes to update a las2peer service from v1.1.1 (or v1.1.2) to the (not yet officially released) 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.
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 set the -jar
argument in the start command to the las2peer-bundle jar file.
By setting this argument, we also do not need to set i5.las2peer.tools.L2pNodeLauncher
as the entrypoint anymore.
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/*" -jar lib/las2peer-bundle-${project.property('core.version')}.jar --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 L2P_JAR_PATH="%BASE%/lib/las2peer-bundle-${project.property('core.version')}.jar"
java -cp %CLASSPATH% -jar %L2P_JAR_PATH% --port 9011 --service-directory service uploadStartupDirectory startService('${project.property('service.name')}.${project.property('service.class')}@${project.property('service.version')}') startWebConnector interactive
pause
"""
}
This Gradle task automatically reads the core.version
attribute from gradle.properties
file.
This allows to automatically set the -jar
argument of the start command to the currently used version of las2peer.
The -jar
argument also needs to be set in the start command inside the docker-entrypoint
.
Therefore we first need to parse the current las2peer version from gradle.properties
file.
This can be done by adding the following command:
export CORE_VERSION=$(awk -F "=" '/core.version/ {print $2}' gradle.properties)
Then we can replace i5.las2peer.tools.L2pNodeLauncher
with -jar lib/las2peer-bundle-'"${CORE_VERSION}"'.jar
in the java start command.