Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6174] Upgrade gradle from 7.6.1 to 8.7 #3591

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ node('ubuntu') {
withEnv(["Path+JDK=$JAVA_JDK_17/bin","JAVA_HOME=$JAVA_JDK_17"]) {
withCredentials([string(credentialsId: 'SONARCLOUD_TOKEN', variable: 'SONAR_TOKEN')]) {
if ( env.BRANCH_NAME.startsWith("PR-") ) {
sh './gradlew --no-parallel --no-daemon jacocoAggregateTestReport sonar -PenableJacoco -Dsonar.pullrequest.branch=${CHANGE_BRANCH} -Dsonar.pullrequest.base=${CHANGE_TARGET} -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.login=${SONAR_TOKEN}'
sh './gradlew --no-parallel --no-daemon jacocoAggregateTestReport sonar -PenableJacoco -Porg.sonarqube.version=4.4.1.3373 -Dsonar.pullrequest.branch=${CHANGE_BRANCH} -Dsonar.pullrequest.base=${CHANGE_TARGET} -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.login=${SONAR_TOKEN}'
zabetak marked this conversation as resolved.
Show resolved Hide resolved
} else {
sh './gradlew --no-parallel --no-daemon jacocoAggregateTestReport sonar -PenableJacoco -Dsonar.branch.name=${BRANCH_NAME} -Dsonar.login=${SONAR_TOKEN}'
sh './gradlew --no-parallel --no-daemon jacocoAggregateTestReport sonar -PenableJacoco -Porg.sonarqube.version=4.4.1.3373 -Dsonar.branch.name=${BRANCH_NAME} -Dsonar.login=${SONAR_TOKEN}'
}
}
}
Expand Down
66 changes: 45 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import com.github.vlsi.gradle.properties.dsl.props
import com.github.vlsi.gradle.release.RepositoryType
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApisExtension
import java.net.URI
import net.ltgt.gradle.errorprone.errorprone
import org.apache.calcite.buildtools.buildext.dsl.ParenthesisBalancer
import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
base
// java-base is needed for platform(...) resolution,
// see https://github.com/gradle/gradle/issues/14822
`java-base`
Expand Down Expand Up @@ -68,11 +68,6 @@ repositories {

tasks.wrapper {
zabetak marked this conversation as resolved.
Show resolved Hide resolved
distributionType = Wrapper.DistributionType.BIN
doLast {
val sha256Uri = URI("$distributionUrl.sha256")
val sha256Sum = String(sha256Uri.toURL().readBytes())
propertiesFile.appendText("distributionSha256Sum=${sha256Sum}\n")
}
}

fun reportsForHumans() = !(System.getenv()["CI"]?.toBoolean() ?: false)
Expand Down Expand Up @@ -193,7 +188,7 @@ val javadocAggregate by tasks.registering(Javadoc::class) {

classpath = files(sourceSets.map { set -> set.map { it.output + it.compileClasspath } })
setSource(sourceSets.map { set -> set.map { it.allJava } })
setDestinationDir(file("$buildDir/docs/javadocAggregate"))
setDestinationDir(file(layout.buildDirectory.get().file("docs/javadocAggregate")))
}

/** Similar to {@link #javadocAggregate} but includes tests.
Expand All @@ -208,7 +203,7 @@ val javadocAggregateIncludingTests by tasks.registering(Javadoc::class) {

classpath = files(sourceSets.map { set -> set.map { it.output + it.compileClasspath } })
setSource(sourceSets.map { set -> set.map { it.allJava } })
setDestinationDir(file("$buildDir/docs/javadocAggregateIncludingTests"))
setDestinationDir(file(layout.buildDirectory.get().file("docs/javadocAggregateIncludingTests")))
}

val adaptersForSqlline = listOf(
Expand All @@ -232,19 +227,43 @@ val sqllineClasspath by configurations.creating {
}
}

@CacheableRule
abstract class AddDependenciesRule @Inject constructor(val dependencies: List<String>) : ComponentMetadataRule {
override fun execute(context: ComponentMetadataContext) {
listOf("compile", "runtime").forEach { base ->
context.details.withVariant(base) {
withDependencies {
dependencies.forEach {
add(it)
}
}
}
}
}
}

dependencies {
sqllineClasspath(platform(project(":bom")))
sqllineClasspath(project(":testkit"))
sqllineClasspath("sqlline:sqlline")
for (p in adaptersForSqlline) {
sqllineClasspath(project(p))
}

components {
for (m in dataSetsForSqlline) {
withModule<AddDependenciesRule>(m)
}
}

for (m in dataSetsForSqlline) {
sqllineClasspath(module(m))
sqllineClasspath(m)
}
if (enableJacoco) {
for (p in subprojects) {
jacocoAggregation(p)
if (p.name != "bom") {
jacocoAggregation(p)
}
}
}
}
Expand Down Expand Up @@ -318,7 +337,7 @@ fun com.github.autostyle.gradle.BaseFormatExtension.license() {
sonarqube {
properties {
property("sonar.test.inclusions", "**/*Test*/**")
property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco/jacocoAggregateTestReport/jacocoAggregateTestReport.xml")
property("sonar.coverage.jacoco.xmlReportPaths", layout.buildDirectory.get().file("reports/jacoco/jacocoAggregateTestReport/jacocoAggregateTestReport.xml"))
}
}

Expand Down Expand Up @@ -449,7 +468,7 @@ allprojects {
// Unfortunately, Gradle passes only config_loc variable by default, so we make
// all the paths relative to config_loc
configProperties!!["cache_file"] =
buildDir.resolve("checkstyle/cacheFile").relativeTo(configLoc)
layout.buildDirectory.asFile.get().resolve("checkstyle/cacheFile").relativeTo(configLoc)
}
// afterEvaluate is to support late sourceSet addition (e.g. jmh sourceset)
afterEvaluate {
Expand Down Expand Up @@ -512,7 +531,7 @@ allprojects {
}

plugins.withType<JavaPlugin> {
configure<JavaPluginConvention> {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand Down Expand Up @@ -800,7 +819,7 @@ allprojects {
}
}
configureEach<Test> {
outputs.cacheIf("test results depend on the database configuration, so we souldn't cache it") {
outputs.cacheIf("test results depend on the database configuration, so we shouldn't cache it") {
false
}
useJUnitPlatform {
Expand Down Expand Up @@ -850,8 +869,8 @@ allprojects {
description = "$description (skipped by default, to enable it add -Dspotbugs)"
}
reports {
html.isEnabled = reportsForHumans()
xml.isEnabled = !reportsForHumans()
html.required.set(reportsForHumans())
xml.required.set(!reportsForHumans())
}
enabled = enableSpotBugs
}
Expand Down Expand Up @@ -908,8 +927,9 @@ allprojects {
archives(sourcesJar)
}

val archivesBaseName = "calcite-$name"
setProperty("archivesBaseName", archivesBaseName)
base {
archivesName.set("calcite-$name")
}

configure<PublishingExtension> {
if (project.path == ":") {
Expand All @@ -922,7 +942,7 @@ allprojects {
}
publications {
create<MavenPublication>(project.name) {
artifactId = archivesBaseName
artifactId = base.archivesName.get()
version = rootProject.version.toString()
description = project.description
from(components["java"])
Expand Down Expand Up @@ -964,10 +984,14 @@ allprojects {
// Re-format the XML
asNode()
}

fun capitalize(input: String): String {
return input.replaceFirstChar { it.uppercaseChar() }
}
name.set(
(project.findProperty("artifact.name") as? String) ?: "Calcite ${project.name.capitalize()}"
(project.findProperty("artifact.name") as? String) ?: "Calcite ${capitalize(project.name)}"
)
description.set(project.description ?: "Calcite ${project.name.capitalize()}")
description.set(project.description ?: "Calcite ${capitalize(project.name)}")
inceptionYear.set("2012")
url.set("https://calcite.apache.org")
licenses {
Expand Down
7 changes: 6 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ allprojects {
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

fun Project.applyKotlinProjectConventions() {
if (project != rootProject) {
apply(plugin = "org.gradle.kotlin.kotlin-dsl")
}

tasks.withType<KotlinCompile> {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include("buildext")
val upperCaseLetters = "\\p{Upper}".toRegex()

fun String.toKebabCase() =
replace(upperCaseLetters) { "-${it.value.toLowerCase()}" }
replace(upperCaseLetters) { "-${it.value.lowercase()}" }

fun buildFileNameFor(projectDirName: String) =
"$projectDirName.gradle.kts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ open class JavaCCTask @Inject constructor(
project.javaexec {
classpath = javaCCClasspath.get()
// The class is in the top-level package
main = "javacc"
getMainClass().set("javacc")
args("-STATIC=${static.get()}")
args("-LOOKAHEAD:${lookAhead.get()}")
args("-OUTPUT_DIRECTORY:${output.get()}/${packageName.get().replace('.', '/')}")
Expand Down
17 changes: 13 additions & 4 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ tasks.jar {
}
}

val generatedVersionDir = File(buildDir, "generated/sources/version")
val generatedVersionDir = layout.buildDirectory.get().file("generated/sources/version")
val versionClass by tasks.registering(Sync::class) {
val re = Regex("^(\\d+)\\.(\\d+).*")

Expand Down Expand Up @@ -150,7 +150,7 @@ val versionClass by tasks.registering(Sync::class) {
}

ide {
generatedJavaSources(versionClass.get(), generatedVersionDir)
generatedJavaSources(versionClass.get(), generatedVersionDir.asFile)
}

sourceSets {
Expand Down Expand Up @@ -212,6 +212,11 @@ tasks.withType<AutostyleTask>().configureEach {
mustRunAfter(javaCCTest)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}
ide {
fun generatedSource(javacc: TaskProvider<org.apache.calcite.buildtools.javacc.JavaCCTask>, sourceSet: String) =
generatedJavaSources(javacc.get(), javacc.get().output.get().asFile, sourceSets.named(sourceSet))
Expand Down Expand Up @@ -271,16 +276,20 @@ val integTestAll by tasks.registering() {
description = "Executes integration JDBC tests for all DBs"
}

fun capitalize(input: String): String {
return input.replaceFirstChar { it.uppercaseChar() }
}

for (db in listOf("h2", "mysql", "oracle", "postgresql")) {
val task = tasks.register("integTest" + db.capitalize(), Test::class) {
val task = tasks.register("integTest" + capitalize(db), Test::class) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Executes integration JDBC tests with $db database"
include("org/apache/calcite/test/JdbcAdapterTest.class")
include("org/apache/calcite/test/JdbcTest.class")
systemProperty("calcite.test.db", db)
// Include the jars from the custom configuration to the classpath
// otherwise the JDBC drivers for each DBMS will be missing
classpath = classpath + configurations.getAt("test" + db.capitalize())
classpath += configurations.getAt("test" + capitalize(db))
}
integTestAll {
dependsOn(task)
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ com.github.spotbugs.version=2.0.0
com.github.vlsi.vlsi-release-plugins.version=1.90
com.google.protobuf.version=0.8.10
de.thetaphi.forbiddenapis.version=3.5.1
jacoco.version=0.8.10
kotlin.version=1.7.10
jacoco.version=0.8.12
kotlin.version=1.9.22
net.ltgt.errorprone.version=1.3.0
me.champeau.gradle.jmh.version=0.5.3
me.champeau.jmh.version=0.7.2
org.jetbrains.gradle.plugin.idea-ext.version=0.5
org.nosphere.apache.rat.version=0.7.0
org.nosphere.apache.rat.version=0.8.1
org.owasp.dependencycheck.version=6.1.6
org.sonarqube.version=3.5.0.2730
com.gradle.enterprise.version=3.13.2
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=6147605a23b4eff6c334927a86ff3508cb5d6722cd624c97ded4c2e8640f1f87
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# 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"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
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
# shellcheck disable=SC2039,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
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# 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, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pluginManagement {
idv("com.google.protobuf")
idv("de.thetaphi.forbiddenapis")
idv("jacoco")
idv("me.champeau.gradle.jmh")
idv("me.champeau.jmh")
idv("net.ltgt.errorprone")
idv("org.jetbrains.gradle.plugin.idea-ext")
idv("org.nosphere.apache.rat")
Expand Down
Loading
Loading