diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a576d65..7ba8b169 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,4 +50,4 @@ jobs: uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 - name: Check with Gradle - run: ./gradlew rat licenseCheck javadoc check + run: ./gradlew rat spotlessCheck javadoc check diff --git a/buildSrc/settings.gradle b/build-logic/build.gradle.kts similarity index 81% rename from buildSrc/settings.gradle rename to build-logic/build.gradle.kts index 0e8e5cdd..90b5ea53 100644 --- a/buildSrc/settings.gradle +++ b/build-logic/build.gradle.kts @@ -17,10 +17,12 @@ * under the License. */ -dependencyResolutionManagement { - versionCatalogs { - libs { - from(files("../gradle/libs.versions.toml")) - } - } -} \ No newline at end of file +plugins { + `kotlin-dsl` +} + +dependencies { + implementation(libs.spotless.gradle.plugin) + implementation(libs.spring.javaformat.gradle.plugin) + implementation(libs.testlogger.gradle.plugin) +} diff --git a/pulsar-client-reactive-bom/build.gradle b/build-logic/settings.gradle.kts similarity index 61% rename from pulsar-client-reactive-bom/build.gradle rename to build-logic/settings.gradle.kts index 0442ff55..5ef9a46b 100644 --- a/pulsar-client-reactive-bom/build.gradle +++ b/build-logic/settings.gradle.kts @@ -17,28 +17,22 @@ * under the License. */ -plugins { - id 'java-platform' - id 'pulsar-client-reactive.publish-conventions' -} - -dependencies { - constraints { - project.rootProject.subprojects - .sort { "$it.name" } - .findAll { it.name != "pulsar-client-reactive-bom" } - .each { - api it - } +dependencyResolutionManagement { + repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS + repositories { + mavenCentral() + // The test-logger plugin is published to the Gradle Plugin Portal only, so restrict + // the portal to that group instead of letting it answer for every dependency. + exclusiveContent { + forRepository { gradlePluginPortal() } + filter { includeGroup("com.adarshr") } + } } -} - -publishing { - publications { - mavenJava(MavenPublication) { - from components.javaPlatform + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) } } } -description = 'Reactive Java client for Apache Pulsar (Bill of Materials)' +rootProject.name = "build-logic" diff --git a/build-logic/src/main/kotlin/pulsar-client-reactive.codestyle-conventions.gradle.kts b/build-logic/src/main/kotlin/pulsar-client-reactive.codestyle-conventions.gradle.kts new file mode 100644 index 00000000..ca205a76 --- /dev/null +++ b/build-logic/src/main/kotlin/pulsar-client-reactive.codestyle-conventions.gradle.kts @@ -0,0 +1,61 @@ +/* + * 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 + * + * https://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. + */ + +plugins { + checkstyle + id("io.spring.javaformat") + id("com.diffplug.spotless") +} + +// The version catalog has no type-safe accessors inside a precompiled script plugin, so it +// has to be looked up through the extension. +val libs = extensions.getByType().named("libs") + +// `isolated` keeps this compatible with configuration caching and project isolation. +val checkstyleConfigDir = isolated.rootProject.projectDirectory.dir("checkstyle") +val licenseHeader = checkstyleConfigDir.file("HEADER.txt") + +dependencies { + checkstyle(libs.findLibrary("spring-javaformat-checkstyle").get()) +} + +checkstyle { + toolVersion = libs.findVersion("checkstyle").get().requiredVersion + // `configFile` defaults to `checkstyle.xml` inside `configDirectory` + configDirectory = checkstyleConfigDir +} + +// Formatting of Java sources is owned by spring-javaformat; Spotless only enforces the ASF +// license header. Apache RAT is the repository-wide backstop for every other file type. +spotless { + kotlinGradle { + target("*.gradle.kts") + licenseHeaderFile(licenseHeader, "(plugins|import|rootProject|pluginManagement|dependencyResolutionManagement)") + } +} + +// `java` has no sources to point Spotless at until the `java` plugin is applied, which +// happens after this convention plugin. Reacting to the plugin avoids `afterEvaluate`. +pluginManager.withPlugin("java") { + spotless { + java { + licenseHeaderFile(licenseHeader) + } + } +} diff --git a/buildSrc/src/main/groovy/pulsar-client-reactive.library-conventions.gradle b/build-logic/src/main/kotlin/pulsar-client-reactive.library-conventions.gradle.kts similarity index 58% rename from buildSrc/src/main/groovy/pulsar-client-reactive.library-conventions.gradle rename to build-logic/src/main/kotlin/pulsar-client-reactive.library-conventions.gradle.kts index b1ca78dd..0f01fdf8 100644 --- a/buildSrc/src/main/groovy/pulsar-client-reactive.library-conventions.gradle +++ b/build-logic/src/main/kotlin/pulsar-client-reactive.library-conventions.gradle.kts @@ -18,43 +18,51 @@ */ plugins { - id 'java-library' - id 'pulsar-client-reactive.publish-conventions' + `java-library` + id("pulsar-client-reactive.publish-conventions") } -repositories { - mavenCentral() -} +val libs = extensions.getByType().named("libs") java { withJavadocJar() withSourcesJar() + // Pinning the toolchain decouples the build from whichever JDK happens to be on PATH + // and keeps the compiled output reproducible. toolchain { languageVersion = JavaLanguageVersion.of(17) } } -compileJava { +tasks.withType().configureEach { + options.encoding = "UTF-8" +} + +tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME) { options.release = 8 } +tasks.withType().configureEach { + options.encoding = "UTF-8" +} + dependencies { - testRuntimeOnly libs.junit.platform.launcher + testRuntimeOnly(libs.findLibrary("junit-platform-launcher").get()) } -tasks.withType(Test) { +tasks.withType().configureEach { useJUnitPlatform() } publishing { publications { - mavenJava(MavenPublication) { - from components.java + named("mavenJava") { + from(components["java"]) versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') + usage(Usage.JAVA_API) { + fromResolutionOf(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) } - usage('java-runtime') { + usage(Usage.JAVA_RUNTIME) { fromResolutionResult() } } diff --git a/build-logic/src/main/kotlin/pulsar-client-reactive.publish-conventions.gradle.kts b/build-logic/src/main/kotlin/pulsar-client-reactive.publish-conventions.gradle.kts new file mode 100644 index 00000000..eb11910e --- /dev/null +++ b/build-logic/src/main/kotlin/pulsar-client-reactive.publish-conventions.gradle.kts @@ -0,0 +1,80 @@ +/* + * 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 + * + * https://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. + */ + +plugins { + `maven-publish` + signing +} + +val publishDebug = providers.gradleProperty("publishDebug") +val isSnapshot = provider { version.toString().endsWith("-SNAPSHOT") } + +// `project.description` is assigned at the bottom of each module's build script, so it has +// to be read lazily rather than when this convention plugin is applied. +val projectDescription = objects.property().value(provider { description }) + +publishing { + repositories { + maven { + if (publishDebug.isPresent) { + url = uri(publishDebug.get()) + } + else { + name = "asf" + url = uri( + if (isSnapshot.get()) "https://repository.apache.org/content/repositories/snapshots/" + else "https://repository.apache.org/service/local/staging/deploy/maven2" + ) + credentials(PasswordCredentials::class) + } + } + } + publications { + create("mavenJava") { + pom { + name = project.name + description = projectDescription + url = "https://github.com/apache/pulsar-client-reactive" + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + distribution = "repo" + } + } + developers { + developer { + organization = "Apache Pulsar developers" + organizationUrl = "https://pulsar.apache.org/" + } + } + scm { + connection = "scm:git:https://github.com/apache/pulsar-client-reactive.git" + developerConnection = "scm:git:https://github.com/apache/pulsar-client-reactive.git" + url = "https://github.com/apache/pulsar-client-reactive" + } + } + } + } +} + +signing { + setRequired(!publishDebug.isPresent) + sign(publishing.publications["mavenJava"]) +} diff --git a/build-logic/src/main/kotlin/pulsar-client-reactive.test-conventions.gradle.kts b/build-logic/src/main/kotlin/pulsar-client-reactive.test-conventions.gradle.kts new file mode 100644 index 00000000..80118f84 --- /dev/null +++ b/build-logic/src/main/kotlin/pulsar-client-reactive.test-conventions.gradle.kts @@ -0,0 +1,69 @@ +/* + * 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 + * + * https://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. + */ + +plugins { + `java-library` + id("com.adarshr.test-logger") +} + +val libs = extensions.getByType().named("libs") + +testlogger { + showStandardStreams = true +} + +val main: SourceSet = sourceSets[SourceSet.MAIN_SOURCE_SET_NAME] +val intTest: SourceSet = sourceSets.create("intTest") { + compileClasspath += main.output + runtimeClasspath += main.output +} + +configurations[intTest.implementationConfigurationName] + .extendsFrom(configurations[JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME]) +configurations[intTest.runtimeOnlyConfigurationName] + .extendsFrom(configurations[JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME]) + +// `isolated` keeps this compatible with configuration caching and project isolation. +val sharedTestResources = files(isolated.rootProject.projectDirectory.dir("shared-test-resources")) + +dependencies { + // add shared-test-resources directory to runtime classpath + intTest.runtimeOnlyConfigurationName(sharedTestResources) + JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME(sharedTestResources) + intTest.runtimeOnlyConfigurationName(libs.findLibrary("junit-platform-launcher").get()) +} + +val integrationTest = tasks.register("integrationTest") { + description = "Runs integration tests." + group = LifecycleBasePlugin.VERIFICATION_GROUP + + testClassesDirs = intTest.output.classesDirs + classpath = intTest.runtimeClasspath + shouldRunAfter(tasks.named(JavaPlugin.TEST_TASK_NAME)) +} + +tasks.named(LifecycleBasePlugin.CHECK_TASK_NAME) { + dependsOn(integrationTest) +} + +tasks.withType().configureEach { + // reduces CPU usage in tests when JIT compiler doesn't spend time compiling code + // this could help reduce flakiness in CI where there's less CPU resources available + jvmArgs("-XX:TieredStopAtLevel=1") +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index e3896b81..00000000 --- a/build.gradle +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -plugins { - alias(libs.plugins.versions) - alias(libs.plugins.version.catalog.update) - id 'pulsar-client-reactive.codestyle-conventions' -} - -allprojects { - group = 'org.apache.pulsar' - apply plugin: 'io.spring.javaformat' - apply plugin: 'org.nosphere.apache.rat' - - repositories { - mavenCentral() - } - - tasks.named('rat') { - inputDir = projectDir - excludes = ['.asf.yaml', // ASF metadata for github integration excluded from src zip - '**/.gradle/**', '**/wrapper/**', 'gradlew*', // gradle wrapper files excluded from src zip - 'gradle.properties', // artifactory release plugin removes header when bumping version - '**/build/**', '**/target/**', 'licenses/**', 'notices/**', - '**/META-INF/services/*', - 'out/**', '*.ipr', '**/*.iml', '*.iws', '.idea/**', // Intellij files - '.classpath', '.project', '.settings/**', 'bin/**', // Eclipse files - ] - } -} - -task sourceTar(type: Tar) { - destinationDirectory = buildDir - archiveBaseName = "pulsar-client-reactive-${rootProject.version}" - archiveClassifier = "src" - archiveExtension = "tar.gz" - compression = Compression.GZIP - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - includeEmptyDirs = false - into(archiveBaseName) { - from(rootDir) { - excludes = [ - '.github/**', '.asf.yaml', - '**/build/**', '**/target/**', - 'out/**', '*.ipr', '**/*.iml', '*.iws', '.idea/**', // Intellij files - '.classpath', '.project', '.settings/**', 'bin/**', // Eclipse files - '**/.gradle/**', '**/wrapper/**', 'gradlew*', // gradle wrapper files excluded from src zip - ] - } - } -} - -license { - tasks { - rootProjectExtraFiles { - files.from('checkstyle', 'idea', 'shared-test-resources', 'buildSrc/src', 'buildSrc/build.gradle', '.github') - } - } -} - -tasks.named("dependencyUpdates").configure { - rejectVersionIf { - it.candidate.version.contains("alpha") || it.candidate.version.contains("beta") || it.candidate.version.contains("rc") - } -} - -versionCatalogUpdate { - keep { - keepUnusedLibraries = true - keepUnusedVersions = true - } -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..80dd9d4a --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,80 @@ +/* + * 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 + * + * https://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. + */ + +plugins { + alias(libs.plugins.rat) + alias(libs.plugins.versions) + alias(libs.plugins.version.catalog.update) + id("pulsar-client-reactive.codestyle-conventions") +} + +// A single RAT run over the whole repository; it already covers every subproject directory. +tasks.rat { + inputDir = layout.projectDirectory + setExcludes( + listOf( + ".asf.yaml", // ASF metadata for github integration excluded from src zip + "**/.gradle/**", "**/wrapper/**", "gradlew*", // gradle wrapper files excluded from src zip + "gradle.properties", // artifactory release plugin removes header when bumping version + "**/build/**", "**/target/**", "licenses/**", "notices/**", + "**/META-INF/services/*", + "out/**", "*.ipr", "**/*.iml", "*.iws", ".idea/**", // Intellij files + ".classpath", ".project", ".settings/**", "bin/**", // Eclipse files + ) + ) +} + +tasks.register("sourceTar") { + description = "Assembles a source distribution archive of the whole repository." + group = BasePlugin.BUILD_GROUP + + destinationDirectory = layout.buildDirectory + archiveBaseName = "pulsar-client-reactive-$version" + archiveClassifier = "src" + archiveExtension = "tar.gz" + compression = Compression.GZIP + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + includeEmptyDirs = false + into(archiveBaseName) { + from(layout.projectDirectory) { + exclude( + ".github/**", ".asf.yaml", + "**/build/**", "**/target/**", + "out/**", "*.ipr", "**/*.iml", "*.iws", ".idea/**", // Intellij files + ".classpath", ".project", ".settings/**", "bin/**", // Eclipse files + "**/.gradle/**", "**/wrapper/**", "gradlew*", // gradle wrapper files excluded from src zip + ) + } + } +} + +tasks.dependencyUpdates { + rejectVersionIf { + listOf("alpha", "beta", "rc").any { candidate.version.contains(it) } + } +} + +// Note: `versionCatalogUpdate` reads `Task.project` at execution time, so it discards the +// configuration cache entry. It is a maintenance task outside the assemble/check flows. +versionCatalogUpdate { + keep { + // keep versions that no library or plugin entry references + keepUnusedVersions = true + } +} diff --git a/buildSrc/src/main/groovy/pulsar-client-reactive.publish-conventions.gradle b/buildSrc/src/main/groovy/pulsar-client-reactive.publish-conventions.gradle deleted file mode 100644 index 60151cb1..00000000 --- a/buildSrc/src/main/groovy/pulsar-client-reactive.publish-conventions.gradle +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -plugins { - id 'maven-publish' - id 'signing' -} - -publishing { - repositories { - maven { - if (project.hasProperty("publishDebug")) { - url = project.property("publishDebug") - } else { - name = 'asf' - url = version.endsWith('-SNAPSHOT') ? 'https://repository.apache.org/content/repositories/snapshots/' : 'https://repository.apache.org/service/local/staging/deploy/maven2' - credentials(PasswordCredentials) - } - } - } - publications { - mavenJava(MavenPublication) { publication -> - pom { - afterEvaluate { - name = project.name - description = project.description - } - url = 'https://github.com/apache/pulsar-client-reactive' - licenses { - license { - name = 'The Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution = 'repo' - } - } - developers { - developer { - id = 'lhotari' - name = 'Lari Hotari' - email = 'lhotari@apache.org' - } - developer { - id = 'cbornet' - name = 'Christophe Bornet' - email = 'cbornet@apache.org' - } - } - scm { - connection = 'scm:git:https://github.com/apache/pulsar-client-reactive.git' - developerConnection = 'scm:git:https://github.com/apache/pulsar-client-reactive.git' - url = 'https://github.com/apache/pulsar-client-reactive' - } - } - } - } -} - -signing { - required !project.hasProperty("publishDebug") - sign publishing.publications.mavenJava -} diff --git a/buildSrc/src/main/groovy/pulsar-client-reactive.test-conventions.gradle b/buildSrc/src/main/groovy/pulsar-client-reactive.test-conventions.gradle deleted file mode 100644 index 6e137d49..00000000 --- a/buildSrc/src/main/groovy/pulsar-client-reactive.test-conventions.gradle +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -plugins { - id 'com.adarshr.test-logger' -} - -testlogger { - showStandardStreams true -} - -sourceSets { - intTest { - compileClasspath += sourceSets.main.output - runtimeClasspath += sourceSets.main.output - } -} - -configurations { - intTestImplementation.extendsFrom implementation - intTestRuntimeOnly.extendsFrom runtimeOnly -} - -dependencies { - // add shared-test-resources directory to runtime classpath - def sharedTestResourcesEntry = files(new File(rootDir, "shared-test-resources")) - intTestRuntimeOnly sharedTestResourcesEntry - testRuntimeOnly sharedTestResourcesEntry - intTestRuntimeOnly libs.junit.platform.launcher -} - -tasks.register('integrationTest', Test) { - description = 'Runs integration tests.' - group = 'verification' - - testClassesDirs = sourceSets.intTest.output.classesDirs - classpath = sourceSets.intTest.runtimeClasspath - shouldRunAfter test -} - -check.dependsOn integrationTest - - -tasks.withType(Test) { - // reduces CPU usage in tests when JIT compiler doesn't spend time compiling code - // this could help reduce flakiness in CI where there's less CPU resources available - jvmArgs '-XX:TieredStopAtLevel=1' -} \ No newline at end of file diff --git a/checkstyle/HEADER.txt b/checkstyle/HEADER.txt index 8ca94578..62084553 100644 --- a/checkstyle/HEADER.txt +++ b/checkstyle/HEADER.txt @@ -1,16 +1,19 @@ -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 +/* + * 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 + * + * https://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. + */ - https://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. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index a107d410..c5c0ce07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,13 @@ # under the License. # +group=org.apache.pulsar version=0.7.1-SNAPSHOT + +# Pin the file encoding so the build behaves the same everywhere and does not miss build +# cache entries because of a platform-dependent default. +org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 +org.gradle.parallel=true +org.gradle.caching=true +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f5545c7a..8835c96d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,22 +20,24 @@ assertj = "3.27.7" # @pin caffeine = "2.9.3" +# @pin pinned by spring-javaformat-checkstyle, which depends on checkstyle 9.3 checkstyle = "9.3" # @pin jackson = "2.18.9" # @pin jctools = "3.3.0" junit-jupiter = "6.1.3" -licenser = "0.6.1" log4j = "2.24.3" mockito = "5.23.0" pulsar = "4.2.4" -rat-gradle = "0.8.0" +rat = "0.8.1" reactor = "3.7.19" +shadow = "9.6.1" slf4j = "2.0.18" +spotless = "8.10.0" spring-javaformat = "0.0.48" testcontainers = "1.21.4" -testlogger = "3.2.0" +testlogger = "4.0.0" [libraries] assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" } @@ -46,7 +48,6 @@ jctools-core = { module = "org.jctools:jctools-core", version.ref = "jctools" } junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" } junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit-jupiter" } junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-jupiter" } -licenser = { module = "gradle.plugin.org.cadixdev.gradle:licenser", version.ref = "licenser" } log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" } log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" } log4j-slf4j2-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version.ref = "log4j" } @@ -54,14 +55,17 @@ mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" } pulsar-client-all = { module = "org.apache.pulsar:pulsar-client-all", version.ref = "pulsar" } pulsar-client-api = { module = "org.apache.pulsar:pulsar-client-api", version.ref = "pulsar" } pulsar-client-shaded = { module = "org.apache.pulsar:pulsar-client", version.ref = "pulsar" } -rat-gradle = { module = "org.nosphere.apache:creadur-rat-gradle", version.ref = "rat-gradle" } reactor-core = { module = "io.projectreactor:reactor-core", version.ref = "reactor" } reactor-test = { module = "io.projectreactor:reactor-test", version.ref = "reactor" } slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } spring-javaformat-checkstyle = { module = "io.spring.javaformat:spring-javaformat-checkstyle", version.ref = "spring-javaformat" } -spring-javaformat-gradle-plugin = { module = "io.spring.javaformat:spring-javaformat-gradle-plugin", version.ref = "spring-javaformat" } testcontainers-pulsar = { module = "org.testcontainers:pulsar", version.ref = "testcontainers" } -testlogger = { module = "com.adarshr:gradle-test-logger-plugin", version.ref = "testlogger" } + +# Gradle plugin implementations, used on the `build-logic` compile classpath so that the +# convention plugins can apply them. Keep in sync with the matching `[plugins]` aliases. +spotless-gradle-plugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } +spring-javaformat-gradle-plugin = { module = "io.spring.javaformat:spring-javaformat-gradle-plugin", version.ref = "spring-javaformat" } +testlogger-gradle-plugin = { module = "com.adarshr:gradle-test-logger-plugin", version.ref = "testlogger" } [bundles] log4j = [ @@ -72,5 +76,7 @@ log4j = [ ] [plugins] -version-catalog-update = "nl.littlerobots.version-catalog-update:0.8.5" -versions = "com.github.ben-manes.versions:0.51.0" +rat = { id = "org.nosphere.apache.rat", version.ref = "rat" } +shadow = { id = "com.gradleup.shadow", version.ref = "shadow" } +version-catalog-update = "nl.littlerobots.version-catalog-update:1.1.1" +versions = "io.github.ben-manes.versions:0.61.0" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 2c352119..eddabd2e 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 09523c0e..84c5a9c6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,10 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionSha256Sum=84fbba45c7f4c64abc77460e1c00f541e9f960e3c7ed2538f1ede19eacd873ae +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip networkTimeout=10000 +retries=0 +retryBackOffMs=500 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index f5feea6d..249efbb0 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ ############################################################################## # -# Gradle start up script for POSIX generated by Gradle. +# gradlew start up script for POSIX generated by Gradle. # # Important for running: # @@ -29,7 +29,7 @@ # bash, then to run this script, type that shell name before the whole # command line, like: # -# ksh Gradle +# ksh gradlew # # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -115,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -173,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -206,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9d21a218..a51ec4f5 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -19,12 +19,12 @@ @if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem -@rem Gradle startup script for Windows +@rem gradlew startup script for Windows @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -51,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -65,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/pulsar-client-reactive-adapter/build.gradle b/pulsar-client-reactive-adapter/build.gradle.kts similarity index 50% rename from pulsar-client-reactive-adapter/build.gradle rename to pulsar-client-reactive-adapter/build.gradle.kts index 37e67748..9e695cb1 100644 --- a/pulsar-client-reactive-adapter/build.gradle +++ b/pulsar-client-reactive-adapter/build.gradle.kts @@ -18,30 +18,30 @@ */ plugins { - id 'pulsar-client-reactive.codestyle-conventions' - id 'pulsar-client-reactive.library-conventions' - id 'pulsar-client-reactive.test-conventions' + id("pulsar-client-reactive.codestyle-conventions") + id("pulsar-client-reactive.library-conventions") + id("pulsar-client-reactive.test-conventions") } dependencies { - api project(':pulsar-client-reactive-api') - api libs.pulsar.client.shaded - api libs.reactor.core - api libs.slf4j.api + api(project(":pulsar-client-reactive-api")) + api(libs.pulsar.client.shaded) + api(libs.reactor.core) + api(libs.slf4j.api) - testImplementation libs.junit.jupiter - testImplementation libs.reactor.test - testImplementation libs.assertj.core - testImplementation libs.bundles.log4j - testImplementation libs.mockito.core + testImplementation(libs.junit.jupiter) + testImplementation(libs.reactor.test) + testImplementation(libs.assertj.core) + testImplementation(libs.bundles.log4j) + testImplementation(libs.mockito.core) - intTestImplementation libs.pulsar.client.all - intTestImplementation project(':pulsar-client-reactive-producer-cache-caffeine') - intTestImplementation project(path: ':pulsar-client-reactive-producer-cache-caffeine-shaded', configuration: 'shadow') - intTestImplementation libs.junit.jupiter - intTestImplementation libs.testcontainers.pulsar - intTestImplementation libs.assertj.core - intTestImplementation libs.bundles.log4j + "intTestImplementation"(libs.pulsar.client.all) + "intTestImplementation"(project(":pulsar-client-reactive-producer-cache-caffeine")) + "intTestImplementation"(project(":pulsar-client-reactive-producer-cache-caffeine-shaded", configuration = "shadow")) + "intTestImplementation"(libs.junit.jupiter) + "intTestImplementation"(libs.testcontainers.pulsar) + "intTestImplementation"(libs.assertj.core) + "intTestImplementation"(libs.bundles.log4j) } description = "Reactive Streams adapter for Apache Pulsar Java client" diff --git a/pulsar-client-reactive-api/build.gradle b/pulsar-client-reactive-api/build.gradle.kts similarity index 63% rename from pulsar-client-reactive-api/build.gradle rename to pulsar-client-reactive-api/build.gradle.kts index 47067e0b..8a0fc33c 100644 --- a/pulsar-client-reactive-api/build.gradle +++ b/pulsar-client-reactive-api/build.gradle.kts @@ -18,23 +18,23 @@ */ plugins { - id 'pulsar-client-reactive.codestyle-conventions' - id 'pulsar-client-reactive.library-conventions' - id 'pulsar-client-reactive.test-conventions' + id("pulsar-client-reactive.codestyle-conventions") + id("pulsar-client-reactive.library-conventions") + id("pulsar-client-reactive.test-conventions") } dependencies { - api libs.reactor.core - api libs.pulsar.client.api - api libs.slf4j.api - implementation libs.jctools.core + api(libs.reactor.core) + api(libs.pulsar.client.api) + api(libs.slf4j.api) + implementation(libs.jctools.core) - testImplementation libs.pulsar.client.shaded - testImplementation libs.junit.jupiter - testImplementation libs.junit.jupiter.params - testImplementation libs.reactor.test - testImplementation libs.assertj.core - testImplementation libs.bundles.log4j + testImplementation(libs.pulsar.client.shaded) + testImplementation(libs.junit.jupiter) + testImplementation(libs.junit.jupiter.params) + testImplementation(libs.reactor.test) + testImplementation(libs.assertj.core) + testImplementation(libs.bundles.log4j) } description = "Reactive Java client for Apache Pulsar" diff --git a/buildSrc/build.gradle b/pulsar-client-reactive-bom/build.gradle.kts similarity index 55% rename from buildSrc/build.gradle rename to pulsar-client-reactive-bom/build.gradle.kts index e53d3732..c66c3140 100644 --- a/buildSrc/build.gradle +++ b/pulsar-client-reactive-bom/build.gradle.kts @@ -18,19 +18,28 @@ */ plugins { - id 'groovy-gradle-plugin' + `java-platform` + id("pulsar-client-reactive.publish-conventions") } -repositories { - mavenCentral() - maven { - url "https://plugins.gradle.org/m2/" +// Listed explicitly rather than derived from `rootProject.subprojects`, which would be +// cross-project configuration. +dependencies { + constraints { + api(project(":pulsar-client-reactive-adapter")) + api(project(":pulsar-client-reactive-api")) + api(project(":pulsar-client-reactive-jackson")) + api(project(":pulsar-client-reactive-producer-cache-caffeine")) + api(project(":pulsar-client-reactive-producer-cache-caffeine-shaded")) } } -dependencies { - implementation libs.spring.javaformat.gradle.plugin - implementation libs.licenser - implementation libs.testlogger - implementation libs.rat.gradle -} \ No newline at end of file +publishing { + publications { + named("mavenJava") { + from(components["javaPlatform"]) + } + } +} + +description = "Reactive Java client for Apache Pulsar (Bill of Materials)" diff --git a/pulsar-client-reactive-jackson/build.gradle b/pulsar-client-reactive-jackson/build.gradle.kts similarity index 70% rename from pulsar-client-reactive-jackson/build.gradle rename to pulsar-client-reactive-jackson/build.gradle.kts index 3b8fbfc3..8bb0e334 100644 --- a/pulsar-client-reactive-jackson/build.gradle +++ b/pulsar-client-reactive-jackson/build.gradle.kts @@ -18,19 +18,19 @@ */ plugins { - id 'pulsar-client-reactive.codestyle-conventions' - id 'pulsar-client-reactive.library-conventions' - id 'pulsar-client-reactive.test-conventions' + id("pulsar-client-reactive.codestyle-conventions") + id("pulsar-client-reactive.library-conventions") + id("pulsar-client-reactive.test-conventions") } dependencies { - api project(':pulsar-client-reactive-api') - api libs.jackson.databind - api libs.jackson.datatype.jsr310 + api(project(":pulsar-client-reactive-api")) + api(libs.jackson.databind) + api(libs.jackson.datatype.jsr310) - testImplementation libs.pulsar.client.shaded - testImplementation libs.junit.jupiter - testImplementation libs.assertj.core + testImplementation(libs.pulsar.client.shaded) + testImplementation(libs.junit.jupiter) + testImplementation(libs.assertj.core) } description = "Jackson module for the reactive client configuration" diff --git a/pulsar-client-reactive-producer-cache-caffeine-shaded/build.gradle b/pulsar-client-reactive-producer-cache-caffeine-shaded/build.gradle deleted file mode 100644 index 20e32a8b..00000000 --- a/pulsar-client-reactive-producer-cache-caffeine-shaded/build.gradle +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -plugins { - id 'pulsar-client-reactive.codestyle-conventions' - id 'pulsar-client-reactive.library-conventions' - id 'com.github.johnrengelman.shadow' version '7.1.2' -} - -dependencies { - api project(':pulsar-client-reactive-adapter') - implementation libs.caffeine - shadow project(':pulsar-client-reactive-adapter') - testImplementation libs.junit.jupiter - testImplementation libs.assertj.core - testImplementation libs.reactor.test - testImplementation libs.mockito.core -} - -description = "Caffeine (shaded) implementation of producer cache" - -jar { - archiveClassifier.set('original') -} - -shadowJar { - archiveClassifier.set(null) - dependsOn(project.tasks.jar) - manifest { - inheritFrom project.tasks.jar.manifest - } - relocate 'com.github.benmanes.caffeine', 'org.apache.pulsar.reactive.shade.com.github.benmanes.caffeine' - relocate 'com.google', 'org.apache.pulsar.reactive.shade.com.google' - relocate 'org.checkerframework', 'org.apache.pulsar.reactive.shade.org.checkerframework' - dependencies { - exclude(dependency { - !['com.github.ben-manes.caffeine', 'org.checkerframework', 'com.google.errorprone'].contains(it.moduleGroup) - }) - } -} - -tasks.build.dependsOn tasks.shadowJar - -// disable module metadata - otherwise original jar will be used when published -tasks.withType(GenerateModuleMetadata) { - enabled = false -} - -// delay the maven publishing - instead add shadowJar to the publication -components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) { - skip() -} - -publishing { - publications { - mavenJava { - artifact(shadowJar) - pom.withXml { - Node pomNode = asNode() - pomNode.dependencies.'*'.findAll() { - it.artifactId.text() == 'caffeine' - }.each() { - it.parent().remove(it) - } - } - } - } -} diff --git a/pulsar-client-reactive-producer-cache-caffeine-shaded/build.gradle.kts b/pulsar-client-reactive-producer-cache-caffeine-shaded/build.gradle.kts new file mode 100644 index 00000000..bad7ea0a --- /dev/null +++ b/pulsar-client-reactive-producer-cache-caffeine-shaded/build.gradle.kts @@ -0,0 +1,86 @@ +/* + * 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 + * + * https://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. + */ + +import groovy.util.Node +import groovy.util.NodeList +import org.gradle.api.artifacts.ResolvedDependency +import org.gradle.api.specs.Spec + +plugins { + id("pulsar-client-reactive.codestyle-conventions") + id("pulsar-client-reactive.library-conventions") + alias(libs.plugins.shadow) +} + +dependencies { + api(project(":pulsar-client-reactive-adapter")) + implementation(libs.caffeine) + shadow(project(":pulsar-client-reactive-adapter")) + + testImplementation(libs.junit.jupiter) + testImplementation(libs.assertj.core) + testImplementation(libs.reactor.test) + testImplementation(libs.mockito.core) +} + +description = "Caffeine (shaded) implementation of producer cache" + +// The shadowed jar is published as the main artifact, so the java component must not also +// expose a separate shadow variant. +shadow { + addShadowVariantIntoJavaComponent = false +} + +tasks.jar { + archiveClassifier = "original" +} + +val relocatedGroups = setOf("com.github.ben-manes.caffeine", "org.checkerframework", "com.google.errorprone") + +tasks.shadowJar { + archiveClassifier = "" + relocate("com.github.benmanes.caffeine", "org.apache.pulsar.reactive.shade.com.github.benmanes.caffeine") + relocate("com.google", "org.apache.pulsar.reactive.shade.com.google") + relocate("org.checkerframework", "org.apache.pulsar.reactive.shade.org.checkerframework") + dependencies { + include(Spec { it.moduleGroup in relocatedGroups }) + } +} + +// disable module metadata - otherwise original jar will be used when published +tasks.withType().configureEach { + enabled = false +} + +publishing { + publications { + named("mavenJava") { + artifact(tasks.shadowJar) + // the relocated dependencies are bundled into the shadowed jar, so they must not + // be declared as dependencies of the published module + pom.withXml { + (asNode()["dependencies"] as NodeList).filterIsInstance().forEach { dependencies -> + dependencies.children().removeIf { + it is Node && (it["artifactId"] as NodeList).text() == "caffeine" + } + } + } + } + } +} diff --git a/pulsar-client-reactive-producer-cache-caffeine/build.gradle b/pulsar-client-reactive-producer-cache-caffeine/build.gradle.kts similarity index 73% rename from pulsar-client-reactive-producer-cache-caffeine/build.gradle rename to pulsar-client-reactive-producer-cache-caffeine/build.gradle.kts index 12f80cb5..43fb345b 100644 --- a/pulsar-client-reactive-producer-cache-caffeine/build.gradle +++ b/pulsar-client-reactive-producer-cache-caffeine/build.gradle.kts @@ -18,19 +18,18 @@ */ plugins { - id 'pulsar-client-reactive.codestyle-conventions' - id 'pulsar-client-reactive.library-conventions' + id("pulsar-client-reactive.codestyle-conventions") + id("pulsar-client-reactive.library-conventions") } dependencies { - api project(':pulsar-client-reactive-adapter') - api libs.caffeine - testImplementation libs.junit.jupiter - testImplementation libs.assertj.core - testImplementation libs.reactor.test - testImplementation libs.mockito.core + api(project(":pulsar-client-reactive-adapter")) + api(libs.caffeine) + + testImplementation(libs.junit.jupiter) + testImplementation(libs.assertj.core) + testImplementation(libs.reactor.test) + testImplementation(libs.mockito.core) } description = "Caffeine implementation of producer cache" - - diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index a9f145de..00000000 --- a/settings.gradle +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -rootProject.name = 'pulsar-client-reactive' -include 'pulsar-client-reactive-api' -include 'pulsar-client-reactive-adapter' -include 'pulsar-client-reactive-bom' -include 'pulsar-client-reactive-producer-cache-caffeine' -include 'pulsar-client-reactive-producer-cache-caffeine-shaded' -include 'pulsar-client-reactive-jackson' diff --git a/buildSrc/src/main/groovy/pulsar-client-reactive.codestyle-conventions.gradle b/settings.gradle.kts similarity index 60% rename from buildSrc/src/main/groovy/pulsar-client-reactive.codestyle-conventions.gradle rename to settings.gradle.kts index bf7a05e3..85d31528 100644 --- a/buildSrc/src/main/groovy/pulsar-client-reactive.codestyle-conventions.gradle +++ b/settings.gradle.kts @@ -17,25 +17,25 @@ * under the License. */ -plugins { - id 'checkstyle' - id "org.cadixdev.licenser" +pluginManagement { + repositories { + gradlePluginPortal() + } + includeBuild("build-logic") } -dependencies { - checkstyle libs.spring.javaformat.checkstyle +dependencyResolutionManagement { + repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS + repositories { + mavenCentral() + } } -checkstyle { - toolVersion libs.versions.checkstyle.get() - configFile project.rootProject.file('checkstyle/checkstyle.xml') -} +rootProject.name = "pulsar-client-reactive" -license { - header = rootProject.file('checkstyle/HEADER.txt') - tasks { - gradle { - files.from('build.gradle', 'settings.gradle', 'gradle.properties') - } - } -} +include("pulsar-client-reactive-api") +include("pulsar-client-reactive-adapter") +include("pulsar-client-reactive-bom") +include("pulsar-client-reactive-producer-cache-caffeine") +include("pulsar-client-reactive-producer-cache-caffeine-shaded") +include("pulsar-client-reactive-jackson")