Skip to content

Commit

Permalink
[Java] Use version catalogs.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyazelenko committed Sep 13, 2024
1 parent 159a03f commit 4d4d6e4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 40 deletions.
54 changes: 14 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@ import java.nio.file.Files
import java.nio.file.StandardOpenOption
import java.security.MessageDigest

buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'org.ow2.asm:asm:9.7'
classpath 'org.ow2.asm:asm-commons:9.7'
}
}

plugins {
id 'java-library'
id 'jvm-test-suite'
id 'com.gradleup.shadow' version '8.3.1' apply false
id 'com.github.ben-manes.versions' version '0.51.0'
alias(libs.plugins.shadow).apply(false)
alias(libs.plugins.versions)
}

defaultTasks 'clean', 'build'
Expand All @@ -54,16 +43,6 @@ def toolchainLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
}

def checkstyleVersion = '10.18.0'
def hamcrestVersion = '3.0'
def mockitoVersion = '5.13.0'
def junitVersion = '5.11.0'
def jqwikVersion = '1.9.0'
def jsonVersion = '20240303'
def jmhVersion = '1.37'
def agronaVersion = '1.23.0'
def agronaVersionRange = "[${agronaVersion},2.0["

def sbeGroup = 'uk.co.real-logic'
def sbeVersion = file('version.txt').text.trim()

Expand Down Expand Up @@ -193,7 +172,7 @@ subprojects {
sourceCompatibility = JavaVersion.VERSION_17
}

checkstyle.toolVersion = "${checkstyleVersion}"
checkstyle.toolVersion = libs.versions.checkstyle.get()

tasks.withType(Sign).configureEach {
onlyIf {
Expand All @@ -219,7 +198,7 @@ subprojects {
options.encoding = 'UTF-8'
options.docEncoding = 'UTF-8'
options.charSet = 'UTF-8'
options.links("https://www.javadoc.io/doc/org.agrona/agrona/${agronaVersion}/")
options.links("https://www.javadoc.io/doc/org.agrona/agrona/${libs.versions.agrona.get()}/")
if (buildJavaVersion >= 23) { // early access JavaDoc location is different
options.links("https://download.java.net/java/early_access/jdk${buildJavaVersion}/docs/api/")
}
Expand All @@ -232,7 +211,7 @@ subprojects {
testing {
suites {
test {
useJUnitJupiter junitVersion
useJUnitJupiter libs.versions.junit.get()

targets {
all {
Expand Down Expand Up @@ -267,12 +246,7 @@ project(':sbe-tool') {
apply plugin: 'signing'

dependencies {
api("org.agrona:agrona") {
version {
strictly(agronaVersionRange)
prefer(agronaVersion)
}
}
api libs.agrona
}

def generatedDir = "${layout.buildDirectory.get()}/generated-src"
Expand Down Expand Up @@ -300,26 +274,26 @@ project(':sbe-tool') {
test {
dependencies {
implementation files("${layout.buildDirectory.get()}/classes/java/generated")
implementation "org.hamcrest:hamcrest:${hamcrestVersion}"
implementation "org.mockito:mockito-core:${mockitoVersion}"
implementation platform("org.junit:junit-bom:${junitVersion}")
implementation libs.hamcrest
implementation libs.mockito
implementation platform("org.junit:junit-bom:${libs.versions.junit.get()}")
implementation "org.junit.jupiter:junit-jupiter-params"
}
}

propertyTest(JvmTestSuite) {
// We should be able to use _only_ the JQwik engine, but this issue is outstanding:
// https://github.com/gradle/gradle/issues/21299
useJUnitJupiter junitVersion
useJUnitJupiter libs.versions.junit.get()

dependencies {
implementation project()
implementation("net.jqwik:jqwik:${jqwikVersion}") {
implementation(libs.jqwik) {
// Exclude JUnit 5 dependencies that are already provided due to useJUnitJupiter
exclude group: 'org.junit.platform', module: 'junit-platform-commons'
exclude group: 'org.junit.platform', module: 'junit-platform-engine'
}
implementation "org.json:json:${jsonVersion}"
implementation libs.json
}


Expand Down Expand Up @@ -611,8 +585,8 @@ project(':sbe-benchmarks') {
apply plugin: 'com.gradleup.shadow'

dependencies {
implementation "org.openjdk.jmh:jmh-core:${jmhVersion}"
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}"
implementation libs.jmh.core
annotationProcessor libs.jmh.generator.annprocess
implementation project(':sbe-tool')
implementation files("${layout.buildDirectory.get()}/classes/java/generated")
}
Expand Down
18 changes: 18 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[versions]
agrona = "1.23.0"
checkstyle = "10.18.1"
junit = "5.11.0"
jmh = "1.37"

[libraries]
agrona = { group = "org.agrona", name = "agrona", version = { strictly = "[1.23, 2.0[", require = "1.23.0" } }
mockito = { group = "org.mockito", name = "mockito-core", version = "5.13.0" }
hamcrest = { group = "org.hamcrest", name = "hamcrest", version = "3.0" }
jqwik = { group = "net.jqwik", name = "jqwik", version = "1.9.0" }
json = { group = "org.json", name = "json", version = "20240303" }
jmh-core = { group = "org.openjdk.jmh", name = "jmh-core", version.ref = "jmh" }
jmh-generator-annprocess = { group = "org.openjdk.jmh", name = "jmh-generator-annprocess", version.ref = "jmh" }

[plugins]
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
shadow = { id = "com.gradleup.shadow", version = "8.3.1" }

0 comments on commit 4d4d6e4

Please sign in to comment.