Skip to content

Commit 01e6a8d

Browse files
committed
chore: Update to JDK 25 and modernize build system
This updates the required JDK version to 25, mostly as a demonstration of compatability. Additionally gradle was updated to the latest (with a collapse of the build files), and the CI was switched from Buildkite to GitHub Actions.
1 parent f3acac7 commit 01e6a8d

16 files changed

Lines changed: 295 additions & 329 deletions

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
8+
- package-ecosystem: "gradle"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Java 25
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: 25
23+
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@v4
26+
27+
- name: Compile
28+
run: ./gradlew clean assemble
29+
30+
- name: Test
31+
run: ./gradlew -PtestMode=slow test
32+
33+
- name: Checkstyle
34+
if: success() || failure()
35+
run: ./gradlew checkstyleMain
36+
37+
- name: Jacoco Coverage Verification
38+
if: success() || failure()
39+
run: ./gradlew jacocoTestCoverageVerification
40+
41+
- name: Upload test results
42+
if: always()
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: test-results
46+
path: build/reports/tests/xml/
47+
48+
- name: Upload build artifacts
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: jars
52+
path: build/libs/*.jar
Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
# ******** NOTE ********
12-
131
name: "CodeQL"
142

153
on:
164
push:
175
branches: [ master ]
186
pull_request:
19-
# The branches below must be a subset of the branches above
207
branches: [ master ]
218
schedule:
229
- cron: '45 16 * * 2'
@@ -30,39 +17,24 @@ jobs:
3017
fail-fast: false
3118
matrix:
3219
language: [ 'java' ]
33-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
34-
# Learn more...
35-
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
3620

3721
steps:
3822
- name: Checkout repository
39-
uses: actions/checkout@v2
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Java 25
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: temurin
29+
java-version: 25
4030

41-
# Initializes the CodeQL tools for scanning.
4231
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@v1
32+
uses: github/codeql-action/init@v3
4433
with:
4534
languages: ${{ matrix.language }}
46-
# If you wish to specify custom queries, you can do so here or in a config file.
47-
# By default, queries listed here will override any specified in a config file.
48-
# Prefix the list here with "+" to use these queries and those in the config file.
49-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
50-
51-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
52-
# If this step fails, then you should remove it and run the build manually (see below)
53-
- name: Autobuild
54-
uses: github/codeql-action/autobuild@v1
55-
56-
# ℹ️ Command-line programs to run using the OS shell.
57-
# 📚 https://git.io/JvXDl
58-
59-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
60-
# and modify them (or add more) to build your code if your project
61-
# uses a compiled language
6235

63-
#- run: |
64-
# make bootstrap
65-
# make release
36+
- name: Build
37+
run: ./gradlew clean assemble
6638

6739
- name: Perform CodeQL Analysis
68-
uses: github/codeql-action/analyze@v1
40+
uses: github/codeql-action/analyze@v3

build.gradle

Lines changed: 161 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,120 @@
1-
apply from: 'build.shared'
2-
apply plugin: 'checkstyle'
3-
apply plugin: 'jacoco'
1+
plugins {
2+
id 'java'
3+
id 'checkstyle'
4+
id 'jacoco'
5+
id 'maven-publish'
6+
id 'signing'
7+
}
8+
9+
java {
10+
toolchain {
11+
languageVersion = JavaLanguageVersion.of(25)
12+
}
13+
}
14+
15+
repositories {
16+
mavenCentral()
17+
}
18+
19+
dependencies {
20+
testImplementation 'junit:junit:4.13.2'
21+
implementation "org.threadly:threadly:$threadlyVersion"
22+
}
23+
24+
compileJava {
25+
options.compilerArgs << '-Xlint:all' << '-Xlint:-deprecation' << '-Xlint:-this-escape' << '-Werror'
26+
}
27+
28+
compileTestJava {
29+
options.compilerArgs << '-Xlint:all'
30+
}
431

5-
plugins.withType(JavaPlugin) {
6-
checkstyle.sourceSets = [sourceSets.main]
32+
checkstyle {
33+
sourceSets = [sourceSets.main]
734
}
835

36+
def testMode = project.findProperty('testMode') ?: 'default'
37+
938
test {
10-
maxParallelForks = Math.min(8, Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 4)))
39+
switch (testMode) {
40+
case 'slow':
41+
maxParallelForks = 1
42+
systemProperty 'systemSpeed', 'slow'
43+
break
44+
case 'stress':
45+
systemProperty 'systemSpeed', 'slow'
46+
systemProperty 'testProfile', 'stress'
47+
maxParallelForks = Math.min(8, Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 2)))
48+
break
49+
default:
50+
maxParallelForks = Math.min(8, Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 4)))
51+
break
52+
}
53+
54+
reports {
55+
junitXml.outputLocation = layout.buildDirectory.dir('reports/tests/xml')
56+
html.outputLocation = layout.buildDirectory.dir('reports/tests/html')
57+
}
58+
binaryResultsDirectory = layout.buildDirectory.dir('reports/tests/bin')
59+
1160
jacoco {
12-
excludes = ['**/package-info**','**/*Test']
13-
destinationFile = file("$buildDir/reports/jacoco/test.exec")
61+
excludes = ['**/package-info**', '**/*Test']
62+
destinationFile = layout.buildDirectory.file('reports/jacoco/test.exec').get().asFile
1463
}
1564
}
1665

17-
test.dependsOn("jar")
66+
test.dependsOn('jar')
67+
68+
jar {
69+
manifest {
70+
attributes(
71+
'Implementation-Title': 'Threadly Test Utilities',
72+
'Implementation-Version': archiveVersion.get()
73+
)
74+
}
75+
}
76+
77+
javadoc {
78+
source = sourceSets.main.allJava
79+
excludes = ['**/ThreadlyInternalAccessor**', '**/ArgumentVerifier**']
80+
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PUBLIC
81+
}
82+
83+
tasks.register('javadocJar', Jar) {
84+
dependsOn javadoc
85+
archiveClassifier.set('javadoc')
86+
from javadoc.destinationDir
87+
}
88+
89+
tasks.register('sourcesJar', Jar) {
90+
from sourceSets.main.allSource
91+
archiveClassifier.set('sources')
92+
}
93+
94+
tasks.register('copyLibs', Copy) {
95+
into layout.buildDirectory.dir('dependencies')
96+
from configurations.runtimeClasspath
97+
}
98+
99+
build.finalizedBy('copyLibs')
18100

19101
jacocoTestReport {
20102
reports {
21103
csv.required = false
22104
xml.required = true
23-
xml.destination = file("$buildDir/reports/jacoco/jacoco.xml")
105+
xml.outputLocation = layout.buildDirectory.file('reports/jacoco/jacoco.xml')
24106
html.required = true
25-
html.destination = file("$buildDir/reports/jacoco/html")
107+
html.outputLocation = layout.buildDirectory.dir('reports/jacoco/html')
26108
}
27109
doLast {
28110
println "Test results available at:"
29-
println "html - $buildDir/reports/tests/html/index.html"
111+
println "html - ${layout.buildDirectory.dir('reports/tests/html').get().asFile}/index.html"
30112
println "Test coverage reports available at:"
31-
println "html - $buildDir/reports/jacoco/html/index.html"
113+
println "html - ${layout.buildDirectory.dir('reports/jacoco/html').get().asFile}/index.html"
32114
}
33115
}
34116

35-
test.finalizedBy("jacocoTestReport")
117+
test.finalizedBy('jacocoTestReport')
36118

37119
jacocoTestCoverageVerification {
38120
violationRules {
@@ -63,4 +145,68 @@ jacocoTestCoverageVerification {
63145
}
64146
}
65147

66-
jacocoTestReport.finalizedBy("jacocoTestCoverageVerification")
148+
jacocoTestReport.finalizedBy('jacocoTestCoverageVerification')
149+
150+
publishing {
151+
publications {
152+
mavenJava(MavenPublication) {
153+
from components.java
154+
155+
artifact(tasks.named('sourcesJar'))
156+
artifact(tasks.named('javadocJar'))
157+
158+
pom {
159+
name = 'Threadly Test Utilities'
160+
description = 'A library of tools to assist with testing concurrent java applications.'
161+
url = 'https://threadly.org/'
162+
163+
scm {
164+
url = 'scm:git@github.com:threadly/threadly-test.git'
165+
connection = 'scm:git@github.com:threadly/threadly-test.git'
166+
developerConnection = 'scm:git@github.com:threadly/threadly-test.git'
167+
}
168+
169+
issueManagement {
170+
system = 'GitHub'
171+
url = 'https://github.com/threadly/threadly-test/issues'
172+
}
173+
174+
licenses {
175+
license {
176+
name = 'Mozilla Public License Version 2.0'
177+
url = 'https://www.mozilla.org/MPL/2.0/'
178+
distribution = 'repo'
179+
}
180+
}
181+
182+
developers {
183+
developer {
184+
id = 'jent'
185+
name = 'Mike Jensen'
186+
email = 'jent@threadly.org'
187+
}
188+
}
189+
}
190+
}
191+
}
192+
repositories {
193+
maven {
194+
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
195+
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
196+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
197+
credentials {
198+
username = findProperty('sonatypeUsername') ?: ''
199+
password = findProperty('sonatypePassword') ?: ''
200+
}
201+
}
202+
}
203+
}
204+
205+
tasks.withType(GenerateMavenPom).configureEach {
206+
destination = layout.buildDirectory.file('generated-pom.xml').get().asFile
207+
}
208+
209+
signing {
210+
required = { !version.toString().contains('SNAPSHOT') && gradle.taskGraph.hasTask('publish') }
211+
sign publishing.publications.mavenJava
212+
}

0 commit comments

Comments
 (0)