Skip to content

Commit

Permalink
[build] update use of gradle deprecated features (#8295)
Browse files Browse the repository at this point in the history
* gradle 8.11

Signed-off-by: Sally MacFarlane <[email protected]>

---------

Signed-off-by: Sally MacFarlane <[email protected]>
  • Loading branch information
macfarla authored Feb 16, 2025
1 parent 5bf7ae1 commit 1508b5c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 52 deletions.
86 changes: 45 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ configure(allprojects - project(':platform')) {
tasks.build {
dependsOn 'javadoc'
}
sourceCompatibility = 21
targetCompatibility = 21

java {
sourceCompatibility = 21
targetCompatibility = 21
}

repositories {
maven {
Expand Down Expand Up @@ -643,32 +646,34 @@ subprojects {
jar { enabled = false }

apply plugin: 'application'
mainClassName = 'org.hyperledger.besu.Besu'
applicationDefaultJvmArgs = [
'-Dvertx.disableFileCPResolving=true',
// BESU_HOME is replaced by a doFirst block in the run task.
'-Dbesu.home=BESU_HOME',
// We shutdown log4j ourselves, as otherwise this shutdown hook runs before our own and whatever
// happens during shutdown is not logged.
'-Dlog4j.shutdownHookEnabled=false',
// Disable JNI lookups in log4j messages to improve security
'-Dlog4j2.formatMsgNoLookups=true',
// Redirect java.util.logging loggers to use log4j2.
'-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager',
// Suppress Java JPMS warnings. Document the reason for each suppression.
// Bouncy Castle needs access to sun.security.provider, which is not open by default.
'--add-opens',
'java.base/sun.security.provider=ALL-UNNAMED',
// Jackson likes to access java.util.OptionalLong's constructor
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
// suppress netty specific module warnings in debug
"-Dio.netty.tryReflectionSetAccessible=true",
"--add-exports",
"java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-opens",
"java.base/java.nio=ALL-UNNAMED"
]
application {
mainClass = 'org.hyperledger.besu.Besu'
applicationDefaultJvmArgs = [
'-Dvertx.disableFileCPResolving=true',
// BESU_HOME is replaced by a doFirst block in the run task.
'-Dbesu.home=BESU_HOME',
// We shutdown log4j ourselves, as otherwise this shutdown hook runs before our own and whatever
// happens during shutdown is not logged.
'-Dlog4j.shutdownHookEnabled=false',
// Disable JNI lookups in log4j messages to improve security
'-Dlog4j2.formatMsgNoLookups=true',
// Redirect java.util.logging loggers to use log4j2.
'-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager',
// Suppress Java JPMS warnings. Document the reason for each suppression.
// Bouncy Castle needs access to sun.security.provider, which is not open by default.
'--add-opens',
'java.base/sun.security.provider=ALL-UNNAMED',
// Jackson likes to access java.util.OptionalLong's constructor
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
// suppress netty specific module warnings in debug
"-Dio.netty.tryReflectionSetAccessible=true",
"--add-exports",
"java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-opens",
"java.base/java.nio=ALL-UNNAMED"
]
}

run {
args project.hasProperty("besu.run.args") ? project.property("besu.run.args").toString().split("\\s+") : []
Expand Down Expand Up @@ -696,7 +701,7 @@ def tweakStartScript(createScriptTask) {
}

startScripts {
defaultJvmOpts = applicationDefaultJvmArgs + [
defaultJvmOpts = application.applicationDefaultJvmArgs + [
"-XX:G1ConcRefinementThreads=2",
"-XX:G1HeapWastePercent=15",
"-XX:MaxGCPauseMillis=100",
Expand All @@ -713,7 +718,6 @@ task untunedStartScripts(type: CreateStartScripts) {
classpath = startScripts.classpath
outputDir = startScripts.outputDir
applicationName = 'besu-untuned'
defaultJvmOpts = applicationDefaultJvmArgs
unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/besu/src/main/scripts/unixStartScript.txt")
windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/besu/src/main/scripts/windowsStartScript.txt")
doLast { tweakStartScript(untunedStartScripts) }
Expand Down Expand Up @@ -822,7 +826,7 @@ task distDocker {
from file("${projectDir}/docker/Dockerfile")
into(dockerBuildDir)
}
exec {
providers.exec {
def image = "${dockerImageName}:${dockerBuildVersion}"
def dockerPlatform = ""
if (project.hasProperty('docker-platform')){
Expand All @@ -846,7 +850,7 @@ task testDocker {
}

doLast {
exec {
providers.exec {
def image = project.hasProperty('release.releaseVersion') ? "${dockerImageName}:" + project.property('release.releaseVersion') : "${dockerImageName}:${project.version}"
workingDir "${projectDir}/docker"
executable shell
Expand All @@ -870,7 +874,7 @@ task dockerUpload {
}

doLast {
exec {
providers.exec {
def archVariantImage = "${image}-${architecture}"
def cmd = "docker tag '${image}' '${archVariantImage}' && docker push '${archVariantImage}'"
println "Executing '${cmd}'"
Expand All @@ -887,28 +891,28 @@ task dockerUploadRelease {
doLast {
for (def architecture in archs) {

exec {
providers.exec {
def cmd = "docker pull '${image}-${architecture}' && docker tag '${image}-${architecture}' '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
providers.exec {
def cmd = "docker push '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}


exec {
providers.exec {
def archImage = "${image}-${architecture}"
def cmd = "docker pull '${archImage}' && docker tag ${archImage} '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
providers.exec {
def cmd = "docker push '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'"
executable shell
Expand All @@ -924,15 +928,15 @@ task manifestDocker {
"arm64",
"amd64"] //TODO: this assumes dockerUpload task has already been run on 2 different archs!
doLast {
exec {
providers.exec {
def targets = ""
archs.forEach { arch -> targets += "'${image}-${arch}' " }
def cmd = "docker manifest create '${image}' ${targets}"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
providers.exec {
def cmd = "docker manifest push '${image}'"
println "Executing '${cmd}'"
executable shell
Expand All @@ -947,15 +951,15 @@ task manifestDockerRelease {

doLast {

exec {
providers.exec {
def targets = ""
archs.forEach { arch -> targets += "'${baseTag}-${arch}' " }
def cmd = "docker manifest create '${baseTag}' ${targets} --amend"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
providers.exec {
def cmd = "docker manifest push '${baseTag}'"
println "Executing '${cmd}'"
executable shell
Expand Down
4 changes: 3 additions & 1 deletion ethereum/evmtool/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ dependencies {
nativeImageClasspath 'org.slf4j:slf4j-nop'
}

mainClassName = 'org.hyperledger.besu.evmtool.EvmTool'
application {
mainClass = 'org.hyperledger.besu.evmtool.EvmTool'
}


// rename the top level dir from besu-<version> to besu and this makes it really
Expand Down
21 changes: 11 additions & 10 deletions ethereum/referencetests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

configurations {
referenceTestAnnotationProcessor.extendsFrom testAnnotationProcessor
// we need this because referenceTestImplementation defaults to 'canBeResolved=false'.
tarConfig.extendsFrom referenceTestImplementation
tarConfig {
canBeResolved = true
canBeConsumed = false
}
}

def blockchainReferenceTests = tasks.register("blockchainReferenceTests") {
final referenceTestsPath = 'src/reference-test/external-resources/BlockchainTests'
Expand Down Expand Up @@ -238,7 +229,7 @@ tasks.register('validateReferenceTestSubmodule') {
def expectedHash = '9201075490807f58811078e9bb5ec895b4ac01a5'
def submodulePath = java.nio.file.Path.of("${rootProject.projectDir}", "ethereum/referencetests/src/reference-test/external-resources").toAbsolutePath()
try {
exec {
providers.exec {
commandLine 'git', 'submodule', 'status', submodulePath
standardOutput = result
errorOutput = result
Expand Down Expand Up @@ -304,3 +295,13 @@ def generateTestFiles(
testFile.newWriter().withWriter { w -> w << testFileContents }
}
}

configurations {
referenceTestAnnotationProcessor.extendsFrom testAnnotationProcessor
// we need this because referenceTestImplementation defaults to 'canBeResolved=false'.
tarConfig.extendsFrom referenceTestImplementation
tarConfig {
canBeResolved = true
canBeConsumed = false
}
}

0 comments on commit 1508b5c

Please sign in to comment.