diff --git a/Jenkinsfile b/Jenkinsfile index 53cc1e6f31f..7ff37aba28c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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}' } 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}' } } } diff --git a/build.gradle.kts b/build.gradle.kts index 0f4ff553db4..60d340ac34e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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` @@ -68,11 +68,6 @@ repositories { tasks.wrapper { 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) @@ -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. @@ -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( @@ -232,6 +227,21 @@ val sqllineClasspath by configurations.creating { } } +@CacheableRule +abstract class AddDependenciesRule @Inject constructor(val dependencies: List) : 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")) @@ -239,12 +249,21 @@ dependencies { for (p in adaptersForSqlline) { sqllineClasspath(project(p)) } + + components { + for (m in dataSetsForSqlline) { + withModule(m) + } + } + for (m in dataSetsForSqlline) { - sqllineClasspath(module(m)) + sqllineClasspath(m) } if (enableJacoco) { for (p in subprojects) { - jacocoAggregation(p) + if (p.name != "bom") { + jacocoAggregation(p) + } } } } @@ -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")) } } @@ -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 { @@ -512,7 +531,7 @@ allprojects { } plugins.withType { - configure { + configure { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } @@ -800,7 +819,7 @@ allprojects { } } configureEach { - 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 { @@ -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 } @@ -908,8 +927,9 @@ allprojects { archives(sourcesJar) } - val archivesBaseName = "calcite-$name" - setProperty("archivesBaseName", archivesBaseName) + base { + archivesName.set("calcite-$name") + } configure { if (project.path == ":") { @@ -922,7 +942,7 @@ allprojects { } publications { create(project.name) { - artifactId = archivesBaseName + artifactId = base.archivesName.get() version = rootProject.version.toString() description = project.description from(components["java"]) @@ -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 { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 06f486a9fcd..fdf111eef79 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -45,6 +45,11 @@ allprojects { dirMode = "775".toInt(8) fileMode = "664".toInt(8) } + + java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } } fun Project.applyKotlinProjectConventions() { @@ -52,7 +57,7 @@ fun Project.applyKotlinProjectConventions() { apply(plugin = "org.gradle.kotlin.kotlin-dsl") } - tasks.withType { + tasks.withType().configureEach { kotlinOptions { jvmTarget = "1.8" } diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index 1149c90d8d7..e3b6a38b804 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -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" diff --git a/buildSrc/subprojects/javacc/src/main/kotlin/org/apache/calcite/buildtools/javacc/JavaCCTask.kt b/buildSrc/subprojects/javacc/src/main/kotlin/org/apache/calcite/buildtools/javacc/JavaCCTask.kt index 340b7d8cbdf..38270621898 100644 --- a/buildSrc/subprojects/javacc/src/main/kotlin/org/apache/calcite/buildtools/javacc/JavaCCTask.kt +++ b/buildSrc/subprojects/javacc/src/main/kotlin/org/apache/calcite/buildtools/javacc/JavaCCTask.kt @@ -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('.', '/')}") diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 9674eb8d921..ede7dfee7bf 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -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+).*") @@ -150,7 +150,7 @@ val versionClass by tasks.registering(Sync::class) { } ide { - generatedJavaSources(versionClass.get(), generatedVersionDir) + generatedJavaSources(versionClass.get(), generatedVersionDir.asFile) } sourceSets { @@ -212,6 +212,11 @@ tasks.withType().configureEach { mustRunAfter(javaCCTest) } +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = "1.8" + } +} ide { fun generatedSource(javacc: TaskProvider, sourceSet: String) = generatedJavaSources(javacc.get(), javacc.get().output.get().asFile, sourceSets.named(sourceSet)) @@ -271,8 +276,12 @@ 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") @@ -280,7 +289,7 @@ for (db in listOf("h2", "mysql", "oracle", "postgresql")) { 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) diff --git a/gradle.properties b/gradle.properties index 3015b91b3d1..e43da370954 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa75..d64cd491770 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 49b350a3a55..bcc1d6e79ea 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index 65dcd68d65c..1aa94a42690 100755 --- a/gradlew +++ b/gradlew @@ -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 @@ -133,10 +131,13 @@ 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. @@ -144,7 +145,7 @@ 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 @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | 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 @@ -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" \ diff --git a/settings.gradle.kts b/settings.gradle.kts index adb373f79b9..9033080d1d4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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") diff --git a/site/_docs/howto.md b/site/_docs/howto.md index 26571eb5b36..9304c153f6f 100644 --- a/site/_docs/howto.md +++ b/site/_docs/howto.md @@ -32,7 +32,7 @@ adapters. ## Building from a source distribution Prerequisite is Java (JDK 8, 11, 17 or 19) -and Gradle (version 7.6.1) on your path. +and Gradle (version 8.7) on your path. Unpack the source distribution `.tar.gz` file, `cd` to the root directory of the unpacked source, @@ -91,7 +91,7 @@ For more information about Gradle, check the following links: ## Upgrade Gradle and the Gradle Wrapper -Gradle's [documentation](https://docs.gradle.org/current/userguide/upgrading_version_7.html) +Gradle's [documentation](https://docs.gradle.org/current/userguide/upgrading_version_8.html) provides detailed information about how to upgrade Gradle. Here is a list of steps: 1. Run `./gradlew help --warning-mode=all` to find out whether you are @@ -99,10 +99,8 @@ provides detailed information about how to upgrade Gradle. Here is a list of ste 2. Fix the deprecations and repeat the previous step to confirm they are fixed. This is a step where Gradle doc could be very helpful since it contains info about deprecations and how to cope with them. -3. Run `./gradlew wrapper --gradle-version ` to upgrade - Gradle. If necessary it will also upgrade the Gradle Wrapper. - This step also updates `gradle/wrapper/gradle-wrapper.properties`, - including the checksum. +3. Run `./gradlew wrapper --gradle-version= --gradle-distribution-sha256-sum=` + to upgrade Gradle. Checksum should be taken from [Gradle release checksums](https://gradle.org/release-checksums/). 4. Check and update Kotlin version in `gradle.properties` if required. Check should be done against [Kotlin compatibility matrix](https://docs.gradle.org/current/userguide/compatibility.html#kotlin). 5. Step 3 will have removed the header from diff --git a/testkit/build.gradle.kts b/testkit/build.gradle.kts index 5f4ab9f5544..dba83160d39 100644 --- a/testkit/build.gradle.kts +++ b/testkit/build.gradle.kts @@ -41,3 +41,9 @@ dependencies { testImplementation(kotlin("test")) testImplementation(kotlin("test-junit5")) } + +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = "1.8" + } +} diff --git a/ubenchmark/build.gradle.kts b/ubenchmark/build.gradle.kts index 7af86bb4616..1764da53f57 100644 --- a/ubenchmark/build.gradle.kts +++ b/ubenchmark/build.gradle.kts @@ -15,7 +15,7 @@ * limitations under the License. */ plugins { - id("me.champeau.gradle.jmh") + id("me.champeau.jmh") } dependencies { @@ -31,7 +31,7 @@ dependencies { } // See https://github.com/melix/jmh-gradle-plugin -// Unfortunately, current jmh-gradle-plugin does not allow to cusomize jmh parameters from the +// Unfortunately, current jmh-gradle-plugin does not allow to customize jmh parameters from the // command line, so the workarounds are: // a) Build and execute the jar itself: ./gradlew jmhJar && java -jar build/libs/calcite-...jar JMH_OPTIONS // b) Execute benchmarks via .main() methods from IDE (you might want to activate "power save mode" @@ -44,7 +44,7 @@ tasks.withType().configureEach { // At best jmh plugin should add the generated directories to the Gradle model, however, // currently it builds the jar only :-/ // IntelliJ IDEA "execute main method" adds a JavaExec task, so we configure it - classpath(File(buildDir, "jmh-generated-classes")) - classpath(File(buildDir, "jmh-generated-resources")) + classpath(File(layout.buildDirectory.asFile.get(), "jmh-generated-classes")) + classpath(File(layout.buildDirectory.asFile.get(), "jmh-generated-resources")) } }