postgresql-jdbc.git / summary / log / commit / refs

commit    a714bfd2ae5cf0721e5669c67d8b7752b4117d90
Author:   Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
Commit:   GitHub <noreply@github.com>
Date:     Thu Feb 09 12:16:25 2023 +0000

    chore: split /build.gradle.kts to build-logic/ plugins (#2755)
    
    See https://docs.gradle.org/current/userguide/structuring_software_products.html


benchmarks/build.gradle.kts | 24 +- bom/build.gradle.kts | 66 -- build-logic-commons/.gitignore | 1 + build-logic-commons/gradle-plugin/build.gradle.kts | 24 + ...build-logic.kotlin-dsl-gradle-plugin.gradle.kts | 18 + build-logic-commons/settings.gradle.kts | 9 + build-logic/.gitignore | 1 + build-logic/README.md | 27 + build-logic/basics/build.gradle.kts | 7 + .../kotlin/build-logic.repositories.gradle.kts | 10 + .../build-logic.reproducible-builds.gradle.kts | 7 + build-logic/build-parameters/build.gradle.kts | 64 ++ build-logic/build.gradle.kts | 3 + .../java-comment-preprocessor/build.gradle.kts | 8 + ...uild-logic.java-comment-preprocessor.gradle.kts | 27 + .../buildlogic}/JavaCommentPreprocessorTask.kt | 2 +- build-logic/jvm/build.gradle.kts | 17 + .../kotlin/build-logic.dokka-javadoc.gradle.kts | 18 + .../kotlin/build-logic.java-library.gradle.kts | 4 + .../src/main/kotlin/build-logic.java.gradle.kts | 126 ++++ .../src/main/kotlin/build-logic.kotlin.gradle.kts | 30 + .../main/kotlin/build-logic.test-base.gradle.kts | 44 ++ .../main/kotlin/build-logic.test-junit5.gradle.kts | 39 ++ build-logic/publishing/build.gradle.kts | 12 + .../build-logic.java-published-library.gradle.kts | 31 + .../build-logic.publish-to-central.gradle.kts | 137 +++++ ...uild-logic.publish-to-tmp-maven-repo.gradle.kts | 41 ++ build-logic/root-build/build.gradle.kts | 3 + .../main/kotlin/build-logic.root-build.gradle.kts | 0 build-logic/settings.gradle.kts | 16 + build-logic/verification/build.gradle.kts | 14 + .../main/kotlin/build-logic.autostyle.gradle.kts | 36 ++ .../kotlin/build-logic.checkerframework.gradle.kts | 45 ++ .../main/kotlin/build-logic.checkstyle.gradle.kts | 32 + .../main/kotlin/build-logic.errorprone.gradle.kts | 33 + .../kotlin/build-logic.forbidden-apis.gradle.kts | 24 + .../src/main/kotlin/build-logic.jacoco.gradle.kts | 51 ++ .../main/kotlin/build-logic.spotbugs.gradle.kts | 41 ++ .../src/main/kotlin/build-logic.style.gradle.kts | 46 ++ build.gradle.kts | 685 +-------------------- buildSrc/build.gradle.kts | 51 -- buildSrc/gradle.properties | 13 - buildSrc/settings.gradle.kts | 13 - gradle.properties | 47 +- pgjdbc-osgi-test/build.gradle.kts | 22 +- pgjdbc/build.gradle.kts | 105 ++-- pgjdbc/reduced-pom.xml | 19 +- .../java/org/postgresql/jdbc/PgConnection.java | 2 + .../org/postgresql/jdbc/PgDatabaseMetaData.java | 4 + .../org/postgresql/largeobject/LargeObject.java | 1 + .../postgresql/largeobject/LargeObjectManager.java | 1 + .../org/postgresql/osgi/PGDataSourceFactory.java | 4 + settings.gradle.kts | 45 +- 53 files changed, 1171 insertions(+), 979 deletions(-) diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index e610b9a1..52f7aa07 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -1,31 +1,17 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2020, PostgreSQL Global Development Group + * See the LICENSE file in the project root for more information. */ plugins { + id("build-logic.java-library") id("me.champeau.jmh") } dependencies { // Make jmhCompileClasspath resolvable - jmhImplementation(platform(project(":bom"))) jmhImplementation(project(":postgresql")) -// jmhImplementation("com.google.guava:guava") -// jmhImplementation("org.codehaus.janino:commons-compiler") - jmhImplementation("org.openjdk.jmh:jmh-core") - jmhImplementation("org.openjdk.jmh:jmh-generator-annprocess") + jmhImplementation("org.openjdk.jmh:jmh-core:1.12") + jmhImplementation("org.openjdk.jmh:jmh-generator-annprocess:1.12") } // See https://github.com/melix/jmh-gradle-plugin diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts deleted file mode 100644 index e6d6216f..00000000 --- a/bom/build.gradle.kts +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2019, PostgreSQL Global Development Group - * See the LICENSE file in the project root for more information. - */ - -plugins { - `java-platform` -} - -val String.v: String get() = rootProject.extra["$this.version"] as String - -// Note: Gradle allows to declare dependency on "bom" as "api", -// and it makes the constraints to be transitively visible -// However Maven can't express that, so the approach is to use Gradle resolution -// and generate pom files with resolved versions -// See https://github.com/gradle/gradle/issues/9866 - -fun DependencyConstraintHandlerScope.apiv( - notation: String, - versionProp: String = notation.substringAfterLast(':') -) = - "api"(notation + ":" + versionProp.v) - -fun DependencyConstraintHandlerScope.runtimev( - notation: String, - versionProp: String = notation.substringAfterLast(':') -) = - "runtime"(notation + ":" + versionProp.v) - -dependencies { - // Parenthesis are needed here: https://github.com/gradle/gradle/issues/9248 - (constraints) { - // api means "the dependency is for both compilation and runtime" - // runtime means "the dependency is only for runtime, not for compilation" - // In other words, marking dependency as "runtime" would avoid accidental - // dependency on it during compilation - apiv("ch.qos.logback:logback-classic", "logback") - apiv("ch.qos.logback:logback-core", "logback") - apiv("com.github.waffle:waffle-jna") - apiv("com.ongres.scram:client", "com.ongres.scram.client") - apiv("javax:javaee-api") - apiv("junit:junit", "junit4") - apiv("org.apache.felix:org.apache.felix.framework") - apiv("org.checkerframework:checker-qual", "checkerframework") - apiv("org.hamcrest:hamcrest") - apiv("org.hamcrest:hamcrest-core", "hamcrest") - apiv("org.hamcrest:hamcrest-library", "hamcrest") - apiv("org.junit.jupiter:junit-jupiter-api", "junit5") - apiv("uk.org.webcompere:system-stubs-jupiter", "junit5-system-stubs-jupiter") - apiv("org.junit.jupiter:junit-jupiter-params", "junit5") - apiv("org.openjdk.jmh:jmh-generator-annprocess", "jmh") - apiv("org.ops4j.pax.exam:pax-exam-container-native", "org.ops4j.pax.exam") - apiv("org.ops4j.pax.exam:pax-exam-junit4", "org.ops4j.pax.exam") - apiv("org.ops4j.pax.exam:pax-exam-junit4", "org.ops4j.pax.exam") - apiv("org.ops4j.pax.exam:pax-exam-link-mvn", "org.ops4j.pax.exam") - apiv("org.ops4j.pax.url:pax-url-aether") - apiv("org.osgi:org.osgi.core") - apiv("org.osgi:org.osgi.service.jdbc") - apiv("org.slf4j:slf4j-api", "slf4j") - apiv("org.slf4j:slf4j-log4j12", "slf4j") - apiv("se.jiderhamn:classloader-leak-test-framework") - runtimev("org.junit.jupiter:junit-jupiter-engine", "junit5") - runtimev("org.junit.vintage:junit-vintage-engine", "junit5") - runtimev("org.openjdk.jmh:jmh-core", "jmh") - } -} diff --git a/build-logic-commons/.gitignore b/build-logic-commons/.gitignore new file mode 100644 index 00000000..de8b1374 --- /dev/null +++ b/build-logic-commons/.gitignore @@ -0,0 +1 @@ +/*/build/ diff --git a/build-logic-commons/gradle-plugin/build.gradle.kts b/build-logic-commons/gradle-plugin/build.gradle.kts new file mode 100644 index 00000000..5e8128c5 --- /dev/null +++ b/build-logic-commons/gradle-plugin/build.gradle.kts @@ -0,0 +1,24 @@ +import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion + +plugins { + `kotlin-dsl` +} + +group = "org.postgresql.build-logic" + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +dependencies { + // We use precompiled script plugins (== plugins written as src/kotlin/build-logic.*.gradle.kts files, + // and we need to declare dependency on org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin + // to make it work. + // See https://github.com/gradle/gradle/issues/17016 regarding expectedKotlinDslPluginsVersion + implementation("org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:$expectedKotlinDslPluginsVersion") +} + +kotlinDslPluginOptions { + jvmTarget.set("1.8") +} diff --git a/build-logic-commons/gradle-plugin/src/main/kotlin/build-logic.kotlin-dsl-gradle-plugin.gradle.kts b/build-logic-commons/gradle-plugin/src/main/kotlin/build-logic.kotlin-dsl-gradle-plugin.gradle.kts new file mode 100644 index 00000000..a1e75096 --- /dev/null +++ b/build-logic-commons/gradle-plugin/src/main/kotlin/build-logic.kotlin-dsl-gradle-plugin.gradle.kts @@ -0,0 +1,18 @@ +plugins { + id("java-library") + id("org.gradle.kotlin.kotlin-dsl") // this is 'kotlin-dsl' without version +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.validatePlugins { + failOnWarning.set(true) + enableStricterValidation.set(true) +} + +kotlinDslPluginOptions { + jvmTarget.set("1.8") +} diff --git a/build-logic-commons/settings.gradle.kts b/build-logic-commons/settings.gradle.kts new file mode 100644 index 00000000..e32971bd --- /dev/null +++ b/build-logic-commons/settings.gradle.kts @@ -0,0 +1,9 @@ +dependencyResolutionManagement { + repositories { + gradlePluginPortal() + } +} + +rootProject.name = "build-logic-commons" + +include("gradle-plugin") diff --git a/build-logic/.gitignore b/build-logic/.gitignore new file mode 100644 index 00000000..de8b1374 --- /dev/null +++ b/build-logic/.gitignore @@ -0,0 +1 @@ +/*/build/ diff --git a/build-logic/README.md b/build-logic/README.md new file mode 100644 index 00000000..ca1a27b6 --- /dev/null +++ b/build-logic/README.md @@ -0,0 +1,27 @@ +# Build logic for pgjdbc + +This is a subset of extra plugins for factoring out +the common patterns from the common build logic. + +The recommended approach is to use build composition, so every build script +should list all its prerequisites in the top-most `plugins { ... }` block. + +The use of `allprojects` and `subprojects` is an anti-pattern as it makes it hard to identify +the configuration for a given project. + +Let us consider an example (see `/pgjdbc/build.gradle.kts`): + +```kotlin +plugins { + id("build-logic.java-published-library") + id("build-logic.test-junit5") +} + +... +``` + +It means that we deal with a Java library that will be published to Central, +and which uses JUnit 5 for testing. + +If you want to see what the logic does, you could open `build-logic.java-published-library.gradle.kts` +and `buildlogic.test-junit5.gradle.kts`. diff --git a/build-logic/basics/build.gradle.kts b/build-logic/basics/build.gradle.kts new file mode 100644 index 00000000..16006a29 --- /dev/null +++ b/build-logic/basics/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + id("build-logic.kotlin-dsl-gradle-plugin") +} + +dependencies { + implementation(project(":build-parameters")) +} diff --git a/build-logic/basics/src/main/kotlin/build-logic.repositories.gradle.kts b/build-logic/basics/src/main/kotlin/build-logic.repositories.gradle.kts new file mode 100644 index 00000000..b0e41864 --- /dev/null +++ b/build-logic/basics/src/main/kotlin/build-logic.repositories.gradle.kts @@ -0,0 +1,10 @@ +plugins { + id("build-logic.build-params") +} + +repositories { + if (buildParameters.enableMavenLocal) { + mavenLocal() + } + mavenCentral() +} diff --git a/build-logic/basics/src/main/kotlin/build-logic.reproducible-builds.gradle.kts b/build-logic/basics/src/main/kotlin/build-logic.reproducible-builds.gradle.kts new file mode 100644 index 00000000..cab15140 --- /dev/null +++ b/build-logic/basics/src/main/kotlin/build-logic.reproducible-builds.gradle.kts @@ -0,0 +1,7 @@ +tasks.withType<AbstractArchiveTask>().configureEach { + // Ensure builds are reproducible + isPreserveFileTimestamps = false + isReproducibleFileOrder = true + dirMode = "775".toInt(8) + fileMode = "664".toInt(8) +} diff --git a/build-logic/build-parameters/build.gradle.kts b/build-logic/build-parameters/build.gradle.kts new file mode 100644 index 00000000..46e302b0 --- /dev/null +++ b/build-logic/build-parameters/build.gradle.kts @@ -0,0 +1,64 @@ +plugins { + id("org.gradlex.build-parameters") version "1.4.1" + id("com.github.vlsi.gradle-extensions") version "1.86" + id("build-logic.kotlin-dsl-gradle-plugin") +} + +buildParameters { + // Other plugins can contribute parameters, so below list is not exhaustive + enableValidation.set(false) + pluginId("build-logic.build-params") + bool("enableMavenLocal") { + defaultValue.set(true) + description.set("Add mavenLocal() to repositories") + } + bool("coverage") { + defaultValue.set(false) + description.set("Collect test coverage") + } + bool("spotbugs") { + defaultValue.set(false) + description.set("Run SpotBugs verifications") + } + bool("enableCheckerframework") { + defaultValue.set(false) + description.set("Run CheckerFramework (nullness) verifications") + } + bool("enableErrorprone") { + defaultValue.set(false) + description.set("Run ErrorProne verifications") + } + bool("skipCheckstyle") { + defaultValue.set(false) + description.set("Skip Checkstyle verifications") + } + bool("skipAutostyle") { + defaultValue.set(false) + description.set("Skip AutoStyle verifications") + } + bool("skipForbiddenApis") { + defaultValue.set(false) + description.set("Skip forbidden-apis verifications") + } + bool("skipJavadoc") { + defaultValue.set(false) + description.set("Skip javadoc generation") + } + bool("failOnJavadocWarning") { + defaultValue.set(true) + description.set("Fail build on javadoc warnings") + } + bool("enableGradleMetadata") { + defaultValue.set(false) + description.set("Generate and publish Gradle Module Metadata") + } + // Note: it does not work in tr_TR locale due to https://github.com/gradlex-org/build-parameters/issues/87 + string("includeTestTags") { + defaultValue.set("") + description.set("Lists tags to include in test execution. For instance -PincludeTestTags=!org.postgresql.test.SlowTests, or or -PincludeTestTags=!org.postgresql.test.Replication") + } + bool("useGpgCmd") { + defaultValue.set(false) + description.set("By default use Java implementation to sign artifacts. When useGpgCmd=true, then gpg command line tool is used for signing artifacts") + } +} diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 00000000..6fc4b501 --- /dev/null +++ b/build-logic/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + `embedded-kotlin` apply false +} diff --git a/build-logic/java-comment-preprocessor/build.gradle.kts b/build-logic/java-comment-preprocessor/build.gradle.kts new file mode 100644 index 00000000..d5547dc8 --- /dev/null +++ b/build-logic/java-comment-preprocessor/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + id("build-logic.kotlin-dsl-gradle-plugin") +} + +dependencies { + implementation("com.igormaznitsa:jcp:7.0.2") + implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.86") +} diff --git a/build-logic/java-comment-preprocessor/src/main/kotlin/build-logic.java-comment-preprocessor.gradle.kts b/build-logic/java-comment-preprocessor/src/main/kotlin/build-logic.java-comment-preprocessor.gradle.kts new file mode 100644 index 00000000..d63eaf22 --- /dev/null +++ b/build-logic/java-comment-preprocessor/src/main/kotlin/build-logic.java-comment-preprocessor.gradle.kts @@ -0,0 +1,27 @@ +import com.github.vlsi.gradle.dsl.configureEach +import com.github.vlsi.gradle.properties.dsl.props + +plugins { + id("com.github.vlsi.gradle-extensions") +} + +tasks.configureEach<buildlogic.JavaCommentPreprocessorTask> { + variables.apply { + val jdbcSpec = props.string("jdbc.specification.version") + put("mvn.project.property.postgresql.jdbc.spec", "JDBC$jdbcSpec") + put("jdbc.specification.version", jdbcSpec) + } + + val re = Regex("^(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*") + + val version = project.version.toString() + val matchResult = re.find(version) ?: throw GradleException("Unable to parse major.minor.patch version parts from project.version '$version'") + val (major, minor, patch) = matchResult.destructured + + variables.apply { + put("version", version) + put("version.major", major) + put("version.minor", minor) + put("version.patch", patch.ifBlank { "0" }) + } +} diff --git a/buildSrc/src/main/kotlin/org/postgresql/buildtools/JavaCommentPreprocessorTask.kt b/build-logic/java-comment-preprocessor/src/main/kotlin/buildlogic/JavaCommentPreprocessorTask.kt similarity index 98% rename from buildSrc/src/main/kotlin/org/postgresql/buildtools/JavaCommentPreprocessorTask.kt rename to build-logic/java-comment-preprocessor/src/main/kotlin/buildlogic/JavaCommentPreprocessorTask.kt index 41d093fc..22cbb1e0 100644 --- a/buildSrc/src/main/kotlin/org/postgresql/buildtools/JavaCommentPreprocessorTask.kt +++ b/build-logic/java-comment-preprocessor/src/main/kotlin/buildlogic/JavaCommentPreprocessorTask.kt @@ -3,7 +3,7 @@ * See the LICENSE file in the project root for more information. */ -package org.postgresql.buildtools +package buildlogic import com.igormaznitsa.jcp.JcpPreprocessor import com.igormaznitsa.jcp.context.PreprocessorContext diff --git a/build-logic/jvm/build.gradle.kts b/build-logic/jvm/build.gradle.kts new file mode 100644 index 00000000..777a64eb --- /dev/null +++ b/build-logic/jvm/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("build-logic.kotlin-dsl-gradle-plugin") +} + +dependencies { + implementation(project(":build-parameters")) + implementation(project(":verification")) + implementation("com.github.vlsi.crlf:com.github.vlsi.crlf.gradle.plugin:1.86") + implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.86") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin") + implementation("com.igormaznitsa:jcp:7.0.2") + implementation("org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:$embeddedKotlinVersion") + implementation("com.github.autostyle:com.github.autostyle.gradle.plugin:3.2") + implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:3.0.1") + implementation("com.github.vlsi.jandex:com.github.vlsi.jandex.gradle.plugin:1.86") + implementation("de.thetaphi.forbiddenapis:de.thetaphi.forbiddenapis.gradle.plugin:3.3") +} diff --git a/build-logic/jvm/src/main/kotlin/build-logic.dokka-javadoc.gradle.kts b/build-logic/jvm/src/main/kotlin/build-logic.dokka-javadoc.gradle.kts new file mode 100644 index 00000000..ade4db86 --- /dev/null +++ b/build-logic/jvm/src/main/kotlin/build-logic.dokka-javadoc.gradle.kts @@ -0,0 +1,18 @@ +plugins { + id("java-base") + id("org.jetbrains.dokka") +} + +java { + // Workaround https://github.com/gradle/gradle/issues/21933, so it adds javadocElements configuration + withJavadocJar() +} + +val dokkaJar by tasks.registering(Jar::class) { + group = LifecycleBasePlugin.BUILD_GROUP + description = "Assembles a jar archive containing javadoc" + from(tasks.dokkaJavadoc) + archiveClassifier.set("javadoc") +} + +configurations[JavaPlugin.JAVADOC_ELEMENTS_CONFIGURATION_NAME].outgoing.artifact(dokkaJar) diff --git a/build-logic/jvm/src/main/kotlin/build-logic.java-library.gradle.kts b/build-logic/jvm/src/main/kotlin/build-logic.java-library.gradle.kts new file mode 100644 index 00000000..57607239 --- /dev/null +++ b/build-logic/jvm/src/main/kotlin/build-logic.java-library.gradle.kts @@ -0,0 +1,4 @@ +plugins { + id("build-logic.java") + id("java-library") +} diff --git a/build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts b/build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts new file mode 100644 index 00000000..901e91de --- /dev/null +++ b/build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts @@ -0,0 +1,126 @@ +import com.github.vlsi.gradle.crlf.CrLfSpec +import com.github.vlsi.gradle.crlf.LineEndings +import com.github.vlsi.gradle.dsl.configureEach +import com.github.vlsi.gradle.properties.dsl.props +import java.time.LocalDate + +plugins { + id("java") + id("com.github.vlsi.crlf") + id("com.github.vlsi.gradle-extensions") + id("build-logic.repositories") + id("build-logic.test-base") + id("build-logic.build-params") + id("build-logic.style") + id("com.github.vlsi.jandex") +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +sourceSets { + main { + resources { + // TODO: remove when LICENSE is removed (it is used by Maven build for now) + exclude("META-INF/LICENSE") + } + } +} + +project.configure<com.github.vlsi.jandex.JandexExtension> { + skipIndexFileGeneration() +} + +if (!buildParameters.enableGradleMetadata) { + tasks.configureEach<GenerateModuleMetadata> { + enabled = false + } +} + +if (buildParameters.coverage || gradle.startParameter.taskNames.any { it.contains("jacoco") }) { + apply(plugin = "build-logic.jacoco") +} + +tasks.configureEach<JavaCompile> { + inputs.property("java.version", System.getProperty("java.version")) + inputs.property("java.vm.version", System.getProperty("java.vm.version")) + options.apply { + encoding = "UTF-8" + compilerArgs.add("-Xlint:deprecation") + if (JavaVersion.current().isJava9Compatible) { + // See https://bugs.openjdk.org/browse/JDK-8032211 + // Don't issue deprecation warnings on import statements is resolved in Java 9+ + //compilerArgs.add("-Werror") + } + } +} + +tasks.configureEach<Javadoc> { + (options as StandardJavadocDocletOptions).apply { + // Please refrain from using non-ASCII chars below since the options are passed as + // javadoc.options file which is parsed with "default encoding" + noTimestamp.value = true + showFromProtected() + if (buildParameters.failOnJavadocWarning) { + // See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363) + // for information about the -Xwerror option. + addBooleanOption("Xwerror", true) + } + // There are too many missing javadocs, so failing the build on missing comments seems to be not an option + addBooleanOption("Xdoclint:all,-missing", true) + // javadoc: error - The code being documented uses modules but the packages + // defined in https://docs.oracle.com/javase/9/docs/api/ are in the unnamed module + source = "1.8" + docEncoding = "UTF-8" + charSet = "UTF-8" + encoding = "UTF-8" + docTitle = "PostgreSQL JDBC ${project.name} API version ${project.version}" + windowTitle = "PostgreSQL JDBC ${project.name} API version ${project.version}" + header = "<b>PostgreSQL JDBC</b>" + val lastEditYear = providers.gradleProperty("lastEditYear") + .getOrElse(LocalDate.now().year.toString()) + bottom = + "Copyright &copy; 1997-$lastEditYear PostgreSQL Global Development Group. All Rights Reserved." + if (JavaVersion.current() >= JavaVersion.VERSION_17) { + addBooleanOption("html5", true) + } else if (JavaVersion.current() >= JavaVersion.VERSION_1_9) { + addBooleanOption("html5", true) + links("https://docs.oracle.com/javase/9/docs/api/") + } else { + links("https://docs.oracle.com/javase/8/docs/api/") + } + } +} + +// Add default license/notice when missing (e.g. see :src:config that overrides LICENSE) + +afterEvaluate { + tasks.configureEach<Jar> { + CrLfSpec(LineEndings.LF).run { + into("META-INF") { + filteringCharset = "UTF-8" + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from("$rootDir/LICENSE") + from("$rootDir/NOTICE") + } + } + } +} + +tasks.configureEach<Jar> { + manifest { + attributes["Bundle-License"] = "BSD-2-Clause" + attributes["Implementation-Title"] = "PostgreSQL JDBC Driver" + attributes["Implementation-Version"] = project.version + val jdbcSpec = props.string("jdbc.specification.version") + if (jdbcSpec.isNotBlank()) { + attributes["Specification-Vendor"] = "Oracle Corporation" + attributes["Specification-Version"] = jdbcSpec + attributes["Specification-Title"] = "JDBC" + } + attributes["Implementation-Vendor"] = "PostgreSQL Global Development Group" + attributes["Implementation-Vendor-Id"] = "org.postgresql" + } +} diff --git a/build-logic/jvm/src/main/kotlin/build-logic.kotlin.gradle.kts b/build-logic/jvm/src/main/kotlin/build-logic.kotlin.gradle.kts new file mode 100644 index 00000000..63f50a83 --- /dev/null +++ b/build-logic/jvm/src/main/kotlin/build-logic.kotlin.gradle.kts @@ -0,0 +1,30 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("java-library") + id("build-logic.java") + id("build-logic.test-base") + id("com.github.vlsi.gradle-extensions") + id("com.github.autostyle") + kotlin("jvm") +} + +java { + withSourcesJar() +} + +autostyle { + kotlin { + file("$rootDir/config/licenseHeaderRaw").takeIf { it.exists() }?.let { + licenseHeader(it.readText()) + } + trimTrailingWhitespace() + endWithNewline() + } +} + +tasks.withType<KotlinCompile>().configureEach { + kotlinOptions { + jvmTarget = "11" + } +} diff --git a/build-logic/jvm/src/main/kotlin/build-logic.test-base.gradle.kts b/build-logic/jvm/src/main/kotlin/build-logic.test-base.gradle.kts new file mode 100644 index 00000000..2c1ba069 --- /dev/null +++ b/build-logic/jvm/src/main/kotlin/build-logic.test-base.gradle.kts @@ -0,0 +1,44 @@ +import com.github.vlsi.gradle.dsl.configureEach +import org.gradle.api.tasks.testing.Test + +plugins { + id("build-logic.build-params") +} + +tasks.configureEach<Test> { + inputs.file("../build.properties") + if (file("../build.local.properties").exists()) { + inputs.file("../build.local.properties") + } + inputs.file("../ssltest.properties") + if (file("../ssltest.local.properties").exists()) { + inputs.file("../ssltest.local.properties") + } + testLogging { + showStandardStreams = true + } + exclude("**/*Suite*") + jvmArgs("-Xmx1536m") + jvmArgs("-Djdk.net.URLClassPath.disableClassPathURLCheck=true") + // Pass the property to tests + fun passProperty(name: String, default: String? = null) { + val value = System.getProperty(name) ?: default + value?.let { systemProperty(name, it) } + } + passProperty("preferQueryMode") + passProperty("java.awt.headless") + passProperty("user.language", "TR") + passProperty("user.country", "tr") + val props = System.getProperties() + @Suppress("UNCHECKED_CAST") + for (e in props.propertyNames() as `java.util`.Enumeration<String>) { + if (e.startsWith("pgjdbc.") || e.startsWith("java")) { + passProperty(e) + } + } + for (p in listOf("server", "port", "database", "username", "password", + "privilegedUser", "privilegedPassword", + "simpleProtocolOnly", "enable_ssl_tests")) { + passProperty(p) + } +} diff --git a/build-logic/jvm/src/main/kotlin/build-logic.test-junit5.gradle.kts b/build-logic/jvm/src/main/kotlin/build-logic.test-junit5.gradle.kts new file mode 100644 index 00000000..12993f35 --- /dev/null +++ b/build-logic/jvm/src/main/kotlin/build-logic.test-junit5.gradle.kts @@ -0,0 +1,39 @@ +import com.github.vlsi.gradle.dsl.configureEach +import com.github.vlsi.gradle.properties.dsl.props + +plugins { + id("java-library") + id("build-logic.build-params") + id("build-logic.test-base") +} + +dependencies { + testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") + testImplementation("uk.org.webcompere:system-stubs-jupiter:2.0.1") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2") + testImplementation("org.hamcrest:hamcrest:2.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") + if ((project.findProperty("junit4") ?: "true").toString().toBoolean()) { + // Allow projects to opt-out of junit dependency, so they can be JUnit5-only + testImplementation("junit:junit:4.13.2") + testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.8.2") + } +} + +tasks.configureEach<Test> { + useJUnitPlatform { + props.string("includeTestTags") + .takeIf { it.isNotBlank() } + ?.let { includeTags(it) } + } + // Pass the property to tests + fun passProperty(name: String, default: String? = null) { + val value = System.getProperty(name) ?: default + value?.let { systemProperty(name, it) } + } + passProperty("junit.jupiter.execution.parallel.enabled", "true") + // TODO: remove when upgrade to JUnit 5.9+ + // See https://github.com/junit-team/junit5/commit/347e3119d36a5c226cddd7981452f11335fad422 + passProperty("junit.jupiter.execution.parallel.config.strategy", "DYNAMIC") + passProperty("junit.jupiter.execution.timeout.default", "5 m") +} diff --git a/build-logic/publishing/build.gradle.kts b/build-logic/publishing/build.gradle.kts new file mode 100644 index 00000000..f3a47fd0 --- /dev/null +++ b/build-logic/publishing/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("build-logic.kotlin-dsl-gradle-plugin") +} + +dependencies { + implementation(project(":basics")) + implementation(project(":jvm")) + implementation(project(":build-parameters")) + implementation("com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin:1.1.0") + implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.86") + implementation("com.github.vlsi.stage-vote-release:com.github.vlsi.stage-vote-release.gradle.plugin:1.86") +} diff --git a/build-logic/publishing/src/main/kotlin/build-logic.java-published-library.gradle.kts b/build-logic/publishing/src/main/kotlin/build-logic.java-published-library.gradle.kts new file mode 100644 index 00000000..0d6e4f70 --- /dev/null +++ b/build-logic/publishing/src/main/kotlin/build-logic.java-published-library.gradle.kts @@ -0,0 +1,31 @@ +import com.github.vlsi.gradle.publishing.dsl.versionFromResolution + +plugins { + id("build-logic.build-params") + id("build-logic.java-library") + id("build-logic.reproducible-builds") + id("build-logic.publish-to-central") +} + +java { + withSourcesJar() + if (!buildParameters.skipJavadoc) { + withJavadocJar() + } +} + +publishing { + publications { + create<MavenPublication>(project.name) { + from(components["java"]) + + // Gradle feature variants can't be mapped to Maven's pom + suppressAllPomMetadataWarnings() + + // Use the resolved versions in pom.xml + // Gradle might have different resolution rules, so we set the versions + // that were used in Gradle build/test. + versionFromResolution() + } + } +} diff --git a/build-logic/publishing/src/main/kotlin/build-logic.publish-to-central.gradle.kts b/build-logic/publishing/src/main/kotlin/build-logic.publish-to-central.gradle.kts new file mode 100644 index 00000000..1f980969 --- /dev/null +++ b/build-logic/publishing/src/main/kotlin/build-logic.publish-to-central.gradle.kts @@ -0,0 +1,137 @@ +import com.github.vlsi.gradle.dsl.configureEach +import org.gradle.api.publish.internal.PublicationInternal +import com.github.vlsi.gradle.publishing.dsl.simplifyXml + +plugins { + id("java-library") + id("maven-publish") + id("build-logic.publish-to-tmp-maven-repo") + id("com.github.vlsi.gradle-extensions") +} + +publishing { + publications { + // <editor-fold defaultstate="collapsed" desc="Override published artifacts (e.g. shaded instead of regular)"> + val extraMavenPublications by configurations.creating { + isVisible = false + isCanBeResolved = false + isCanBeConsumed = false + } + afterEvaluate { + named<MavenPublication>(project.name) { + extraMavenPublications.outgoing.artifacts.apply { + val keys = mapTo(HashSet()) { + it.classifier.orEmpty() to it.extension + } + artifacts.removeIf { + keys.contains(it.classifier.orEmpty() to it.extension) + } + forEach { artifact(it) } + } + } + } + // </editor-fold> + } + publications.configureEach<MavenPublication> { + // Use the resolved versions in pom.xml + // Gradle might have different resolution rules, so we set the versions + // that were used in Gradle build/test. + versionMapping { + usage(Usage.JAVA_RUNTIME) { + fromResolutionResult() + } + usage(Usage.JAVA_API) { + fromResolutionOf("runtimeClasspath") + } + } + pom { + simplifyXml() + name.set( + (project.findProperty("artifact.name") as? String) ?: "pgdjbc ${project.name.capitalize()}" + ) + description.set(project.description ?: "PostgreSQL JDBC Driver ${project.name.capitalize()}") + inceptionYear.set("1997") + url.set("https://jdbc.postgresql.org") + licenses { + license { + name.set("BSD-2-Clause") + url.set("https://jdbc.postgresql.org/about/license.html") + comments.set("BSD-2-Clause, copyright PostgreSQL Global Development Group") + distribution.set("repo") + } + } + organization { + name.set("PostgreSQL Global Development Group") + url.set("https://jdbc.postgresql.org/") + } + developers { + developer { + id.set("davecramer") + name.set("Dave Cramer") + } + developer { + id.set("jurka") + name.set("Kris Jurka") + } + developer { + id.set("oliver") + name.set("Oliver Jowett") + } + developer { + id.set("ringerc") + name.set("Craig Ringer") + } + developer { + id.set("vlsi") + name.set("Vladimir Sitnikov") + } + developer { + id.set("bokken") + name.set("Brett Okken") + } + } + issueManagement { + system.set("GitHub issues") + url.set("https://github.com/pgjdbc/pgjdbc/issues") + } + mailingLists { + mailingList { + name.set("PostgreSQL JDBC development list") + subscribe.set("https://lists.postgresql.org/") + unsubscribe.set("https://lists.postgresql.org/unsubscribe/") + post.set("pgsql-jdbc@postgresql.org") + archive.set("https://www.postgresql.org/list/pgsql-jdbc/") + } + } + scm { + connection.set("scm:git:https://github.com/pgjdbc/pgjdbc.git") + developerConnection.set("scm:git:https://github.com/pgjdbc/pgjdbc.git") + url.set("https://github.com/pgjdbc/pgjdbc") + tag.set("HEAD") + } + } + } +} + +val createReleaseBundle by tasks.registering(Sync::class) { + description = "This task should be used by github actions to create release artifacts along with a slsa attestation" + val releaseDir = layout.buildDirectory.dir("release") + outputs.dir(releaseDir) + + into(releaseDir) + rename("pom-default.xml", "${project.name}-${project.version}.pom") + rename("module.json", "${project.name}-${project.version}.module") +} + +publishing { + publications.configureEach { + (this as PublicationInternal<*>).allPublishableArtifacts { + val publicationArtifact = this + createReleaseBundle.configure { + dependsOn(publicationArtifact) + from(publicationArtifact.file) + } + } + } +} + diff --git a/build-logic/publishing/src/main/kotlin/build-logic.publish-to-tmp-maven-repo.gradle.kts b/build-logic/publishing/src/main/kotlin/build-logic.publish-to-tmp-maven-repo.gradle.kts new file mode 100644 index 00000000..67377084 --- /dev/null +++ b/build-logic/publishing/src/main/kotlin/build-logic.publish-to-tmp-maven-repo.gradle.kts @@ -0,0 +1,41 @@ +plugins { + id("java-library") + id("maven-publish") +} + +val localRepoElements by configurations.creating { + isCanBeConsumed = true + isCanBeResolved = false + description = + "Shares local maven repository directory that contains the artifacts produced by the current project" + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named("maven-repository")) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) + } +} + +val localRepoDir = layout.buildDirectory.dir("local-maven-repo") + +publishing { + repositories { + maven { + name = "tmp-maven" + url = uri(localRepoDir) + } + } +} + +localRepoElements.outgoing.artifact(localRepoDir) { + builtBy(tasks.named("publishAllPublicationsToTmp-mavenRepository")) +} + +val cleanLocalRepository by tasks.registering(Delete::class) { + description = "Clears local-maven-repo so timestamp-based snapshot artifacts do not consume space" + delete(localRepoDir) +} + +tasks.withType<PublishToMavenRepository>() + .matching { it.name.endsWith("PublicationToTmp-mavenRepository") } + .configureEach { + dependsOn(cleanLocalRepository) + } diff --git a/build-logic/root-build/build.gradle.kts b/build-logic/root-build/build.gradle.kts new file mode 100644 index 00000000..6fbfddd7 --- /dev/null +++ b/build-logic/root-build/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("build-logic.kotlin-dsl-gradle-plugin") +} diff --git a/build-logic/root-build/src/main/kotlin/build-logic.root-build.gradle.kts b/build-logic/root-build/src/main/kotlin/build-logic.root-build.gradle.kts new file mode 100644 index 00000000..e69de29b diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 00000000..34002de8 --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,16 @@ +dependencyResolutionManagement { + repositories { + gradlePluginPortal() + } +} + +rootProject.name = "build-logic" + +includeBuild("../build-logic-commons") +include("build-parameters") +include("basics") +include("jvm") +include("java-comment-preprocessor") +include("publishing") +include("root-build") +include("verification") diff --git a/build-logic/verification/build.gradle.kts b/build-logic/verification/build.gradle.kts new file mode 100644 index 00000000..edb4eca0 --- /dev/null +++ b/build-logic/verification/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("build-logic.kotlin-dsl-gradle-plugin") +} + +dependencies { + implementation(project(":basics")) + implementation(project(":build-parameters")) + implementation("com.github.autostyle:com.github.autostyle.gradle.plugin:3.2") + implementation("com.github.spotbugs:com.github.spotbugs.gradle.plugin:5.0.13") + implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.86") + implementation("de.thetaphi.forbiddenapis:de.thetaphi.forbiddenapis.gradle.plugin:3.3") + implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:3.0.1") + implementation("org.checkerframework:org.checkerframework.gradle.plugin:0.6.23") +} diff --git a/build-logic/verification/src/main/kotlin/build-logic.autostyle.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.autostyle.gradle.kts new file mode 100644 index 00000000..cace7540 --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.autostyle.gradle.kts @@ -0,0 +1,36 @@ +plugins { + id("com.github.autostyle") +} + +autostyle { + kotlinGradle { + ktlint() + trimTrailingWhitespace() + endWithNewline() + } + format("markdown") { + target("**/*.md") + endWithNewline() + } +} + +plugins.withId("java") { + autostyle { + java { + // targetExclude("**/test/java/*.java") + // TODO: implement license check (with copyright year) + // licenseHeaderFile(licenseHeaderFile) + importOrder( + "static ", + "org.postgresql.", + "", + "java.", + "javax." + ) + removeUnusedImports() + trimTrailingWhitespace() + indentWithSpaces(4) + endWithNewline() + } + } +} diff --git a/build-logic/verification/src/main/kotlin/build-logic.checkerframework.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.checkerframework.gradle.kts new file mode 100644 index 00000000..cf100ba9 --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.checkerframework.gradle.kts @@ -0,0 +1,45 @@ +import org.gradle.api.JavaVersion +import org.gradle.kotlin.dsl.dependencies + +plugins { + id("org.checkerframework") +} + +dependencies { + providers.gradleProperty("checkerframework.version") + .takeIf { it.isPresent } + ?.let { + val checkerframeworkVersion = it.get() + "checkerFramework"("org.checkerframework:checker:$checkerframeworkVersion") + if (JavaVersion.current() == JavaVersion.VERSION_1_8) { + // only needed for JDK 8 + "checkerFrameworkAnnotatedJDK"("org.checkerframework:jdk8:$checkerframeworkVersion") + } + } ?: run { + val checkerframeworkVersion = "3.30.0" + "checkerFramework"("org.checkerframework:checker:$checkerframeworkVersion") + if (JavaVersion.current() == JavaVersion.VERSION_1_8) { + // only needed for JDK 8 + "checkerFrameworkAnnotatedJDK"("org.checkerframework:jdk8:$checkerframeworkVersion") + } + } +} + +checkerFramework { + skipVersionCheck = true + excludeTests = true + // See https://checkerframework.org/manual/#introduction + checkers.add("org.checkerframework.checker.nullness.NullnessChecker") + checkers.add("org.checkerframework.checker.optional.OptionalChecker") + // checkers.add("org.checkerframework.checker.index.IndexChecker") + checkers.add("org.checkerframework.checker.regex.RegexChecker") + extraJavacArgs.add("-Astubs=" + + fileTree("$rootDir/config/checkerframework") { + include("*.astub") + }.asPath + ) + // Translation classes are autogenerated, and they + extraJavacArgs.add("-AskipDefs=^org\\.postgresql\\.translation\\.") + // The below produces too many warnings :( + // extraJavacArgs.add("-Alint=redundantNullComparison") +} diff --git a/build-logic/verification/src/main/kotlin/build-logic.checkstyle.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.checkstyle.gradle.kts new file mode 100644 index 00000000..3213b92f --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.checkstyle.gradle.kts @@ -0,0 +1,32 @@ +import org.gradle.api.plugins.quality.Checkstyle +import org.gradle.kotlin.dsl.withType +import java.io.File + +plugins { + id("checkstyle") +} + +checkstyle { + toolVersion = "9.3" + providers.gradleProperty("checkstyle.version") + .takeIf { it.isPresent } + ?.let { toolVersion = it.get() } + + // Current one is ~8.8 + // https://github.com/julianhyde/toolbox/issues/3 + isShowViolations = true + // TOOD: move to /config + val configDir = File(rootDir, "pgjdbc/src/main/checkstyle") + configDirectory.set(configDir) + configFile = configDir.resolve("checks.xml") +} + +val checkstyleTasks = tasks.withType<Checkstyle>() +checkstyleTasks.configureEach { + // Checkstyle 8.26 does not need classpath, see https://github.com/gradle/gradle/issues/14227 + classpath = files() +} + +tasks.register("checkstyleAll") { + dependsOn(checkstyleTasks) +} diff --git a/build-logic/verification/src/main/kotlin/build-logic.errorprone.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.errorprone.gradle.kts new file mode 100644 index 00000000..662123ac --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.errorprone.gradle.kts @@ -0,0 +1,33 @@ +import com.github.vlsi.gradle.dsl.configureEach +import net.ltgt.gradle.errorprone.errorprone +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.dependencies + +plugins { + id("java") + id("build-logic.repositories") +} + +if (!project.hasProperty("skipErrorprone")) { + apply(plugin = "net.ltgt.errorprone") + + dependencies { + "errorprone"("com.google.errorprone:error_prone_core:2.18.0") + "annotationProcessor"("com.google.guava:guava-beta-checker:1.0") + } + + tasks.configureEach<JavaCompile> { + if ("Test" in name) { + // Ignore warnings in test code + options.errorprone.isEnabled.set(false) + } else { + options.compilerArgs.addAll(listOf("-Xmaxerrs", "10000", "-Xmaxwarns", "10000")) + options.errorprone { + disableWarningsInGeneratedCode.set(true) + enable( + "PackageLocation" + ) + } + } + } +} diff --git a/build-logic/verification/src/main/kotlin/build-logic.forbidden-apis.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.forbidden-apis.gradle.kts new file mode 100644 index 00000000..f0d45734 --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.forbidden-apis.gradle.kts @@ -0,0 +1,24 @@ +import com.github.vlsi.gradle.dsl.configureEach +import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis + +plugins { + id("de.thetaphi.forbiddenapis") +} + +forbiddenApis { + failOnUnsupportedJava = false + signaturesFiles = files("$rootDir/config/forbidden-apis/forbidden-apis.txt") + bundledSignatures.addAll( + listOf( + // "jdk-deprecated", + "jdk-internal", + "jdk-non-portable" + // "jdk-system-out" + // "jdk-unsafe" + ) + ) +} + +tasks.configureEach<CheckForbiddenApis> { + exclude("**/org/postgresql/util/internal/Unsafe.class") +} diff --git a/build-logic/verification/src/main/kotlin/build-logic.jacoco.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.jacoco.gradle.kts new file mode 100644 index 00000000..50028ac4 --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.jacoco.gradle.kts @@ -0,0 +1,51 @@ +plugins { + id("java-base") + id("jacoco") +} + +jacoco { + toolVersion = "0.8.5" + providers.gradleProperty("jacoco.version") + .takeIf { it.isPresent } + ?.let { toolVersion = it.get() } +} + +val testTasks = tasks.withType<Test>() +val javaExecTasks = tasks.withType<JavaExec>() + +// This configuration must be postponed since JacocoTaskExtension might be added inside +// configure block of a task (== before this code is run) +afterEvaluate { + for (t in arrayOf(testTasks, javaExecTasks)) { + t.configureEach { + extensions.findByType<JacocoTaskExtension>()?.apply { + // We want collect code coverage for org.postgresql classes only + includes?.add("org.postgresql.*") + } + } + } +} + +val jacocoReport by rootProject.tasks.existing(JacocoReport::class) +val mainCode = sourceSets["main"] + +// TODO: rework with provide-consume configurations +jacocoReport { + // Note: this creates a lazy collection + // Some projects might fail to create a file (e.g. no tests or no coverage), + // So we check for file existence. Otherwise, JacocoMerge would fail + val execFiles = + files(testTasks, javaExecTasks).filter { it.exists() && it.name.endsWith(".exec") } + executionData(execFiles) + additionalSourceDirs.from(mainCode.allJava.srcDirs) + sourceDirectories.from(mainCode.allSource.srcDirs) + classDirectories.from(mainCode.output) +} + +// TODO: check which reports do we need +//tasks.configureEach<JacocoReport> { +// reports { +// html.required.set(reportsForHumans()) +// xml.required.set(!reportsForHumans()) +// } +//} diff --git a/build-logic/verification/src/main/kotlin/build-logic.spotbugs.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.spotbugs.gradle.kts new file mode 100644 index 00000000..758a4acd --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.spotbugs.gradle.kts @@ -0,0 +1,41 @@ +import com.github.spotbugs.snom.Confidence +import com.github.spotbugs.snom.SpotBugsExtension +import com.github.spotbugs.snom.SpotBugsTask +import com.github.vlsi.gradle.dsl.configureEach +import org.gradle.language.base.plugins.LifecycleBasePlugin + +plugins { + id("com.github.spotbugs") +} + +spotbugs { + // Below statement is for Renovate Bot since it does not support toolVersion.set("..") pattern yet + val toolVersion = "4.0.0" + this.toolVersion.set(toolVersion) + + providers.gradleProperty("spotbugs.version") + .takeIf { it.isPresent } + ?.let { this.toolVersion.set(it) } + reportLevel.set(Confidence.HIGH) +} + +dependencies { + // Parenthesis are needed here: https://github.com/gradle/gradle/issues/9248 + (constraints) { + providers.gradleProperty("asm.version") + .takeIf { it.isPresent } + ?.let { + val asmVersion = it.get() + spotbugs("org.ow2.asm:asm:$asmVersion") + spotbugs("org.ow2.asm:asm-all:$asmVersion") + spotbugs("org.ow2.asm:asm-analysis:$asmVersion") + spotbugs("org.ow2.asm:asm-commons:$asmVersion") + spotbugs("org.ow2.asm:asm-tree:$asmVersion") + spotbugs("org.ow2.asm:asm-util:$asmVersion") + } + } +} + +tasks.configureEach<SpotBugsTask> { + group = LifecycleBasePlugin.VERIFICATION_GROUP +} diff --git a/build-logic/verification/src/main/kotlin/build-logic.style.gradle.kts b/build-logic/verification/src/main/kotlin/build-logic.style.gradle.kts new file mode 100644 index 00000000..f5657771 --- /dev/null +++ b/build-logic/verification/src/main/kotlin/build-logic.style.gradle.kts @@ -0,0 +1,46 @@ +import org.gradle.kotlin.dsl.apply +import org.gradle.language.base.plugins.LifecycleBasePlugin + +plugins { + id("build-logic.build-params") +} + +if (!buildParameters.skipAutostyle) { + apply(plugin = "build-logic.autostyle") +} + +if (!buildParameters.skipCheckstyle) { + apply(plugin = "build-logic.checkstyle") +} + +if (!buildParameters.skipForbiddenApis) { + apply(plugin = "build-logic.forbidden-apis") +} + +plugins.withId("java-base") { + if (buildParameters.enableCheckerframework) { + apply(plugin = "build-logic.checkerframework") + } + if (buildParameters.enableErrorprone) { + apply(plugin = "build-logic.errorprone") + } + if (buildParameters.spotbugs) { + apply(plugin = "build-logic.spotbugs") + } +} + +if (!buildParameters.skipAutostyle || !buildParameters.skipCheckstyle || !buildParameters.skipForbiddenApis) { + tasks.register("style") { + group = LifecycleBasePlugin.VERIFICATION_GROUP + description = "Formats code (license header, import order, whitespace at end of line, ...) and executes Checkstyle verifications" + if (!buildParameters.skipAutostyle) { + dependsOn("autostyleApply") + } + if (!buildParameters.skipCheckstyle) { + dependsOn("checkstyleAll") + } + if (!buildParameters.skipForbiddenApis) { + dependsOn("forbiddenApisAll") + } + } +} diff --git a/build.gradle.kts b/build.gradle.kts index e13c1704..2a1c64bb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,81 +3,23 @@ * See the LICENSE file in the project root for more information. */ -import com.github.spotbugs.SpotBugsTask -import com.github.vlsi.gradle.crlf.CrLfSpec -import com.github.vlsi.gradle.crlf.LineEndings -import com.github.vlsi.gradle.dsl.configureEach -import com.github.vlsi.gradle.git.FindGitAttributes -import com.github.vlsi.gradle.properties.dsl.props -import com.github.vlsi.gradle.publishing.dsl.simplifyXml -import com.github.vlsi.gradle.publishing.dsl.versionFromResolution -import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis -import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApisExtension -import org.postgresql.buildtools.JavaCommentPreprocessorTask - plugins { - publishing - // Verification - checkstyle - jacoco - id("com.github.autostyle") - id("com.github.spotbugs") id("org.owasp.dependencycheck") - id("org.checkerframework") apply false - id("com.github.johnrengelman.shadow") apply false - id("de.thetaphi.forbiddenapis") apply false id("org.nosphere.gradle.github.actions") - id("com.github.vlsi.jandex") apply false // IDE configuration - id("org.jetbrains.gradle.plugin.idea-ext") id("com.github.vlsi.ide") // Release - id("com.github.vlsi.crlf") id("com.github.vlsi.gradle-extensions") - id("com.github.vlsi.license-gather") apply false id("com.github.vlsi.stage-vote-release") } -fun reportsForHumans() = !(System.getenv()["CI"]?.toBoolean() ?: props.bool("CI")) - -val lastEditYear = 2023 // TODO: by extra(lastEditYear("$rootDir/LICENSE")) - -// Do not enable spotbugs by default. Execute it only when -Pspotbugs is present -val enableSpotBugs = props.bool("spotbugs", default = false) -val enableCheckerframework by props() -val skipCheckstyle by props() -val skipAutostyle by props() -val skipJavadoc by props() -val skipForbiddenApis by props() -val enableMavenLocal by props() -val enableGradleMetadata by props() -// For instance -PincludeTestTags=!org.postgresql.test.SlowTests -// or -PincludeTestTags=!org.postgresql.test.Replication -val includeTestTags by props("") -// By default use Java implementation to sign artifacts -// When useGpgCmd=true, then gpg command line tool is used for signing -val useGpgCmd by props() -val jacocoEnabled by extra { - props.bool("coverage") || gradle.startParameter.taskNames.any { it.contains("jacoco") } -} - ide { // TODO: set copyright to PostgreSQL Global Development Group - // copyrightToAsf() ideaInstructionsUri = uri("https://github.com/pgjdbc/pgjdbc") doNotDetectFrameworks("android", "jruby") } -// This task scans the project for gitignore / gitattributes, and that is reused for building -// source/binary artifacts with the appropriate eol/executable file flags -// It enables to automatically exclude patterns from .gitignore -val gitProps by tasks.registering(FindGitAttributes::class) { - // Scanning for .gitignore and .gitattributes files in a task avoids doing that - // when distribution build is not required (e.g. code is just compiled) - root.set(rootDir) -} - val String.v: String get() = rootProject.extra["$this.version"] as String val buildVersion = "pgjdbc".v + releaseParams.snapshotSuffix @@ -86,10 +28,6 @@ println("Building pgjdbc $buildVersion") val isReleaseVersion = rootProject.releaseParams.release.get() -// Configures URLs to SVN and Nexus - -val licenseHeaderFile = file("config/license.header.java") - val jacocoReport by tasks.registering(JacocoReport::class) { group = "Coverage reports" description = "Generates an aggregate report from all subprojects" @@ -119,620 +57,23 @@ releaseParams { allprojects { group = "org.postgresql" version = buildVersion +} - apply(plugin = "com.github.vlsi.gradle-extensions") - - plugins.withId("de.marcphilipp.nexus-publish") { - configure<de.marcphilipp.gradle.nexus.NexusPublishExtension> { - clientTimeout.set(java.time.Duration.ofMinutes(15)) - } - } - - plugins.withId("io.codearte.nexus-staging") { - configure<io.codearte.gradle.nexus.NexusStagingExtension> { - numberOfRetries = 20 * 60 / 2 - delayBetweenRetriesInMillis = 2000 - } - } - - repositories { - if (enableMavenLocal) { - mavenLocal() - } - mavenCentral() - } - - val javaMainUsed = file("src/main/java").isDirectory - val javaTestUsed = file("src/test/java").isDirectory - val javaUsed = javaMainUsed || javaTestUsed - if (javaUsed) { - apply(plugin = "java-library") - if (jacocoEnabled) { - apply(plugin = "jacoco") - } - } - - plugins.withId("java-library") { - dependencies { - "implementation"(platform(project(":bom"))) - } - } - - val kotlinMainUsed = file("src/main/kotlin").isDirectory - val kotlinTestUsed = file("src/test/kotlin").isDirectory - val kotlinUsed = kotlinMainUsed || kotlinTestUsed - if (kotlinUsed) { - apply(plugin = "java-library") - apply(plugin = "org.jetbrains.kotlin.jvm") - dependencies { - add(if (kotlinMainUsed) "implementation" else "testImplementation", kotlin("stdlib")) - } - } - - val hasTests = javaTestUsed || kotlinTestUsed - if (hasTests) { - // Add default tests dependencies - dependencies { - val testImplementation by configurations - val testRuntimeOnly by configurations - testImplementation("org.junit.jupiter:junit-jupiter-api") - testImplementation("uk.org.webcompere:system-stubs-jupiter") - testImplementation("org.junit.jupiter:junit-jupiter-params") - testImplementation("org.hamcrest:hamcrest") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") - if (project.props.bool("junit4", default = true)) { - // Allow projects to opt-out of junit dependency, so they can be JUnit5-only - testImplementation("junit:junit") - testRuntimeOnly("org.junit.vintage:junit-vintage-engine") - } - } - } - - if (!skipAutostyle) { - apply(plugin = "com.github.autostyle") - autostyle { - kotlinGradle { - ktlint() - trimTrailingWhitespace() - endWithNewline() - } - format("markdown") { - target("**/*.md") - endWithNewline() - } - } - } - val skipCheckstyle = skipCheckstyle || props.bool("skipCheckstyle") - if (!skipCheckstyle) { - apply<CheckstylePlugin>() - dependencies { - checkstyle("com.puppycrawl.tools:checkstyle:${"checkstyle".v}") - } - checkstyle { - // Current one is ~8.8 - // https://github.com/julianhyde/toolbox/issues/3 - isShowViolations = true - // TOOD: move to /config - configDirectory.set(File(rootDir, "pgjdbc/src/main/checkstyle")) - configFile = configDirectory.get().file("checks.xml").asFile - } - - val checkstyleTasks = tasks.withType<Checkstyle>() - checkstyleTasks.configureEach { - // Checkstyle 8.26 does not need classpath, see https://github.com/gradle/gradle/issues/14227 - classpath = files() - } - - tasks.register("checkstyleAll") { - dependsOn(checkstyleTasks) - } - } - if (!skipAutostyle || !skipCheckstyle) { - tasks.register("style") { - group = LifecycleBasePlugin.VERIFICATION_GROUP - description = "Formats code (license header, import order, whitespace at end of line, ...) and executes Checkstyle verifications" - if (!skipAutostyle) { - dependsOn("autostyleApply") - } - if (!skipCheckstyle) { - dependsOn("checkstyleAll") - } - } - } - - tasks.configureEach<AbstractArchiveTask> { - // Ensure builds are reproducible - isPreserveFileTimestamps = false - isReproducibleFileOrder = true - dirMode = "775".toInt(8) - fileMode = "664".toInt(8) - } - - plugins.withType<SigningPlugin> { - afterEvaluate { - configure<SigningExtension> { - val release = rootProject.releaseParams.release.get() - // Note it would still try to sign the artifacts, - // however it would fail only when signing a RELEASE version fails - isRequired = release - if (useGpgCmd) { - useGpgCmd() - } - } - } - } - - plugins.withType<JacocoPlugin> { - the<JacocoPluginExtension>().toolVersion = "jacoco".v - - val testTasks = tasks.withType<Test>() - val javaExecTasks = tasks.withType<JavaExec>() - // This configuration must be postponed since JacocoTaskExtension might be added inside - // configure block of a task (== before this code is run). See :src:dist-check:createBatchTask - afterEvaluate { - for (t in arrayOf(testTasks, javaExecTasks)) { - t.configureEach { - extensions.findByType<JacocoTaskExtension>()?.apply { - // Do not collect coverage when not asked (e.g. via jacocoReport or -Pcoverage) - isEnabled = jacocoEnabled - // We don't want to collect coverage for third-party classes - includes?.add("org.postgresql.*") - } - } - } - } - - jacocoReport { - // Note: this creates a lazy collection - // Some of the projects might fail to create a file (e.g. no tests or no coverage), - // So we check for file existence. Otherwise JacocoMerge would fail - val execFiles = - files(testTasks, javaExecTasks).filter { it.exists() && it.name.endsWith(".exec") } - executionData(execFiles) - } - - tasks.configureEach<JacocoReport> { - reports { - html.required.set(reportsForHumans()) - xml.required.set(!reportsForHumans()) - } - } - } - - tasks { - // <editor-fold defaultstate="collapsed" desc="JavaCommentPreprocessor: configure version variables"> - configureEach<JavaCommentPreprocessorTask> { - variables.apply { - val jdbcSpec = props.string("jdbc.specification.version") - put("mvn.project.property.postgresql.jdbc.spec", "JDBC$jdbcSpec") - put("jdbc.specification.version", jdbcSpec) - } - - val re = Regex("^(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*") - - val version = project.version.toString() - val matchResult = re.find(version) ?: throw GradleException("Unable to parse major.minor.patch version parts from project.version '$version'") - val (major, minor, patch) = matchResult.destructured - - variables.apply { - put("version", version) - put("version.major", major) - put("version.minor", minor) - put("version.patch", patch.ifBlank { "0" }) - } - } - // </editor-fold> - - // <editor-fold defaultstate="collapsed" desc="Javadoc configuration"> - configureEach<Javadoc> { - (options as StandardJavadocDocletOptions).apply { - // Please refrain from using non-ASCII chars below since the options are passed as - // javadoc.options file which is parsed with "default encoding" - noTimestamp.value = true - showFromProtected() - if (props.bool("failOnJavadocWarning", default = true)) { - // See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363) - // for information about the -Xwerror option. - addBooleanOption("Xwerror", true) - } - // There are too many missing javadocs, so failing the build on missing comments seems to be not an option - addBooleanOption("Xdoclint:all,-missing", true) - // javadoc: error - The code being documented uses modules but the packages - // defined in https://docs.oracle.com/javase/9/docs/api/ are in the unnamed module - source = "1.8" - docEncoding = "UTF-8" - charSet = "UTF-8" - encoding = "UTF-8" - docTitle = "PostgreSQL JDBC ${project.name} API version ${project.version}" - windowTitle = "PostgreSQL JDBC ${project.name} API version ${project.version}" - header = "<b>PostgreSQL JDBC</b>" - bottom = - "Copyright &copy; 1997-$lastEditYear PostgreSQL Global Development Group. All Rights Reserved." - if (JavaVersion.current() >= JavaVersion.VERSION_17) { - addBooleanOption("html5", true) - } else if (JavaVersion.current() >= JavaVersion.VERSION_1_9) { - addBooleanOption("html5", true) - links("https://docs.oracle.com/javase/9/docs/api/") - } else { - links("https://docs.oracle.com/javase/8/docs/api/") - } - } - } - // </editor-fold> - } - - plugins.withType<JavaPlugin> { - configure<JavaPluginExtension> { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - withSourcesJar() - if (!skipJavadoc) { - withJavadocJar() - } - } - - val sourceSets: SourceSetContainer by project - - apply(plugin = "com.github.vlsi.jandex") - apply(plugin = "maven-publish") - - project.configure<com.github.vlsi.jandex.JandexExtension> { - skipIndexFileGeneration() - } - - if (!enableGradleMetadata) { - tasks.withType<GenerateModuleMetadata> { - enabled = false - } - } - - if (!skipForbiddenApis && !props.bool("skipCheckstyle")) { - apply(plugin = "de.thetaphi.forbiddenapis") - configure<CheckForbiddenApisExtension> { - failOnUnsupportedJava = false - signaturesFiles = files("$rootDir/config/forbidden-apis/forbidden-apis.txt") - bundledSignatures.addAll( - listOf( - // "jdk-deprecated", - "jdk-internal", - "jdk-non-portable" - // "jdk-system-out" - // "jdk-unsafe" - ) - ) - } - tasks.configureEach<CheckForbiddenApis> { - exclude("**/org/postgresql/util/internal/Unsafe.class") - } - } - - if (!skipAutostyle) { - autostyle { - java { - // targetExclude("**/test/java/*.java") - // TODO: implement license check (with copyright year) - // licenseHeaderFile(licenseHeaderFile) - importOrder( - "static ", - "org.postgresql.", - "", - "java.", - "javax." - ) - removeUnusedImports() - trimTrailingWhitespace() - indentWithSpaces(4) - endWithNewline() - } - } - } - - if (enableCheckerframework) { - apply(plugin = "org.checkerframework") - dependencies { - "checkerFramework"("org.checkerframework:checker:${"checkerframework".v}") - // CheckerFramework annotations might be used in the code as follows: - // dependencies { - // "compileOnly"("org.checkerframework:checker-qual") - // "testCompileOnly"("org.checkerframework:checker-qual") - // } - if (JavaVersion.current() == JavaVersion.VERSION_1_8) { - // only needed for JDK 8 - "checkerFrameworkAnnotatedJDK"("org.checkerframework:jdk8:${"checkerframework".v}") - } - } - configure<org.checkerframework.gradle.plugin.CheckerFrameworkExtension> { - skipVersionCheck = true - excludeTests = true - // See https://checkerframework.org/manual/#introduction - checkers.add("org.checkerframework.checker.nullness.NullnessChecker") - checkers.add("org.checkerframework.checker.optional.OptionalChecker") - // checkers.add("org.checkerframework.checker.index.IndexChecker") - checkers.add("org.checkerframework.checker.regex.RegexChecker") - extraJavacArgs.add("-Astubs=" + - fileTree("$rootDir/config/checkerframework") { - include("*.astub") - }.asPath - ) - // Translation classes are autogenerated, and they - extraJavacArgs.add("-AskipDefs=^org\\.postgresql\\.translation\\.") - // The below produces too many warnings :( - // extraJavacArgs.add("-Alint=redundantNullComparison") - } - } - - if (jacocoEnabled) { - // Add each project to combined report - val mainCode = sourceSets["main"] - jacocoReport.configure { - additionalSourceDirs.from(mainCode.allJava.srcDirs) - sourceDirectories.from(mainCode.allSource.srcDirs) - classDirectories.from(mainCode.output) - } - } - - if (enableSpotBugs) { - apply(plugin = "com.github.spotbugs") - spotbugs { - toolVersion = "spotbugs".v - reportLevel = "high" - // excludeFilter = file("$rootDir/src/main/config/spotbugs/spotbugs-filter.xml") - // By default spotbugs verifies TEST classes as well, and we do not want that - this.sourceSets = listOf(sourceSets["main"]) - } - dependencies { - // Parenthesis are needed here: https://github.com/gradle/gradle/issues/9248 - (constraints) { - "spotbugs"("org.ow2.asm:asm:${"asm".v}") - "spotbugs"("org.ow2.asm:asm-all:${"asm".v}") - "spotbugs"("org.ow2.asm:asm-analysis:${"asm".v}") - "spotbugs"("org.ow2.asm:asm-commons:${"asm".v}") - "spotbugs"("org.ow2.asm:asm-tree:${"asm".v}") - "spotbugs"("org.ow2.asm:asm-util:${"asm".v}") - } - } - } - - (sourceSets) { - "main" { - resources { - // TODO: remove when LICENSE is removed (it is used by Maven build for now) - exclude("src/main/resources/META-INF/LICENSE") - } - } - } - - tasks { - configureEach<Jar> { - manifest { - attributes["Bundle-License"] = "BSD-2-Clause" - attributes["Implementation-Title"] = "PostgreSQL JDBC Driver" - attributes["Implementation-Version"] = project.version - val jdbcSpec = props.string("jdbc.specification.version") - if (jdbcSpec.isNotBlank()) { - attributes["Specification-Vendor"] = "Oracle Corporation" - attributes["Specification-Version"] = jdbcSpec - attributes["Specification-Title"] = "JDBC" - } - attributes["Implementation-Vendor"] = "PostgreSQL Global Development Group" - attributes["Implementation-Vendor-Id"] = "org.postgresql" - } - } - - configureEach<JavaCompile> { - options.encoding = "UTF-8" - } - configureEach<Test> { - useJUnitPlatform { - if (includeTestTags.isNotBlank()) { - includeTags.add(includeTestTags) - } - } - inputs.file("../build.properties") - if (file("../build.local.properties").exists()) { - inputs.file("../build.local.properties") - } - inputs.file("../ssltest.properties") - if (file("../ssltest.local.properties").exists()) { - inputs.file("../ssltest.local.properties") - } - testLogging { - showStandardStreams = true - } - exclude("**/*Suite*") - jvmArgs("-Xmx1536m") - jvmArgs("-Djdk.net.URLClassPath.disableClassPathURLCheck=true") - // Pass the property to tests - fun passProperty(name: String, default: String? = null) { - val value = System.getProperty(name) ?: default - value?.let { systemProperty(name, it) } - } - passProperty("preferQueryMode") - passProperty("java.awt.headless") - passProperty("junit.jupiter.execution.parallel.enabled", "true") - // TODO: remove when upgrade to JUnit 5.9+ - // See https://github.com/junit-team/junit5/commit/347e3119d36a5c226cddd7981452f11335fad422 - passProperty("junit.jupiter.execution.parallel.config.strategy", "DYNAMIC") - passProperty("junit.jupiter.execution.timeout.default", "5 m") - passProperty("user.language", "TR") - passProperty("user.country", "tr") - val props = System.getProperties() - for (e in props.propertyNames() as `java.util`.Enumeration<String>) { - if (e.startsWith("pgjdbc.") || e.startsWith("java")) { - passProperty(e) - } - } - for (p in listOf("server", "port", "database", "username", "password", - "privilegedUser", "privilegedPassword", - "simpleProtocolOnly", "enable_ssl_tests")) { - passProperty(p) - } - } - configureEach<SpotBugsTask> { - group = LifecycleBasePlugin.VERIFICATION_GROUP - if (enableSpotBugs) { - description = "$description (skipped by default, to enable it add -Dspotbugs)" - } - reports { - html.required.set(reportsForHumans()) - xml.required.set(!reportsForHumans()) - } - enabled = enableSpotBugs - } - - afterEvaluate { - // Add default license/notice when missing - configureEach<Jar> { - CrLfSpec(LineEndings.LF).run { - into("META-INF") { - filteringCharset = "UTF-8" - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - // Note: we need "generic Apache-2.0" text without third-party items - // So we use the text from $rootDir/config/ since source distribution - // contains altered text at $rootDir/LICENSE - textFrom("$rootDir/src/main/config/licenses/LICENSE") - textFrom("$rootDir/NOTICE") - } - } - } - } - } - - configure<PublishingExtension> { - if (!project.props.bool("nexus.publish", default = true)) { - // Some of the artifacts do not need to be published - return@configure - } - - publications { - // <editor-fold defaultstate="collapsed" desc="Override published artifacts (e.g. shaded instead of regular)"> - val extraMavenPublications by configurations.creating { - isVisible = false - isCanBeResolved = false - isCanBeConsumed = false - } - afterEvaluate { - named<MavenPublication>(project.name) { - extraMavenPublications.outgoing.artifacts.apply { - val keys = mapTo(HashSet()) { - it.classifier.orEmpty() to it.extension - } - artifacts.removeIf { - keys.contains(it.classifier.orEmpty() to it.extension) - } - forEach { artifact(it) } - } - } - } - // </editor-fold> - // <editor-fold defaultstate="collapsed" desc="Configuration of the published pom.xml"> - create<MavenPublication>(project.name) { - artifactId = project.name - version = rootProject.version.toString() - from(components["java"]) - - // Gradle feature variants can't be mapped to Maven's pom - suppressAllPomMetadataWarnings() +val parameters by tasks.registering { + group = HelpTasksPlugin.HELP_GROUP + description = "Displays build parameters (i.e. -P flags) that can be used to customize the build" + dependsOn(gradle.includedBuild("build-logic").task(":build-parameters:parameters")) +} - // Use the resolved versions in pom.xml - // Gradle might have different resolution rules, so we set the versions - // that were used in Gradle build/test. - versionFromResolution() - pom { - simplifyXml() - name.set( - (project.findProperty("artifact.name") as? String) ?: "pgdjbc ${project.name.capitalize()}" - ) - description.set(project.description ?: "PostgreSQL JDBC Driver ${project.name.capitalize()}") - inceptionYear.set("1997") - url.set("https://jdbc.postgresql.org") - licenses { - license { - name.set("BSD-2-Clause") - url.set("https://jdbc.postgresql.org/about/license.html") - comments.set("BSD-2-Clause, copyright PostgreSQL Global Development Group") - distribution.set("repo") - } - } - organization { - name.set("PostgreSQL Global Development Group") - url.set("https://jdbc.postgresql.org/") - } - developers { - developer { - id.set("davecramer") - name.set("Dave Cramer") - } - developer { - id.set("jurka") - name.set("Kris Jurka") - } - developer { - id.set("oliver") - name.set("Oliver Jowett") - } - developer { - id.set("ringerc") - name.set("Craig Ringer") - } - developer { - id.set("vlsi") - name.set("Vladimir Sitnikov") - } - developer { - id.set("bokken") - name.set("Brett Okken") - } - } - issueManagement { - system.set("GitHub issues") - url.set("https://github.com/pgjdbc/pgjdbc/issues") - } - mailingLists { - mailingList { - name.set("PostgreSQL JDBC development list") - subscribe.set("https://lists.postgresql.org/") - unsubscribe.set("https://lists.postgresql.org/unsubscribe/") - post.set("pgsql-jdbc@postgresql.org") - archive.set("https://www.postgresql.org/list/pgsql-jdbc/") - } - } - scm { - connection.set("scm:git:https://github.com/pgjdbc/pgjdbc.git") - developerConnection.set("scm:git:https://github.com/pgjdbc/pgjdbc.git") - url.set("https://github.com/pgjdbc/pgjdbc") - tag.set("HEAD") - } - } - } - // </editor-fold> - } - } +plugins.withId("de.marcphilipp.nexus-publish") { + configure<de.marcphilipp.gradle.nexus.NexusPublishExtension> { + clientTimeout.set(java.time.Duration.ofMinutes(15)) } } -subprojects { - if (project.path.startsWith(":postgresql")) { - plugins.withId("java") { - configure<JavaPluginExtension> { - val sourceSets: SourceSetContainer by project - registerFeature("sspi") { - usingSourceSet(sourceSets["main"]) - } - registerFeature("osgi") { - usingSourceSet(sourceSets["main"]) - } - } - dependencies { - "sspiImplementation"("com.github.waffle:waffle-jna") - // The dependencies are provided by OSGi container, - // so they should not be exposed as transitive dependencies - "osgiCompileOnly"("org.osgi:org.osgi.core") - "osgiCompileOnly"("org.osgi:org.osgi.service.jdbc") - "testImplementation"("org.osgi:org.osgi.service.jdbc") { - because("DataSourceFactory is needed for PGDataSourceFactoryTest") - } - } - } +plugins.withId("io.codearte.nexus-staging") { + configure<io.codearte.gradle.nexus.NexusStagingExtension> { + numberOfRetries = 20 * 60 / 2 + delayBetweenRetriesInMillis = 2000 } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 398425d9..00000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2020, PostgreSQL Global Development Group - * See the LICENSE file in the project root for more information. - */ - -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - `kotlin-dsl` - id("com.github.autostyle") -} - -repositories { - mavenCentral() - gradlePluginPortal() -} - -val String.v: String get() = rootProject.extra["$this.version"] as String - -dependencies { - implementation("com.igormaznitsa:jcp:${"jcp".v}") -} - -tasks.withType<KotlinCompile> { - kotlinOptions { - jvmTarget = "1.8" - } -} - -tasks.withType<AbstractArchiveTask>().configureEach { - // Ensure builds are reproducible - isPreserveFileTimestamps = false - isReproducibleFileOrder = true - dirMode = "775".toInt(8) - fileMode = "664".toInt(8) -} - -autostyle { - kotlin { - ktlint { - userData(mapOf("disabled_rules" to "no-wildcard-imports,import-ordering")) - } - trimTrailingWhitespace() - endWithNewline() - } - kotlinGradle { - ktlint() - trimTrailingWhitespace() - endWithNewline() - } -} diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties deleted file mode 100644 index 16329b6f..00000000 --- a/buildSrc/gradle.properties +++ /dev/null @@ -1,13 +0,0 @@ -org.gradle.parallel=true - -# See https://github.com/gradle/gradle/pull/11358 -# repository.apache.org does not yet support .sha256 and .sha512 checksums -systemProp.org.gradle.internal.publish.checksums.insecure=true - -kotlin.code.style=official - -# Plugins -com.github.autostyle.version=3.2 - -# Dependencies -jcp.version=7.0.2 diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts deleted file mode 100644 index 7d6475e1..00000000 --- a/buildSrc/settings.gradle.kts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2020, PostgreSQL Global Development Group - * See the LICENSE file in the project root for more information. - */ - -pluginManagement { - plugins { - fun String.v() = extra["$this.version"].toString() - fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v() - - idv("com.github.autostyle") - } -} diff --git a/gradle.properties b/gradle.properties index c341560c..90a1b440 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,6 +16,7 @@ kotlin.code.style=official # Release version can be generated by using -Prelease or -Prc=<int> arguments pgjdbc.version=42.6.0 +lastEditYear=2023 # The options below configures the use of local clone (e.g. testing development versions) # You can pass un-comment it, or pass option -PlocalReleasePlugins, or -PlocalReleasePlugins=<path> # localReleasePlugins=../vlsi-release-plugins @@ -28,43 +29,11 @@ pgjdbc.version=42.6.0 slowTestLogThreshold=2000 slowSuiteLogThreshold=500 -# Plugins -biz.aQute.bnd.builder.version=6.3.1 -com.github.autostyle.version=3.2 -com.github.burrunan.s3-build-cache.version=1.1 -com.github.johnrengelman.shadow.version=5.1.0 -com.github.lburgazzoli.karaf.version=0.5.4 -com.github.spotbugs.version=2.0.0 -com.github.vlsi.vlsi-release-plugins.version=1.82 -de.thetaphi.forbiddenapis.version=3.3 -kotlin.version=1.3.70 -me.champeau.jmh.version=0.6.6 -org.checkerframework.version=0.6.23 -org.jetbrains.gradle.plugin.idea-ext.version=0.7 -org.nosphere.gradle.github.actions.version=1.2.0 -org.owasp.dependencycheck.version=5.3.0 - # Tools -jacoco.version=0.8.5 -checkstyle.version=9.3 -spotbugs.version=4.0.0 - -# Dependencies -checkerframework.version=3.30.0 -classloader-leak-test-framework.version=1.1.1 -com.ongres.scram.client.version=2.1 -hamcrest-date.version=2.0.7 -hamcrest.version=2.2 -jmh.version=1.12 -javaee-api.version=6.0 -junit4.version=4.13 -junit5.version=5.8.2 -junit5-system-stubs-jupiter.version=2.0.1 -logback.version=1.1.2 -org.apache.felix.framework.version=7.0.5 -org.ops4j.pax.exam.version=4.13.5 -org.osgi.core.version=5.0.0 -org.osgi.service.jdbc.version=1.0.0 -pax-url-aether.version=2.6.7 -slf4j.version=1.7.25 -waffle-jna.version=1.9.1 +# The version below are listed for reference only, and they can be overridden by command line +# via -Pcheckstyle.version=... +# If you want to upgrade a version, modify the relevant toolVersion = "..." line in *.gradle.kts +#checkerframework.version=3.30.0 +#checkstyle.version=9.3 +#jacoco.version=0.8.5 +#spotbugs.version=4.0.0 diff --git a/pgjdbc-osgi-test/build.gradle.kts b/pgjdbc-osgi-test/build.gradle.kts index 79cf6609..bbe456b0 100644 --- a/pgjdbc-osgi-test/build.gradle.kts +++ b/pgjdbc-osgi-test/build.gradle.kts @@ -1,3 +1,7 @@ +plugins { + id("build-logic.java-library") +} + val pgjdbcRepository by configurations.creating { isCanBeConsumed = false isCanBeResolved = true @@ -14,17 +18,17 @@ dependencies { testImplementation(project(":postgresql")) - testImplementation("javax:javaee-api") - testImplementation("org.osgi:org.osgi.service.jdbc") - testImplementation("org.ops4j.pax.exam:pax-exam-container-native") + testImplementation("javax:javaee-api:6.0") + testImplementation("org.osgi:org.osgi.service.jdbc:1.0.0") + testImplementation("org.ops4j.pax.exam:pax-exam-container-native:4.13.5") // pax-exam is not yet compatible with junit5 // see https://github.com/ops4j/org.ops4j.pax.exam2/issues/886 - testImplementation("org.ops4j.pax.exam:pax-exam-junit4") - testImplementation("org.ops4j.pax.exam:pax-exam-link-mvn") - testImplementation("org.ops4j.pax.url:pax-url-aether") - testImplementation("org.apache.felix:org.apache.felix.framework") - testImplementation("ch.qos.logback:logback-core") - testImplementation("ch.qos.logback:logback-classic") + testImplementation("org.ops4j.pax.exam:pax-exam-junit4:4.13.5") + testImplementation("org.ops4j.pax.exam:pax-exam-link-mvn:4.13.5") + testImplementation("org.ops4j.pax.url:pax-url-aether:2.6.7") + testImplementation("org.apache.felix:org.apache.felix.framework:7.0.5") + testImplementation("ch.qos.logback:logback-core:1.1.2") + testImplementation("ch.qos.logback:logback-classic:1.1.2") } // <editor-fold defaultstate="collapsed" desc="Pass dependency versions to pax-exam container"> diff --git a/pgjdbc/build.gradle.kts b/pgjdbc/build.gradle.kts index 64e95cfc..16238a06 100644 --- a/pgjdbc/build.gradle.kts +++ b/pgjdbc/build.gradle.kts @@ -4,7 +4,6 @@ */ import aQute.bnd.gradle.Bundle -import aQute.bnd.gradle.BundleTaskConvention import com.github.autostyle.gradle.AutostyleTask import com.github.vlsi.gradle.dsl.configureEach import com.github.vlsi.gradle.gettext.GettextTask @@ -17,6 +16,9 @@ import com.github.vlsi.gradle.release.dsl.dependencyLicenses import com.github.vlsi.gradle.release.dsl.licensesCopySpec plugins { + id("build-logic.java-published-library") + id("build-logic.test-junit5") + id("build-logic.java-comment-preprocessor") id("biz.aQute.bnd.builder") apply false id("com.github.johnrengelman.shadow") id("com.github.lburgazzoli.karaf") @@ -32,6 +34,21 @@ buildscript { } } +java { + val sourceSets: SourceSetContainer by project + registerFeature("sspi") { + usingSourceSet(sourceSets["main"]) + } + registerFeature("osgi") { + usingSourceSet(sourceSets["main"]) + } +} + +val knows by tasks.existing { + group = null // Hide the task from `./gradlew tasks` output + description = "This is a dummy task, unfortunately the author refuses to remove it: https://github.com/johnrengelman/shadow/issues/122" +} + val shaded by configurations.creating val karafFeatures by configurations.creating { @@ -52,11 +69,24 @@ configurations { val String.v: String get() = rootProject.extra["$this.version"] as String dependencies { - shaded(platform(project(":bom"))) - shaded("com.ongres.scram:client") + constraints { + api("com.github.waffle:waffle-jna:1.9.1") + api("org.osgi:org.osgi.core:5.0.0") + api("org.osgi:org.osgi.service.jdbc:1.0.0") + } - implementation("org.checkerframework:checker-qual") - testImplementation("se.jiderhamn:classloader-leak-test-framework") + "sspiImplementation"("com.github.waffle:waffle-jna") + // The dependencies are provided by OSGi container, + // so they should not be exposed as transitive dependencies + "osgiCompileOnly"("org.osgi:org.osgi.core") + "osgiCompileOnly"("org.osgi:org.osgi.service.jdbc") + "testImplementation"("org.osgi:org.osgi.service.jdbc") { + because("DataSourceFactory is needed for PGDataSourceFactoryTest") + } + shaded("com.ongres.scram:client:2.1") + + implementation("org.checkerframework:checker-qual:3.5.0") + testImplementation("se.jiderhamn:classloader-leak-test-framework:1.1.1") } val skipReplicationTests by props() @@ -75,7 +105,7 @@ tasks.configureEach<Test> { } } -val preprocessVersion by tasks.registering(org.postgresql.buildtools.JavaCommentPreprocessorTask::class) { +val preprocessVersion by tasks.registering(buildlogic.JavaCommentPreprocessorTask::class) { baseDir.set(projectDir) sourceFolders.add("src/main/version") } @@ -205,7 +235,7 @@ tasks.shadowJar { val osgiJar by tasks.registering(Bundle::class) { archiveClassifier.set("osgi") from(tasks.shadowJar.map { zipTree(it.archiveFile) }) - withConvention(BundleTaskConvention::class) { + bundle { bnd( """ -exportcontents: !org.postgresql.shaded.*, org.postgresql.* @@ -303,24 +333,20 @@ val sourceDistribution by tasks.registering(Tar::class) { include("README.md") } - val props = listOf( - "pgjdbc.version", - "junit4.version", - "junit5.version", - "junit5-system-stubs-jupiter.version", - "classloader-leak-test-framework.version", - "com.ongres.scram.client.version" - ).associate { propertyName -> - val value = project.findProperty(propertyName) as String - inputs.property(propertyName, project.findProperty(propertyName)) - "%{$propertyName}" to value + val testRuntimeClasspath = configurations.testRuntimeClasspath + dependsOn(testRuntimeClasspath) + + val props by lazy { + // Associate group:module with version, so %{group:module} can be used in reduced-pom.xml + testRuntimeClasspath.get().incoming.resolutionResult.allComponents + .associateBy({ it.moduleVersion!!.module.toString() }, { it.moduleVersion!!.version }) } from("reduced-pom.xml") { rename { "pom.xml" } filter { - it.replace(Regex("%\\{[^}]+\\}")) { - props[it.value] ?: throw GradleException("Unknown property in reduced-pom.xml: $it") + it.replace(Regex("%\\{([^}]+)\\}")) { + props[it.groups[1]!!.value] ?: throw GradleException("Unknown property in reduced-pom.xml: ${it.value}") } } } @@ -383,42 +409,3 @@ val extraMavenPublications by configurations.getting classifier = "features" } } - -// <editor-fold defaultstate="collapsed" desc="Populates build/local-maven-repo with artifacts produced by the current project for testing purposes"> -val localRepoElements by configurations.creating { - isCanBeConsumed = true - isCanBeResolved = false - description = - "Shares local maven repository directory that contains the artifacts produced by the current project" - attributes { - attribute(Category.CATEGORY_ATTRIBUTE, objects.named("maven-repository")) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) - } -} - -val localRepoDir = layout.buildDirectory.dir("local-maven-repo") - -publishing { - repositories { - maven { - name = "local" - url = uri(localRepoDir) - } - } -} - -localRepoElements.outgoing.artifact(localRepoDir) { - builtBy(tasks.named("publishAllPublicationsToLocalRepository")) -} - -val cleanLocalRepository by tasks.registering(Delete::class) { - description = "Clears local-maven-repo so timestamp-based snapshot artifacts do not consume space" - delete(localRepoDir) -} - -tasks.withType<PublishToMavenRepository>() - .matching { it.name.contains("ToLocalRepository") } - .configureEach { - dependsOn(cleanLocalRepository) - } -// </editor-fold> diff --git a/pgjdbc/reduced-pom.xml b/pgjdbc/reduced-pom.xml index 084393e1..8b8a7752 100644 --- a/pgjdbc/reduced-pom.xml +++ b/pgjdbc/reduced-pom.xml @@ -10,7 +10,7 @@ <artifactId>postgresql</artifactId> <packaging>jar</packaging> <name>PostgreSQL JDBC Driver - JDBC 4.2</name> - <version>%{pgjdbc.version}</version> + <version>%{org.postgresql:postgresql}</version> <description>Java JDBC 4.2 (JRE 8+) driver for PostgreSQL database</description> <url>https://github.com/pgjdbc/pgjdbc</url> @@ -43,47 +43,48 @@ <dependency> <groupId>com.ongres.scram</groupId> <artifactId>client</artifactId> - <version>%{com.ongres.scram.client.version}</version> + <version>%{com.ongres.scram:client}</version> </dependency> <dependency> <groupId>se.jiderhamn</groupId> <artifactId>classloader-leak-test-framework</artifactId> - <version>%{classloader-leak-test-framework.version}</version> + <version>%{se.jiderhamn:classloader-leak-test-framework}</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>%{junit4.version}</version> + <version>%{junit:junit}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> - <version>%{junit5.version}</version> + <version>%{org.junit.jupiter:junit-jupiter-api}</version> <scope>test</scope> </dependency> <dependency> <groupId>uk.org.webcompere</groupId> <artifactId>system-stubs-jupiter</artifactId> - <version>%{junit5-system-stubs-jupiter.version}</version> + <version>%{uk.org.webcompere:system-stubs-jupiter}</version> + <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> - <version>%{junit5.version}</version> + <version>%{org.junit.jupiter:junit-jupiter-params}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> - <version>%{junit5.version}</version> + <version>%{org.junit.jupiter:junit-jupiter-params}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> - <version>%{junit5.version}</version> + <version>%{org.junit.jupiter:junit-jupiter-params}</version> <scope>test</scope> </dependency> </dependencies> diff --git a/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java b/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java index 3ac5eb25..1f5b7129 100644 --- a/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java +++ b/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java @@ -659,6 +659,7 @@ public class PgConnection implements BaseConnection { return queryExecutor.getUser(); } + @SuppressWarnings("deprecation") // support for deprecated Fastpath API public Fastpath getFastpathAPI() throws SQLException { checkClosed(); if (fastpath == null) { @@ -668,6 +669,7 @@ public class PgConnection implements BaseConnection { } // This holds a reference to the Fastpath API if already open + @SuppressWarnings("deprecation") // support for deprecated Fastpath API private @Nullable Fastpath fastpath; public LargeObjectManager getLargeObjectAPI() throws SQLException { diff --git a/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java b/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java index d0e8fd0e..e5e07384 100644 --- a/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java +++ b/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java @@ -355,6 +355,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { return keywords; } + @SuppressWarnings("deprecation") public String getNumericFunctions() throws SQLException { return EscapedFunctions.ABS + ',' + EscapedFunctions.ACOS + ',' + EscapedFunctions.ASIN + ',' + EscapedFunctions.ATAN + ',' + EscapedFunctions.ATAN2 + ',' + EscapedFunctions.CEILING @@ -367,6 +368,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { } + @SuppressWarnings("deprecation") public String getStringFunctions() throws SQLException { String funcs = EscapedFunctions.ASCII + ',' + EscapedFunctions.CHAR + ',' + EscapedFunctions.CONCAT + ',' + EscapedFunctions.LCASE + ',' + EscapedFunctions.LEFT + ',' @@ -386,10 +388,12 @@ public class PgDatabaseMetaData implements DatabaseMetaData { return funcs; } + @SuppressWarnings("deprecation") public String getSystemFunctions() throws SQLException { return EscapedFunctions.DATABASE + ',' + EscapedFunctions.IFNULL + ',' + EscapedFunctions.USER; } + @SuppressWarnings("deprecation") public String getTimeDateFunctions() throws SQLException { String timeDateFuncs = EscapedFunctions.CURDATE + ',' + EscapedFunctions.CURTIME + ',' + EscapedFunctions.DAYNAME + ',' + EscapedFunctions.DAYOFMONTH + ',' diff --git a/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObject.java b/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObject.java index 7bd142ce..2baf2ff0 100644 --- a/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObject.java +++ b/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObject.java @@ -42,6 +42,7 @@ import java.sql.SQLException; * @see java.sql.PreparedStatement#setBinaryStream * @see java.sql.PreparedStatement#setUnicodeStream */ +@SuppressWarnings("deprecation") // support for deprecated Fastpath API public class LargeObject implements AutoCloseable { diff --git a/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObjectManager.java b/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObjectManager.java index 12780968..12efe14e 100644 --- a/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObjectManager.java +++ b/pgjdbc/src/main/java/org/postgresql/largeobject/LargeObjectManager.java @@ -56,6 +56,7 @@ import java.util.logging.Level; * @see java.sql.PreparedStatement#setBinaryStream * @see java.sql.PreparedStatement#setUnicodeStream */ +@SuppressWarnings("deprecation") // support for deprecated Fastpath API public class LargeObjectManager { // the fastpath api for this connection private Fastpath fp; diff --git a/pgjdbc/src/main/java/org/postgresql/osgi/PGDataSourceFactory.java b/pgjdbc/src/main/java/org/postgresql/osgi/PGDataSourceFactory.java index 00cd8581..9f4cf9f2 100644 --- a/pgjdbc/src/main/java/org/postgresql/osgi/PGDataSourceFactory.java +++ b/pgjdbc/src/main/java/org/postgresql/osgi/PGDataSourceFactory.java @@ -56,6 +56,7 @@ public class PGDataSourceFactory implements DataSourceFactory { } } + @SuppressWarnings("deprecation") private void configureBaseDataSource(BaseDataSource ds, Properties props) throws SQLException { if (props.containsKey(JDBC_URL)) { ds.setUrl(castNonNull(props.getProperty(JDBC_URL))); @@ -89,6 +90,7 @@ public class PGDataSourceFactory implements DataSourceFactory { return new org.postgresql.Driver(); } + @SuppressWarnings("deprecation") private DataSource createPoolingDataSource(Properties props) throws SQLException { PoolingDataSource dataSource = new PoolingDataSource(); if (props.containsKey(JDBC_INITIAL_POOL_SIZE)) { @@ -106,6 +108,7 @@ public class PGDataSourceFactory implements DataSourceFactory { return dataSource; } + @SuppressWarnings("deprecation") private DataSource createSimpleDataSource(Properties props) throws SQLException { SimpleDataSource dataSource = new SimpleDataSource(); configureBaseDataSource(dataSource, props); @@ -130,6 +133,7 @@ public class PGDataSourceFactory implements DataSourceFactory { } } + @SuppressWarnings("deprecation") public ConnectionPoolDataSource createConnectionPoolDataSource(Properties props) throws SQLException { props = new SingleUseProperties(props); diff --git a/settings.gradle.kts b/settings.gradle.kts index 07908cd2..f829e785 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,37 +5,25 @@ pluginManagement { plugins { - fun String.v() = extra["$this.version"].toString() - fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v() - - idv("biz.aQute.bnd.builder") - idv("com.github.autostyle") - idv("com.github.burrunan.s3-build-cache") - idv("com.github.johnrengelman.shadow") - idv("com.github.lburgazzoli.karaf") - idv("com.github.spotbugs") - idv("com.github.vlsi.crlf", "com.github.vlsi.vlsi-release-plugins") - idv("com.github.vlsi.gettext", "com.github.vlsi.vlsi-release-plugins") - idv("com.github.vlsi.gradle-extensions", "com.github.vlsi.vlsi-release-plugins") - idv("com.github.vlsi.ide", "com.github.vlsi.vlsi-release-plugins") - idv("com.github.vlsi.jandex", "com.github.vlsi.vlsi-release-plugins") - idv("com.github.vlsi.license-gather", "com.github.vlsi.vlsi-release-plugins") - idv("com.github.vlsi.stage-vote-release", "com.github.vlsi.vlsi-release-plugins") - idv("de.thetaphi.forbiddenapis") - idv("me.champeau.jmh") - idv("org.checkerframework") - idv("org.jetbrains.gradle.plugin.idea-ext") - idv("org.nosphere.gradle.github.actions") - idv("org.owasp.dependencycheck") - kotlin("jvm") version "kotlin".v() + id("biz.aQute.bnd.builder") version "6.3.1" + id("com.github.burrunan.s3-build-cache") version "1.1" + id("com.github.johnrengelman.shadow") version "5.1.0" + id("com.github.lburgazzoli.karaf") version "0.5.4" + id("com.github.vlsi.crlf") version "1.86" + id("com.github.vlsi.gettext") version "1.86" + id("com.github.vlsi.gradle-extensions") version "1.86" + id("com.github.vlsi.license-gather") version "1.86" + id("com.github.vlsi.ide") version "1.86" + id("com.github.vlsi.stage-vote-release") version "1.86" + id("org.nosphere.gradle.github.actions") version "1.2.0" + id("org.owasp.dependencycheck") version "5.3.0" + id("me.champeau.jmh") version "0.6.8" + kotlin("jvm") version "1.8.10" } } plugins { - // TODO: remove explicit version once upgrade to Gradle 7.4+ - // The version is explicitly specified to support building with tr_TR locale - // See https://github.com/gradle/gradle/issues/17361 - id("com.gradle.enterprise") version "3.10.1" + `gradle-enterprise` id("com.github.burrunan.s3-build-cache") } @@ -43,8 +31,9 @@ plugins { // Note: it cannot be inferred from the directory name as developer might clone pgjdbc to pgjdbc_tmp (or whatever) folder rootProject.name = "pgjdbc" +includeBuild("build-logic") + include( - "bom", "benchmarks", "postgresql", "pgjdbc-osgi-test" [parent: 59ca5d92f8ac]