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

chore: update gradle to support Java 21 #10513

Merged
merged 15 commits into from
Dec 21, 2023
2 changes: 1 addition & 1 deletion .github/workflows/node-flow-build-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.3"
default: "21.0.1"
java-distribution:
description: "Java JDK Distribution:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node-zxc-compile-application-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.3"
default: "21.0.1"
node-version:
description: "NodeJS Version:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform-flow-deploy-adhoc-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.3"
default: "21.0.1"
java-distribution:
description: "Java JDK Distribution:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform-flow-deploy-ea-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.3"
default: "21.0.1"
java-distribution:
description: "Java JDK Distribution:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform-flow-deploy-mc-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.3"
default: "21.0.1"
java-distribution:
description: "Java JDK Distribution:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform-zxc-release-internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.3"
default: "21.0.1"
gradle-version:
description: "Gradle Version:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform-zxc-release-maven-central.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.3"
default: "21.0.1"
gradle-version:
description: "Gradle Version:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zxc-jrs-regression.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ on:
description: "Java JDK Version:"
type: string
required: false
default: "17"
default: "21.0.1"
gradle-version:
description: "Gradle Version:"
type: string
Expand Down
2 changes: 1 addition & 1 deletion build-logic/project-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
dependencies {
implementation("com.adarshr:gradle-test-logger-plugin:4.0.0")
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.26.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.23.3")
implementation("com.github.johnrengelman:shadow:8.1.1")
implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
implementation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ version =
providers.fileContents(rootProject.layout.projectDirectory.versionTxt()).asText.get().trim()

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
vendor.set(JvmVendorSpec.ADOPTIUM)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,6 @@ extraJavaModuleInfo {
exportAllPackages()
requireAllDefinedDependencies()
}
module("org.mockito:mockito-inline", "org.mockito.inline") {
exportAllPackages()
requireAllDefinedDependencies()
}
module("uk.org.webcompere:system-stubs-core", "uk.org.webcompere.systemstubs.core") {
exportAllPackages()
requireAllDefinedDependencies()
Expand Down
5 changes: 4 additions & 1 deletion build-logic/settings-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@

plugins { `kotlin-dsl` }

dependencies { implementation("com.gradle:gradle-enterprise-gradle-plugin:3.15.1") }
dependencies {
implementation("org.gradle.toolchains:foojay-resolver:0.7.0")
implementation("com.gradle:gradle-enterprise-gradle-plugin:3.15.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ pluginManagement {
}
}

plugins { id("com.gradle.enterprise") }
plugins {
id("com.gradle.enterprise")
id("org.gradle.toolchains.foojay-resolver-convention")
}

// Enable Gradle Build Scan
gradleEnterprise {
Expand Down
5 changes: 2 additions & 3 deletions hedera-dependency-versions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ val grpcVersion = "1.54.1"
val helidonVersion = "3.2.1"
val jacksonVersion = "2.16.0"
val log4jVersion = "2.21.1"
val mockitoVersion = "4.11.0"
val mockitoVersion = "5.8.0"
val nettyVersion = "4.1.87.Final"
val prometheusVersion = "0.16.0"
val protobufVersion = "3.21.7"
val systemStubsVersion = "2.0.2"
val systemStubsVersion = "2.1.5"
val testContainersVersion = "1.17.2"
val tuweniVersion = "2.4.2"

Expand Down Expand Up @@ -101,7 +101,6 @@ moduleInfo {
version("org.junit.platform.engine", "1.9.1")
version("org.junitpioneer", "2.0.1")
version("org.mockito", mockitoVersion)
version("org.mockito.inline", mockitoVersion)
version("org.mockito.junit.jupiter", mockitoVersion)
version("org.opentest4j", "1.2.0")
version("org.testcontainers", testContainersVersion)
Expand Down
1 change: 0 additions & 1 deletion hedera-node/cli-clients/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ testModuleInfo {
requires("org.junit.jupiter.api")
requires("org.mockito")
requires("org.mockito.junit.jupiter")
runtimeOnly("org.mockito.inline")
}

tasks.shadowJar {
Expand Down
1 change: 0 additions & 1 deletion hedera-node/hedera-consensus-service-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ testModuleInfo {
requires("org.mockito")
requires("org.mockito.junit.jupiter")
requiresStatic("com.github.spotbugs.annotations")
runtimeOnly("org.mockito.inline")
}
1 change: 0 additions & 1 deletion hedera-node/hedera-evm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ testModuleInfo {
requires("org.junit.jupiter.api")
requires("org.mockito")
requires("org.mockito.junit.jupiter")
runtimeOnly("org.mockito.inline")
}

publishing {
Expand Down
1 change: 0 additions & 1 deletion hedera-node/hedera-file-service-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ testModuleInfo {
requires("org.mockito")
requires("org.mockito.junit.jupiter")
requiresStatic("com.github.spotbugs.annotations")
runtimeOnly("org.mockito.inline")
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,36 @@

import com.hedera.pbj.runtime.io.buffer.BufferedData;
import java.nio.ByteBuffer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class DataBufferTest {
@Mock
private ByteBuffer buffer;

private BufferedData subject;

@BeforeEach
void setUp() {
subject = BufferedData.wrap(buffer);
}

@Test
void readFullyDelegates() {
final var b = new byte[] {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05};
subject = BufferedData.wrap(ByteBuffer.wrap(b));
final var subject = BufferedData.wrap(ByteBuffer.wrap(b));
final var bRead = new byte[b.length];
subject.readBytes(bRead);
assertArrayEquals(b, bRead);
}

@Test
void skipBytes() {
final var subject = BufferedData.wrap(ByteBuffer.wrap(new byte[] {}));
final var skipped = subject.skip(32L);
assertEquals(0, skipped);
}

@Test
void canReadThings() {
buffer = ByteBuffer.wrap(new byte[] {
final var buffer = ByteBuffer.wrap(new byte[] {
1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
});
subject = BufferedData.wrap(buffer);
final var subject = BufferedData.wrap(buffer);

// assertTrue(subject.readBoolean());
subject.readByte();
Expand All @@ -84,8 +69,8 @@ void canReadThings() {
@Test
@Disabled("Enable once reading boolean is supported")
void canReadFalse() {
buffer = ByteBuffer.wrap(new byte[] {0});
subject = BufferedData.wrap(buffer);
final var buffer = ByteBuffer.wrap(new byte[] {0});
final var subject = BufferedData.wrap(buffer);

// assertFalse(subject.readBoolean());
}
Expand All @@ -106,34 +91,38 @@ void returnsDelegate() {
@Test
void delegatesWrites() {
final var bytes = new byte[] {1, 2, 3, 4, 5};

InOrder inOrder = Mockito.inOrder(buffer);
final var buffer = ByteBuffer.allocate(40);
final var subject = BufferedData.wrap(buffer);

subject.writeByte((byte) 12);
subject.writeBytes(bytes);
subject.writeBytes(bytes, 1, 3);
// subject.writeBoolean(true);
// subject.writeBoolean(false);
subject.writeByte((byte) 42);
// subject.writeShort(13);
// subject.writeChar(14);
subject.writeInt(15);
subject.writeLong(16L);
subject.writeFloat(17.0f);
subject.writeDouble(18.0);

inOrder.verify(buffer).put((byte) 12);
inOrder.verify(buffer).put(bytes);
inOrder.verify(buffer).put(bytes, 1, 3);
// inOrder.verify(buffer).put((byte) 1);
// inOrder.verify(buffer).put((byte) 0);
inOrder.verify(buffer).put((byte) 42);
// inOrder.verify(buffer).putShort((short) 13);
// inOrder.verify(buffer).putChar((char) 14);
inOrder.verify(buffer).putInt(15);
inOrder.verify(buffer).putLong(16L);
inOrder.verify(buffer).putFloat(17.0f);
inOrder.verify(buffer).putDouble(18.0);
assertArrayEquals(
new byte[] {
12, 1, 2, 3, 4, 5, 2, 3, 4, 42, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 16, 65, -120, 0, 0, 64, 50, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
buffer.array());

buffer.rewind();
assertEquals(12, buffer.get());
final var bytes5Read = new byte[5];
buffer.get(bytes5Read);
assertArrayEquals(bytes, bytes5Read);
final var bytes3Read = new byte[3];
buffer.get(bytes3Read);
assertArrayEquals(new byte[] {2, 3, 4}, bytes3Read);
assertEquals(42, buffer.get());
assertEquals(15, buffer.getInt());
assertEquals(16L, buffer.getLong());
assertEquals(17.0f, buffer.getFloat());
assertEquals(18.0, buffer.getDouble());
}

@Test
Expand Down
Loading
Loading