Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 9 additions & 7 deletions buildSrc/settings.gradle → build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
* under the License.
*/

dependencyResolutionManagement {
versionCatalogs {
libs {
from(files("../gradle/libs.versions.toml"))
}
}
}
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.spotless.gradle.plugin)
implementation(libs.spring.javaformat.gradle.plugin)
implementation(libs.testlogger.gradle.plugin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
@@ -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<VersionCatalogsExtension>().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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,51 @@
*/

plugins {
id 'java-library'
id 'pulsar-client-reactive.publish-conventions'
`java-library`
Comment thread
onobc marked this conversation as resolved.
id("pulsar-client-reactive.publish-conventions")
}

repositories {
mavenCentral()
}
val libs = extensions.getByType<VersionCatalogsExtension>().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<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}

tasks.named<JavaCompile>(JavaPlugin.COMPILE_JAVA_TASK_NAME) {
options.release = 8
}

tasks.withType<Javadoc>().configureEach {
options.encoding = "UTF-8"
}

dependencies {
testRuntimeOnly libs.junit.platform.launcher
testRuntimeOnly(libs.findLibrary("junit-platform-launcher").get())
}

tasks.withType(Test) {
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
named<MavenPublication>("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()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String>().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<MavenPublication>("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"])
}
Original file line number Diff line number Diff line change
@@ -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<VersionCatalogsExtension>().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<Test>("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<Test>().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")
}
Loading
Loading