Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build against Java 21 #2929

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/latest-bitcoind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:
with:
path: eclair

- name: Set up JDK 11
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 21
distribution: 'adopt'

- name: Configure OS settings
run: echo "fs.file-max = 1024000" | sudo tee -a /etc/sysctl.conf

- name: Run eclair tests
run: BITCOIND_DIR=$GITHUB_WORKSPACE/bitcoin/build/src mvn test
run: BITCOIND_DIR=$GITHUB_WORKSPACE/bitcoin/build/src ./mvnw test
working-directory: ./eclair
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
timeout-minutes: 30

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 21
distribution: 'adopt'

- name: Cache Maven dependencies
Expand All @@ -34,7 +34,7 @@ jobs:
# NB: we exclude external API tests from the CI, because we don't want our build to fail because a dependency is failing.
# This means we won't automatically catch changes in external APIs, but developers should regularly run the test suite locally so in practice it shouldn't be a problem.
- name: Build with Maven
run: mvn test-compile && mvn scoverage:report -DtagsToExclude=external-api
run: ./mvnw test-compile && ./mvnw scoverage:report -DtagsToExclude=external-api

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
22 changes: 22 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
t-bast marked this conversation as resolved.
Show resolved Hide resolved
distributionType=script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
t-bast marked this conversation as resolved.
Show resolved Hide resolved
distributionSha256Sum=4ec3f26fb1a692473aea0235c300bd20f0f9fe741947c82c1234cefd76ac3a3c
t-bast marked this conversation as resolved.
Show resolved Hide resolved
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
wrapperSha256Sum=3d8f20ce6103913be8b52aef6d994e0c54705fb527324ceb9b835b338739c7a8
22 changes: 11 additions & 11 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Requirements

- [OpenJDK 11](https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot).
- [Maven](https://maven.apache.org/download.cgi) 3.6.0 or newer
- [OpenJDK 21](https://adoptium.net/temurin/releases/?package=jdk&version=21).
- [Maven](https://maven.apache.org/download.cgi) 3.9.2 or newer

## Build

Expand All @@ -14,61 +14,61 @@ that we release, you must use the build environment (OS, JDK, maven...) that we
To build the project and run the tests, simply run:

```shell
mvn package
./mvnw package
```

Notes:

- This command will build all modules (core, node, gui).
- If the build fails, you may need to clean previously built artifacts with the `mvn clean` command.
- If the build fails, you may need to clean previously built artifacts with the `./mvnw clean` command.
- Archives can be found in the `target` folder for each module.

### Skip tests

Running tests takes time. If you want to skip them, use `-DskipTests`:

```shell
mvn package -DskipTests
./mvnw package -DskipTests
```

### Run tests

To only run the tests, run:

```shell
mvn test
./mvnw test
```

To run tests for a specific class, run:

```shell
mvn test -Dsuites=*<TestClassName>
./mvnw test -Dsuites=*<TestClassName>
```

To run tests using a specific number of threads, run:

```shell
mvn -T <thread_count> test
./mvnw -T <thread_count> test
```

To run tests with a specific version of `bitcoind`, run:

```shell
BITCOIND_DIR=<absolute/path/to/directory> mvn test
BITCOIND_DIR=<absolute/path/to/directory> ./mvnw test
```

### Build specific module

To only build the `eclair-node` module, run:

```shell
mvn package -pl eclair-node -am -Dmaven.test.skip=true
./mvnw package -pl eclair-node -am -Dmaven.test.skip=true
```

To install `eclair-core` into your local maven repository and use it in another project, run:

```shell
mvn clean install -pl eclair-core -am -Dmaven.test.skip=true
./mvnw clean install -pl eclair-core -am -Dmaven.test.skip=true
```

## Build the API documentation
Expand Down
35 changes: 8 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,33 @@
FROM adoptopenjdk/openjdk11:jdk-11.0.3_7-alpine as BUILD

# Setup maven, we don't use https://hub.docker.com/_/maven/ as it declare .m2 as volume, we loose all mvn cache
# We can alternatively do as proposed by https://github.com/carlossg/docker-maven#packaging-a-local-repository-with-the-image
# this was meant to make the image smaller, but we use multi-stage build so we don't care
RUN apk add --no-cache curl tar bash

ARG MAVEN_VERSION=3.9.2
ARG USER_HOME_DIR="/root"
ARG SHA=900bdeeeae550d2d2b3920fe0e00e41b0069f32c019d566465015bdd1b3866395cbe016e22d95d25d51d3a5e614af2c83ec9b282d73309f644859bbad08b63db
ARG BASE_URL=https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries

RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
FROM eclipse-temurin:21-jdk-alpine as BUILD

# Let's fetch eclair dependencies, so that Docker can cache them
# This way we won't have to fetch dependencies again if only the source code changes
# The easiest way to reliably get dependencies is to build the project with no sources
WORKDIR /usr/src
COPY mvnw mvnw
COPY .mvn .mvn
COPY pom.xml pom.xml
COPY eclair-core/pom.xml eclair-core/pom.xml
COPY eclair-front/pom.xml eclair-front/pom.xml
COPY eclair-node/pom.xml eclair-node/pom.xml
COPY eclair-node/modules/assembly.xml eclair-node/modules/assembly.xml
RUN mkdir -p eclair-core/src/main/scala && touch eclair-core/src/main/scala/empty.scala
# Blank build. We only care about eclair-node, and we use install because eclair-node depends on eclair-core
RUN mvn install -pl eclair-node -am
RUN mvn clean
RUN ./mvnw install -pl eclair-node -am
RUN ./mvnw clean

# Only then do we copy the sources
COPY . .

# And this time we can build in offline mode, specifying 'notag' instead of git commit
RUN mvn package -pl eclair-node -am -DskipTests -Dgit.commit.id=notag -Dgit.commit.id.abbrev=notag -o
RUN ./mvnw package -pl eclair-node -am -DskipTests -Dgit.commit.id=notag -Dgit.commit.id.abbrev=notag -o
# It might be good idea to run the tests here, so that the docker build fail if the code is bugged

# We currently use a debian image for runtime because of some jni-related issue with sqlite
FROM openjdk:11.0.4-jre-slim
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app

# install jq for eclair-cli
RUN apt-get update && apt-get install -y bash jq curl unzip
RUN apk add bash jq curl unzip

# copy and install eclair-cli executable
COPY --from=BUILD /usr/src/eclair-core/eclair-cli .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ rpcclienttimeout=30

Eclair is developed in [Scala](https://www.scala-lang.org/), a powerful functional language that runs on the JVM, and is packaged as a ZIP archive.

To run Eclair, you first need to install Java, we recommend that you use [OpenJDK 11](https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot). Other runtimes also work, but we don't recommend using them.
To run Eclair, you first need to install Java. Eclair targets Java 21 and will run on any compatible Java runtime, we recommend that you use [OpenJDK 21](https://adoptium.net/temurin/releases/?package=jdk&version=21).

Then download our latest [release](https://github.com/ACINQ/eclair/releases), unzip the archive and run the following command:

Expand Down
65 changes: 0 additions & 65 deletions contrib/arm64v8.Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ $ git clone [email protected]:ACINQ/eclair.git
$ vi eclair-core/src/main/reference.conf # set akka.remote.artery.transport = "tls-tcp"
$ cp akka-cluster-tls.jks eclair-front/modules/awseb/ # copy the file you generated
$ vi eclair-front/modules/awseb.xml # uncomment the relevant parts
$ mvn package -DskipTests
$ ./mvnw package -DskipTests
```
Alternatively, you can also edit the existing bundle and manually add the `akka-cluster-tls.jks` file to the root of the zip archive. You will also need to set `akka.remote.artery.transport=tls-tcp` at runtime.

Expand Down
11 changes: 8 additions & 3 deletions docs/release-notes/eclair-vnext.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ When `option_provide_storage` is enabled, eclair will store a small encrypted ba
This backup is limited to 65kB and node operators should customize the `eclair.peer-storage` configuration section to match their desired SLAs.
This is mostly intended for LSPs that serve mobile wallets to allow users to restore their channels when they switch phones.

### Eclair requires a Java 21 runtime

Eclair now targets Java 21 and requires a compatible Java Runtime Environment. It will no longer work on JRE 11 or JRE 17.
t-bast marked this conversation as resolved.
Show resolved Hide resolved
There are many organisations that package Java runtimes and development kits, for example [OpenJDK 21](https://adoptium.net/temurin/releases/?package=jdk&version=21).

### API changes

<insert changes>
Expand Down Expand Up @@ -45,14 +50,14 @@ $ sha256sum -c SHA256SUMS.stripped

Eclair builds are deterministic. To reproduce our builds, please use the following environment (*):

- Ubuntu 22.04
- AdoptOpenJDK 11.0.22
- Ubuntu 24.04.1
- Adoptium OpenJDK 21.0.4
- Maven 3.9.2

Use the following command to generate the eclair-node package:

```sh
mvn clean install -DskipTests
./mvnw clean install -DskipTests
```

That should generate `eclair-node/target/eclair-node-<version>-XXXXXXX-bin.zip` with sha256 checksums that match the one we provide and sign in `SHA256SUMS.asc`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,11 @@ object NodeAddress {
}

object IPAddress {
def apply(inetAddress: InetAddress, port: Int): IPAddress = inetAddress match {
def apply(inetAddress: InetAddress, port: Int): IPAddress = (inetAddress: @unchecked) match {
// we need the @unchecked annotation to suppress a "matching not exhaustive". Before JDK21, InetAddress was a regular so scalac would not check anything (it only checks sealed patterns)
// with JDK21 InetAddress is defined as `public sealed class InetAddress implements Serializable permits Inet4Address, Inet6Address` and scalac complains because in theory there could be
// an InetAddress() instance, though its not possible in practice because the constructor is package private :(
// remove @unchecked if we upgrade to a newer JDK that does not have this pb, or if scalac pattern matching becomes more clever
case address: Inet4Address => IPv4(address, port)
case address: Inet6Address => IPv6(address, port)
}
Expand Down
2 changes: 1 addition & 1 deletion eclair-front/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<groupId>io.kamon</groupId>
<artifactId>kanela-agent</artifactId>
<!-- if you change this make sure to also update the lib version in eclair-front.sh and eclair-node.sh -->
<version>1.0.17</version>
<version>${kanela-agent.version}</version>
</dependency>
<!-- tests -->
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions eclair-front/src/main/resources/eclair-front.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ addDebugger () {

addKanelaAgent () {
# make sure that the lib version matches the one defined in pom.xml
addJava "-javaagent:$lib_dir/kanela-agent-1.0.17.jar"
addJava "-javaagent:$lib_dir/kanela-agent-1.0.18.jar"
}

require_arg () {
Expand Down Expand Up @@ -283,7 +283,7 @@ java_version_check() {
if [[ "$java_version" == "" ]]; then
echo
echo No java installations was detected.
echo Please go to 'https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot' and download
echo Please go to 'https://adoptium.net/temurin/releases/?package=jre&version=21' and download
echo
exit 1
else
Expand All @@ -296,7 +296,7 @@ java_version_check() {
echo The java installation you have is not up to date, eclair-front requires
echo at least version 1.8+ \(version 11 recommended\) but you have version $java_version
echo
echo Please go to 'https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot' and download
echo Please go to 'https://adoptium.net/temurin/releases/?package=jre&version=21' and download
echo a valid Java Runtime and install before running eclair-front.
echo
exit 1
Expand Down
2 changes: 1 addition & 1 deletion eclair-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
<dependency>
<groupId>io.kamon</groupId>
<artifactId>kanela-agent</artifactId>
<version>1.0.17</version>
<version>${kanela-agent.version}</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion eclair-node/src/main/resources/eclair-node.bat
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if "%JAVAOK%"=="false" (
)
echo.
echo Please go to
echo https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot
echo https://adoptium.net/temurin/releases/?package=jdk&version=21
echo and download a valid Java JDK and install before running @@APP_NAME@@.
echo.
echo If you think this message is in error, please check
Expand Down
Loading
Loading