Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#17] feat(build): refactor the gradle script to consolidate the dependecy and plugin version (#18)

Saisai Shao1c908725f042
diff --git a/build.gradle.kts b/build.gradle.kts
index b240961fdb..6b46c4022b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,16 +5,19 @@ plugins {
`maven-publish`
id("java")
id("idea")
- id("com.github.vlsi.gradle-extensions") version "1.74"
- id("com.diffplug.spotless") version "6.11.0"
- id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
+ alias(libs.plugins.gradle.extensions)
+ alias(libs.plugins.spotless)
+ alias(libs.plugins.publish)
}
repositories { mavenCentral() }
-java { toolchain { languageVersion.set(JavaLanguageVersion.of(8)) } }
-
-dependencies {
+java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(8))
+ withJavadocJar()
+ withSourcesJar()
+ }
}
allprojects {
diff --git a/gradle.properties b/gradle.properties
index c8d97dae42..e773d3d923 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -8,10 +8,6 @@ org.jetbrains.gradle.plugin.idea-ext.version=0.5
kotlin.version=1.5.31
com.github.vlsi.vlsi-release-plugins.version=1.74
-# dependencies
-junit5.version=5.8.1
-protoc.version=3.17.3
-
#version that is going to be updated automatically by releases
version = 0.1.0
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 0000000000..fadd28c467
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,18 @@
+[versions]
+junit = "5.8.1"
+protoc = "3.17.3"
+protobuf-plugin = "0.9.2"
+spotless-plugin = '6.11.0'
+gradle-extensions-plugin = '1.74'
+publish-plugin = '1.1.0'
+
+[libraries]
+protobuf-java = { group = "com.google.protobuf", name = "protobuf-java", version.ref = "protoc" }
+
+[bundles]
+
+[plugins]
+protobuf = { id = "com.google.protobuf", version.ref = "protobuf-plugin" }
+spotless = { id = "com.diffplug.spotless", version.ref = "spotless-plugin" }
+gradle-extensions = { id = "com.github.vlsi.gradle-extensions", version.ref = "gradle-extensions-plugin" }
+publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "publish-plugin" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index aa991fceae..4a0a58d550 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
+# checksum was taken from https://gradle.org/release-checksums
+distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
+networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 1b6c787337..0c913deb55 100755
--- a/gradlew
+++ b/gradlew
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,14 @@ do
esac
done
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-APP_NAME="Gradle"
+# This is normally unused
+# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+if [ ! -e $APP_HOME/gradle/wrapper/gradle-wrapper.jar ]; then
+ curl -o $APP_HOME/gradle/wrapper/gradle-wrapper.jar https://raw.githubusercontent.com/gradle/gradle/v8.1.1/gradle/wrapper/gradle-wrapper.jar
+fi
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -143,12 +144,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -193,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
@@ -205,6 +214,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index ac1b06f938..0000000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,89 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/schema/build.gradle.kts b/schema/build.gradle.kts
index 5afba856ba..0c5168a636 100644
--- a/schema/build.gradle.kts
+++ b/schema/build.gradle.kts
@@ -4,20 +4,12 @@ plugins {
`maven-publish`
id("java")
id("idea")
- id("com.google.protobuf") version "0.9.2"
- id("com.diffplug.spotless") version "6.11.0"
+ alias(libs.plugins.protobuf)
+ alias(libs.plugins.spotless)
}
dependencies {
- implementation("com.google.protobuf:protobuf-java:${project.property("protoc.version")}")
-}
-
-java {
- toolchain {
- languageVersion.set(JavaLanguageVersion.of(8))
- withJavadocJar()
- withSourcesJar()
- }
+ implementation(libs.protobuf.java)
}
sourceSets {
@@ -28,5 +20,5 @@ sourceSets {
}
protobuf {
- protoc { artifact = "com.google.protobuf:protoc:${project.property("protoc.version")}" }
+ protoc { artifact = "com.google.protobuf:protoc:${libs.versions.protoc.get()}"}
}
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 24255d8a3c..bcf2b2ae36 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,14 +1,3 @@
rootProject.name = "Unified Catalog"
include("api", "core", "schema", "server")
-
-pluginManagement {
- plugins {
- fun String.v() = extra["$this.version"].toString()
- fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v()
-
- idv("com.google.protobuf")
- idv("org.jetbrains.gradle.plugin.idea-ext")
- kotlin("jvm") version "kotlin".v()
- }
-}