diff --git a/build.gradle b/build.gradle index d454d1a06..ed9653b21 100644 --- a/build.gradle +++ b/build.gradle @@ -5,11 +5,11 @@ plugins { id 'idea' id 'maven-publish' id 'signing' - id "com.diffplug.spotless" version "6.25.0" + alias(libs.plugins.spotless) id 'java-library' id 'jacoco' // Build docs locally by running "site" command - id 'kr.motd.sphinx' version '2.10.1' + alias(libs.plugins.sphinx) } repositories { @@ -35,89 +35,65 @@ def _artifactId = 'server' //This is for https://github.com/gradle/gradle/issues/11308 System.setProperty("org.gradle.internal.publish.checksums.insecure", "True") -def luceneVersion = '9.12.0' -project.ext.slf4jVersion = '2.0.16' -project.ext.grpcVersion = '1.66.0' -project.ext.lz4Version = '1.8.0' -project.ext.mockitoVersion = '5.12.0' -project.ext.jacksonYamlVersion = '2.17.2' -project.ext.junitVersion = '4.13.2' -def log4jVersion = '2.23.1' -def disruptorVersion = '4.0.0' -def gsonVersion = '2.11.0' -def snakeYamlVersion = '2.2' -def spatial4jVersion = '0.8' -def s3mockVersion = '0.2.6' -def commonsCompressVersion = '1.27.0' -def awsJavaSdkVersion = '1.12.768' -def guiceVersion = '7.0.0' -def prometheusClientVersion = '1.3.1' -def fastutilVersion = '8.5.14' - dependencies { //prometheus (metrics) deps - implementation "io.prometheus:prometheus-metrics-core:${prometheusClientVersion}" - implementation "io.prometheus:prometheus-metrics-instrumentation-jvm:${prometheusClientVersion}" - implementation "io.prometheus:prometheus-metrics-exposition-formats:${prometheusClientVersion}" - implementation "io.grpc:grpc-netty-shaded:${rootProject.grpcVersion}" + implementation libs.prometheus.metrics.core + implementation libs.prometheus.metrics.exposition.formats + implementation libs.prometheus.metrics.instrumentation.jvm //logging deps - implementation "org.slf4j:slf4j-api:${project.ext.slf4jVersion}" - implementation "org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion}" - implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}" - implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" - implementation "com.lmax:disruptor:${disruptorVersion}" - - - implementation "com.google.code.gson:gson:${gsonVersion}" - implementation 'commons-io:commons-io:2.16.1' - implementation "org.yaml:snakeyaml:${snakeYamlVersion}" - implementation "org.apache.commons:commons-compress:${commonsCompressVersion}" - implementation "com.amazonaws:aws-java-sdk-core:${awsJavaSdkVersion}" - implementation "com.amazonaws:aws-java-sdk-s3:${awsJavaSdkVersion}" - runtimeOnly "com.amazonaws:aws-java-sdk-sts:${awsJavaSdkVersion}" - implementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.2" - implementation "com.google.inject:guice:${guiceVersion}" - implementation "org.lz4:lz4-java:${project.ext.lz4Version}" - implementation "com.fasterxml.jackson.core:jackson-databind:${project.ext.jacksonYamlVersion}" - implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.ext.jacksonYamlVersion}" + implementation libs.slf4j.api + implementation libs.log4j.api + implementation libs.log4j.core + implementation libs.log4j.slf4j2.impl + implementation libs.disruptor //lucene deps - implementation "org.apache.lucene:lucene-core:${luceneVersion}" - implementation "org.apache.lucene:lucene-codecs:${luceneVersion}" - implementation "org.apache.lucene:lucene-backward-codecs:${luceneVersion}" - implementation "org.apache.lucene:lucene-queries:${luceneVersion}" - implementation "org.apache.lucene:lucene-facet:${luceneVersion}" - implementation "org.apache.lucene:lucene-replicator:${luceneVersion}" - implementation "org.apache.lucene:lucene-analysis-common:${luceneVersion}" - implementation "org.apache.lucene:lucene-suggest:${luceneVersion}" - implementation "org.apache.lucene:lucene-expressions:${luceneVersion}" - implementation "org.apache.lucene:lucene-queries:${luceneVersion}" - implementation "org.apache.lucene:lucene-queryparser:${luceneVersion}" - implementation "org.apache.lucene:lucene-highlighter:${luceneVersion}" - implementation "org.apache.lucene:lucene-grouping:${luceneVersion}" - implementation "org.apache.lucene:lucene-queries:${luceneVersion}" - implementation "org.apache.lucene:lucene-join:${luceneVersion}" + implementation libs.lucene.analysis.common + implementation libs.lucene.backward.codecs + implementation libs.lucene.core + implementation libs.lucene.codecs + implementation libs.lucene.expressions + implementation libs.lucene.facet + implementation libs.lucene.grouping + implementation libs.lucene.highlighter + implementation libs.lucene.join + implementation libs.lucene.queries + implementation libs.lucene.queryparser + implementation libs.lucene.replicator + implementation libs.lucene.suggest //cli deps - implementation 'info.picocli:picocli:4.7.6' - implementation 'org.apache.commons:commons-csv:1.11.0' - - // gRPC deps - implementation "io.grpc:grpc-services:${project.ext.grpcVersion}" - - implementation "it.unimi.dsi:fastutil:${fastutilVersion}" - - testImplementation "junit:junit:${project.ext.junitVersion}" - testImplementation "io.grpc:grpc-testing:${rootProject.grpcVersion}" - testImplementation "io.grpc:grpc-inprocess:${rootProject.grpcVersion}" - testImplementation "org.mockito:mockito-core:${project.ext.mockitoVersion}" - testImplementation "org.apache.lucene:lucene-test-framework:${luceneVersion}" - testImplementation "org.locationtech.spatial4j:spatial4j:${spatial4jVersion}" - testImplementation "io.findify:s3mock_2.13:${s3mockVersion}" - - testImplementation "org.assertj:assertj-core:3.26.3" + implementation libs.picocli + implementation libs.commons.csv + + // other deps + implementation libs.aws.java.sdk.core + implementation libs.aws.java.sdk.s3 + runtimeOnly libs.aws.java.sdk.sts + implementation libs.commons.compress + implementation libs.commons.io + implementation libs.fastutil + implementation libs.grpc.netty.shaded + implementation libs.grpc.services + implementation libs.gson + implementation libs.guice + implementation libs.jackson.databind + implementation libs.jackson.dataformat.yaml + implementation libs.jakarta.xml.bind.api + implementation libs.lz4.java + implementation libs.snakeyaml + + // test deps + testImplementation libs.junit + testImplementation libs.grpc.inprocess + testImplementation libs.grpc.testing + testImplementation libs.mockito.core + testImplementation libs.lucene.test.framework + testImplementation libs.spatial4j + testImplementation libs.s3mock + testImplementation libs.assertj.core api project(':clientlib') } diff --git a/clientlib/build.gradle b/clientlib/build.gradle index 35d381c30..616e40f5b 100644 --- a/clientlib/build.gradle +++ b/clientlib/build.gradle @@ -1,14 +1,13 @@ plugins { // Provide convenience executables for trying out the examples. id 'application' - // ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier gradle versions - id 'com.google.protobuf' version '0.9.4' + alias(libs.plugins.protobuf) // Generate IntelliJ IDEA's .idea & .iml project files id 'idea' // Publish clientlib to maven central id 'maven-publish' id 'signing' - id "com.diffplug.spotless" + alias(libs.plugins.spotless) id 'java-library' } @@ -29,32 +28,25 @@ startScripts.enabled = false // groupId, artifactId and version for the generated pom def _artifactId = 'clientlib' -// Dependency versions -def protobufVersion = '3.25.3' -def protocVersion = protobufVersion - dependencies { - //grpc deps - api "com.google.api.grpc:proto-google-common-protos:2.41.0" - implementation "io.grpc:grpc-protobuf:${rootProject.grpcVersion}" - implementation "io.grpc:grpc-stub:${rootProject.grpcVersion}" - implementation "io.grpc:grpc-okhttp:${rootProject.grpcVersion}" - implementation "javax.annotation:javax.annotation-api:1.2" - implementation "org.slf4j:slf4j-api:${rootProject.slf4jVersion}" - implementation "com.fasterxml.jackson.core:jackson-databind:${rootProject.jacksonYamlVersion}" - implementation "com.google.protobuf:protobuf-java:${protobufVersion}" - - // for lz4 message compression - implementation "org.lz4:lz4-java:${rootProject.lz4Version}" - + api libs.proto.google.common.protos // examples/advanced need this for JsonFormat - api "com.google.protobuf:protobuf-java-util:${protobufVersion}" - - runtimeOnly "io.grpc:grpc-netty-shaded:${rootProject.grpcVersion}" + api libs.protobuf.java.util + + runtimeOnly libs.grpc.netty.shaded + implementation libs.grpc.okhttp + implementation libs.grpc.protobuf + implementation libs.grpc.stub + implementation libs.jackson.databind + implementation libs.javax.annotation.api + // for lz4 message compression + implementation libs.lz4.java + implementation libs.protobuf.java + implementation libs.slf4j.api //test deps - testImplementation "junit:junit:${rootProject.junitVersion}" - testImplementation "org.mockito:mockito-core:${rootProject.mockitoVersion}" + testImplementation libs.junit + testImplementation libs.mockito.core } // Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code. @@ -67,10 +59,11 @@ sourceSets { } } +def protocGrpcVersion = libs.versions.grpc.get() protobuf { - protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" } + protoc { artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}" } plugins { - grpc { artifact = "io.grpc:protoc-gen-grpc-java:${rootProject.grpcVersion}" } + grpc { artifact = "io.grpc:protoc-gen-grpc-java:${protocGrpcVersion}" } } generateProtoTasks { all()*.plugins { grpc {} } diff --git a/example-plugin/build.gradle b/example-plugin/build.gradle index eadaf26ce..0062bbe6e 100644 --- a/example-plugin/build.gradle +++ b/example-plugin/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.diffplug.spotless' version '6.22.0' + alias(libs.plugins.spotless) id 'distribution' // Generate IntelliJ IDEA's .idea & .iml project files id 'idea' @@ -23,21 +23,17 @@ group 'com.yelp.nrtsearch.plugins' version '0.0.1' ext { - assertjVersion = '3.26.3' - grpcVersion = "1.66.0" - junitVersion = "4.13.2" nrtsearchVersion = "1.+" - protobufVersion = "3.25.3" } dependencies { compileOnly "com.yelp.nrtsearch:server:${nrtsearchVersion}" testImplementation "com.yelp.nrtsearch:server:${nrtsearchVersion}" testImplementation("com.yelp.nrtsearch:server:${nrtsearchVersion}:tests") - testImplementation "junit:junit:${junitVersion}" - testImplementation "org.assertj:assertj-core:${assertjVersion}" - testImplementation "io.grpc:grpc-testing:${grpcVersion}" - testImplementation "com.google.protobuf:protobuf-java:${protobufVersion}" + testImplementation libs.assertj.core + testImplementation libs.grpc.testing + testImplementation libs.junit + testImplementation libs.protobuf.java } distributions { diff --git a/example-plugin/settings.gradle b/example-plugin/settings.gradle index f8d106068..afc3d418a 100644 --- a/example-plugin/settings.gradle +++ b/example-plugin/settings.gradle @@ -1,2 +1,8 @@ rootProject.name = 'example-plugin' - +dependencyResolutionManagement { + versionCatalogs { + libs { + from(files("../gradle/libs.versions.toml")) + } + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..a734216b9 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,69 @@ +[versions] +aws = "1.12.768" +grpc = "1.66.0" +jackson = "2.17.2" +log4j = "2.23.1" +lucene = "9.12.0" +prometheus = "1.3.1" +protobuf = "3.25.3" + +[libraries] +aws-java-sdk-core = { module = "com.amazonaws:aws-java-sdk-core", version.ref = "aws" } +aws-java-sdk-s3 = { module = "com.amazonaws:aws-java-sdk-s3", version.ref = "aws" } +aws-java-sdk-sts = { module = "com.amazonaws:aws-java-sdk-sts", version.ref = "aws" } +commons-compress = { module = "org.apache.commons:commons-compress", version = "1.27.0" } +commons-csv = { module = "org.apache.commons:commons-csv", version = "1.11.0" } +commons-io = { module = "commons-io:commons-io", version = "2.16.1" } +disruptor = { module = "com.lmax:disruptor", version = "4.0.0" } +fastutil = { module = "it.unimi.dsi:fastutil", version = "8.5.14" } +grpc-netty-shaded = { module = "io.grpc:grpc-netty-shaded", version.ref = "grpc" } +grpc-okhttp = { module = "io.grpc:grpc-okhttp", version.ref = "grpc" } +grpc-protobuf = { module = "io.grpc:grpc-protobuf", version.ref = "grpc" } +grpc-services = { module = "io.grpc:grpc-services", version.ref = "grpc" } +grpc-stub = { module = "io.grpc:grpc-stub", version.ref = "grpc" } +gson = { module = "com.google.code.gson:gson", version = "2.11.0" } +guice = { module = "com.google.inject:guice", version = "7.0.0" } +jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" } +jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" } +jakarta-xml-bind-api = { module = "jakarta.xml.bind:jakarta.xml.bind-api", version = "4.0.2" } +javax-annotation-api = { module = "javax.annotation:javax.annotation-api", version = "1.2" } +log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" } +log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" } +log4j-slf4j2-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version.ref = "log4j" } +lucene-analysis-common = { module = "org.apache.lucene:lucene-analysis-common", version.ref = "lucene" } +lucene-backward-codecs = { module = "org.apache.lucene:lucene-backward-codecs", version.ref = "lucene" } +lucene-core = { module = "org.apache.lucene:lucene-core", version.ref = "lucene" } +lucene-codecs = { module = "org.apache.lucene:lucene-codecs", version.ref = "lucene" } +lucene-expressions = { module = "org.apache.lucene:lucene-expressions", version.ref = "lucene" } +lucene-facet = { module = "org.apache.lucene:lucene-facet", version.ref = "lucene" } +lucene-grouping = { module = "org.apache.lucene:lucene-grouping", version.ref = "lucene" } +lucene-highlighter = { module = "org.apache.lucene:lucene-highlighter", version.ref = "lucene" } +lucene-join = { module = "org.apache.lucene:lucene-join", version.ref = "lucene" } +lucene-queries = { module = "org.apache.lucene:lucene-queries", version.ref = "lucene" } +lucene-queryparser = { module = "org.apache.lucene:lucene-queryparser", version.ref = "lucene" } +lucene-replicator = { module = "org.apache.lucene:lucene-replicator", version.ref = "lucene" } +lucene-suggest = { module = "org.apache.lucene:lucene-suggest", version.ref = "lucene" } +lz4-java = { module = "org.lz4:lz4-java", version = "1.8.0" } +picocli = { module = "info.picocli:picocli", version = "4.7.6" } +prometheus-metrics-core = { module = "io.prometheus:prometheus-metrics-core", version.ref = "prometheus"} +prometheus-metrics-exposition-formats = { module = "io.prometheus:prometheus-metrics-exposition-formats", version.ref = "prometheus"} +prometheus-metrics-instrumentation-jvm = { module = "io.prometheus:prometheus-metrics-instrumentation-jvm", version.ref = "prometheus"} +proto-google-common-protos = { module = "com.google.api.grpc:proto-google-common-protos", version = "2.41.0" } +protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobuf" } +protobuf-java-util = { module = "com.google.protobuf:protobuf-java-util", version.ref = "protobuf" } +slf4j-api = { module = "org.slf4j:slf4j-api", version = "2.0.16" } +snakeyaml = { module = "org.yaml:snakeyaml", version = "2.2" } + +assertj-core = { module = "org.assertj:assertj-core", version = "3.26.3" } +grpc-inprocess = { module = "io.grpc:grpc-inprocess", version.ref = "grpc" } +grpc-testing = { module = "io.grpc:grpc-testing", version.ref = "grpc" } +junit = { module = "junit:junit", version = "4.13.2" } +lucene-test-framework = { module = "org.apache.lucene:lucene-test-framework", version.ref = "lucene" } +mockito-core = { module = "org.mockito:mockito-core", version = "5.12.0" } +s3mock = { module = "io.findify:s3mock_2.13", version = "0.2.6" } +spatial4j = { module = "org.locationtech.spatial4j:spatial4j", version = "0.8" } + +[plugins] +protobuf = { id = "com.google.protobuf", version = "0.9.4" } +sphinx = { id = "kr.motd.sphinx", version = "2.10.1" } +spotless = { id = "com.diffplug.spotless", version = "6.25.0" } \ No newline at end of file