Skip to content

Commit

Permalink
Build with Java 21 and gradle 8.8
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Pinto <[email protected]>
  • Loading branch information
lu-pinto committed Dec 16, 2024
1 parent 780b7ee commit 2e8de75
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 259 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
uses: gradle/actions/setup-gradle@c4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1

- name: Publish package
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108 changes: 52 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
* 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.
*/
import org.ajoberstar.grgit.Grgit
import net.ltgt.gradle.errorprone.CheckSeverity
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import groovy.xml.XmlParser
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
Expand All @@ -19,20 +22,16 @@ buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath "org.ajoberstar.grgit:grgit-core:5.2.1"
}
}

plugins {
id 'com.diffplug.spotless' version '6.22.0'
id 'net.ltgt.errorprone' version '3.1.0'
id 'org.springframework.boot' version '3.2.4'
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.gradle.crypto.checksum' version '1.4.0'
id 'org.jetbrains.kotlin.jvm' version '1.9.23'
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.23'
id 'org.jetbrains.kotlin.jvm' version '2.1.0'
id 'org.jetbrains.kotlin.plugin.spring' version '2.1.0'
id 'org.jetbrains.dokka' version '1.9.20'
id 'maven-publish'
id 'se.patrikerdes.use-latest-versions' version '0.2.18'
Expand Down Expand Up @@ -74,10 +73,10 @@ def expandedTaskList = []
gradle.startParameter.taskNames.each {
expandedTaskList << (buildAliases[it] ? buildAliases[it] : it)
}
gradle.startParameter.taskNames = expandedTaskList.flatten()
gradle.startParameter.taskNames = expandedTaskList.flatten() as Iterable<String>

ext {
gradleVersion = '7.6'
gradleVersion = '8.8'
}

apply from: "${rootDir}/gradle/wrapper.gradle"
Expand All @@ -96,7 +95,7 @@ spotless {
}
}

task integrationTest(type: Test) {
tasks.register('integrationTest', Test) {
}

subprojects {
Expand Down Expand Up @@ -142,14 +141,14 @@ subprojects {
integrationTestRuntimeOnly 'ch.qos.logback:logback-classic'
}

task integrationTest(type: Test) {
tasks.register('integrationTest', Test) {
description = 'Runs integration tests.'
group = 'verification'

testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath

useJUnitPlatform() { includeEngines 'spek', 'junit-jupiter' }
useJUnitPlatform() { 'junit-jupiter' }
timeout = Duration.ofMinutes(30)
}

Expand All @@ -159,19 +158,19 @@ subprojects {
//////
// Parallel build execution

tasks.withType(Test) {
tasks.withType(Test).configureEach {
// If GRADLE_MAX_TEST_FORKS is not set, use half the available processors
maxParallelForks = (System.getenv('GRADLE_MAX_TEST_FORKS') ?:
(Runtime.runtime.availableProcessors().intdiv(2) ?: 1)).toInteger()
(Runtime.runtime.availableProcessors().intdiv(2) ?: 1)).toInteger()
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.fork = true
options.incremental = true
options.encoding = 'UTF-8'
}

task allDependencies(type: DependencyReportTask) {}
tasks.register('allDependencies', DependencyReportTask) {}
}

//////
Expand Down Expand Up @@ -200,51 +199,47 @@ allprojects {

repositories {
mavenCentral()
maven {
url = 'https://hyperledger.jfrog.io/artifactory/besu-maven/'
}
}


//////
// Compiler arguments

sourceCompatibility = '1.17'
targetCompatibility = '1.17'
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

dependencies {
errorprone 'com.google.errorprone:error_prone_core'
}

tasks.withType(AbstractArchiveTask) {
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += [
'-Xlint:unchecked',
'-Xlint:cast',
'-Xlint:rawtypes',
'-Xlint:overloads',
'-Xlint:divzero',
'-Xlint:finally',
'-Xlint:static',
'-Werror'
'-Xlint:unchecked',
'-Xlint:cast',
'-Xlint:rawtypes',
'-Xlint:overloads',
'-Xlint:divzero',
'-Xlint:finally',
'-Xlint:static',
'-Werror'
]

options.errorprone {
excludedPaths = '.*/generated-src/.*'
check('FutureReturnValueIgnored', net.ltgt.gradle.errorprone.CheckSeverity.OFF)
check('UnnecessaryParentheses', net.ltgt.gradle.errorprone.CheckSeverity.OFF)
check('FutureReturnValueIgnored', CheckSeverity.OFF)
check('UnnecessaryParentheses', CheckSeverity.OFF)

disableWarningsInGeneratedCode = true
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "17"
tasks.withType(KotlinCompile).configureEach {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
allWarningsAsErrors = true
freeCompilerArgs = [
'-Xjsr305=strict',
Expand All @@ -258,36 +253,37 @@ allprojects {
// Use JUnit5 for testing

test {
useJUnitPlatform() { includeEngines 'spek', 'junit-jupiter' }
useJUnitPlatform() { 'junit-jupiter' }
timeout = Duration.ofMinutes(30)
}

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
xml.required.set(true)
html.required.set(true)
}
getExecutionData().setFrom(fileTree(buildDir).include("/jacoco/*.exec"))
getExecutionData().setFrom(fileTree(rootProject.layout.buildDirectory).include("/jacoco/*.exec"))
}


//////
// Artifact locations

jar {
destinationDirectory = file("${rootProject.buildDir}/libs")
destinationDirectory = rootProject.layout.buildDirectory.dir("libs")
}

task sourcesJar(type: Jar, dependsOn: classes) {
destinationDirectory = file("${rootProject.buildDir}/src")
classifier = 'sources'
tasks.register('sourcesJar', Jar) {
dependsOn classes
destinationDirectory = rootProject.layout.buildDirectory.dir("src")
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

//////
// Packaging and deployment

tasks.withType(Jar) {
tasks.withType(Jar).configureEach {
def moduleName = rootProject.name
if (rootProject == project) {
archiveBaseName = project.name
Expand All @@ -297,8 +293,8 @@ allprojects {
}
manifest {
attributes('Implementation-Title': archiveBaseName,
'Implementation-Version': project.version,
'Automatic-Module-Name': moduleName.replaceAll("-","_"))
'Implementation-Version': project.version,
'Automatic-Module-Name': moduleName.replaceAll("-", "_"))
}
from(rootProject.projectDir) {
include 'DISCLAIMER'
Expand Down Expand Up @@ -336,7 +332,7 @@ allprojects {
project.logger.info('Reading .m2/settings.xml')
def serverId = (project.properties['distMgmtServerId'] ?: isRelease
? 'apache.releases.https' : 'apache.snapshots.https')
def m2SettingCreds = new XmlSlurper().parse(settingsXml).servers.server.find { server -> serverId.equals(server.id.text()) }
def m2SettingCreds = new XmlParser().parse(settingsXml).servers.server.find { server -> serverId == server.id.text() }
if (m2SettingCreds) {
project.logger.info('Found matching credentials from .m2/settings.xml')
credentials {
Expand Down Expand Up @@ -370,7 +366,7 @@ allprojects {
MavenDeployment(MavenPublication) { publication ->
if (project != rootProject) {
from components.java
artifact sourcesJar { classifier 'sources' }
artifact sourcesJar { archiveClassifier.set('sources') }
}
groupId 'io.consensys.protocols'
artifactId 'tuweni-' + project.name
Expand Down Expand Up @@ -494,19 +490,19 @@ allprojects {
}
}

tasks.withType(Sign) {
tasks.withType(Sign).configureEach {
onlyIf {
System.getenv('ENABLE_SIGNING') == 'true'
}
}

tasks.withType(GenerateModuleMetadata) {
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}

model {
tasks.generatePomFileForMavenDeploymentPublication {
destination = file("$buildDir/generated-pom.xml")
destination = rootProject.layout.buildDirectory.dir("generated-pom.xml")
}
tasks.publishMavenDeploymentPublicationToMavenLocal { dependsOn project.tasks.signArchives }
}
Expand Down Expand Up @@ -538,7 +534,7 @@ apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(file("$rootProject.buildDir/docs"))
outputDirectory = rootProject.layout.buildDirectory.dir("docs")
}

tasks.register("docs") {
Expand Down Expand Up @@ -573,7 +569,7 @@ dokkaHtml {
}
}

project.task("checkNotice") {
tasks.register('checkNotice') {
def lines = file("NOTICE").readLines()
def expected = "Copyright 2023-${LocalDate.now().getYear()} The Machine Consultancy LLC"
for (line in lines) {
Expand Down
2 changes: 1 addition & 1 deletion bytes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
implementation 'org.connid:framework-internal'
compileOnly 'com.google.code.findbugs:jsr305'
compileOnly 'com.google.errorprone:error_prone_annotations'
compileOnly 'io.vertx:vertx-core'
api 'io.vertx:vertx-core'

testImplementation 'io.vertx:vertx-core'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
Expand Down
Loading

0 comments on commit 2e8de75

Please sign in to comment.