diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 89dc744c..3119e294 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -18,6 +18,7 @@ gradlePlugin { dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20") implementation("org.openapitools:openapi-generator-gradle-plugin:7.4.0") "functionalTestImplementation"(project) } diff --git a/build-logic/src/main/kotlin/com/gabrielfeo/kotlin-jvm-library.gradle.kts b/build-logic/src/main/kotlin/com/gabrielfeo/kotlin-jvm-library.gradle.kts index d3e9f37e..10a28d29 100644 --- a/build-logic/src/main/kotlin/com/gabrielfeo/kotlin-jvm-library.gradle.kts +++ b/build-logic/src/main/kotlin/com/gabrielfeo/kotlin-jvm-library.gradle.kts @@ -1,6 +1,49 @@ package com.gabrielfeo +import org.jetbrains.dokka.DokkaConfiguration.Visibility.PUBLIC +import org.jetbrains.dokka.gradle.DokkaTask +import java.net.URL + plugins { id("org.jetbrains.kotlin.jvm") + id("org.jetbrains.dokka") `java-library` } + +val repoUrl: Provider = providers.gradleProperty("repo.url") + +java { + withSourcesJar() + withJavadocJar() + toolchain { + languageVersion.set(JavaLanguageVersion.of(11)) + vendor.set(JvmVendorSpec.AZUL) + } +} + +tasks.withType().configureEach { + dokkaSourceSets.all { + sourceRoot("src/main/kotlin") + sourceLink { + localDirectory.set(file("src/main/kotlin")) + remoteUrl.set(repoUrl.map { URL("$it/blob/$version/src/main/kotlin") }) + remoteLineSuffix.set("#L") + } + jdkVersion.set(11) + suppressGeneratedFiles.set(false) + documentedVisibilities.set(setOf(PUBLIC)) + perPackageOption { + matchingRegex.set(""".*\.internal.*""") + suppress.set(true) + } + externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/") + externalDocumentationLink("https://square.github.io/okhttp/4.x/okhttp/") + externalDocumentationLink("https://square.github.io/retrofit/2.x/retrofit/") + externalDocumentationLink("https://square.github.io/moshi/1.x/moshi/") + externalDocumentationLink("https://square.github.io/moshi/1.x/moshi-kotlin/") + } +} + +tasks.named("javadocJar") { + from(tasks.dokkaHtml) +} diff --git a/build-logic/src/main/kotlin/com/gabrielfeo/test-suites.gradle.kts b/build-logic/src/main/kotlin/com/gabrielfeo/test-suites.gradle.kts index 34fb8ef0..7b0c5f70 100644 --- a/build-logic/src/main/kotlin/com/gabrielfeo/test-suites.gradle.kts +++ b/build-logic/src/main/kotlin/com/gabrielfeo/test-suites.gradle.kts @@ -34,7 +34,7 @@ kotlin { } // TODO Unapply test-fixtures and delete the source set, since we're not publishing it? -components.getByName("java").apply { +components.named("java") { withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() } withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() } } diff --git a/build.gradle.kts b/build.gradle.kts index f70e0f5f..e69de29b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +0,0 @@ -plugins { - id("org.jetbrains.dokka") version "1.9.20" apply false -} diff --git a/gradle.properties b/gradle.properties index 1999e4f3..9d16b8c0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,7 @@ group=com.gabrielfeo artifact=develocity-api-kotlin version=2024.1.0 develocity.version=2024.1 +repo.url=https://github.com/gabrielfeo/develocity-api-kotlin org.gradle.jvmargs=-Xmx5g org.gradle.caching=true # Becomes default in Gradle 9.0 diff --git a/library/build.gradle.kts b/library/build.gradle.kts index ff84edbc..250e7a34 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -8,57 +8,18 @@ plugins { id("com.gabrielfeo.kotlin-jvm-library") id("com.gabrielfeo.develocity-api-code-generation") id("com.gabrielfeo.test-suites") - id("org.jetbrains.dokka") `java-library` `maven-publish` signing kotlin("jupyter.api") version "0.12.0-181" } -val repoUrl = "https://github.com/gabrielfeo/develocity-api-kotlin" - -java { - withSourcesJar() - withJavadocJar() - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - vendor.set(JvmVendorSpec.AZUL) - } -} - -tasks.withType().configureEach { - dokkaSourceSets.register("main") { - sourceRoot("src/main/kotlin") - sourceLink { - localDirectory.set(file("src/main/kotlin")) - remoteUrl.set(URL("$repoUrl/blob/$version/src/main/kotlin")) - remoteLineSuffix.set("#L") - } - jdkVersion.set(11) - suppressGeneratedFiles.set(false) - documentedVisibilities.set(setOf(PUBLIC)) - perPackageOption { - matchingRegex.set(""".*\.internal.*""") - suppress.set(true) - } - externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/") - externalDocumentationLink("https://square.github.io/okhttp/4.x/okhttp/") - externalDocumentationLink("https://square.github.io/retrofit/2.x/retrofit/") - externalDocumentationLink("https://square.github.io/moshi/1.x/moshi/") - externalDocumentationLink("https://square.github.io/moshi/1.x/moshi-kotlin/") - } -} - tasks.processJupyterApiResources { libraryProducers = listOf( "com.gabrielfeo.develocity.api.internal.jupyter.DevelocityApiJupyterIntegration", ) } -tasks.named("javadocJar") { - from(tasks.dokkaHtml) -} - tasks.named("integrationTest") { environment("DEVELOCITY_API_LOG_LEVEL", "DEBUG") } @@ -94,6 +55,7 @@ dependencies { val libraryPom = Action { name.set("Develocity API Kotlin") description.set("A library to use the Develocity API in Kotlin") + val repoUrl = providers.gradleProperty("repo.url") url.set(repoUrl) licenses { license { @@ -110,27 +72,27 @@ val libraryPom = Action { } } scm { - val basicUrl = repoUrl.substringAfter("://") - connection.set("scm:git:git://$basicUrl.git") - developerConnection.set("scm:git:ssh://$basicUrl.git") - url.set("https://$basicUrl/") + val basicUrl = repoUrl.map { it.substringAfter("://") } + connection.set(basicUrl.map { "scm:git:git://$it.git" }) + developerConnection.set(basicUrl.map { "scm:git:ssh://$it.git" }) + url.set(basicUrl.map { "https://$it/" }) } } publishing { publications { - create("develocityApiKotlin") { + register("develocityApiKotlin") { artifactId = "develocity-api-kotlin" from(components["java"]) pom(libraryPom) } // For occasional maven local publishing - create("unsignedDevelocityApiKotlin") { + register("unsignedDevelocityApiKotlin") { artifactId = "develocity-api-kotlin" from(components["java"]) pom(libraryPom) } - create("relocation") { + register("relocation") { artifactId = "gradle-enterprise-api-kotlin" pom { libraryPom(this) @@ -165,10 +127,10 @@ publishing { fun isCI() = System.getenv("CI").toBoolean() signing { - sign( - publishing.publications["develocityApiKotlin"], - publishing.publications["relocation"], - ) + val signedPublications = publishing.publications.matching { + !it.name.contains("unsigned", ignoreCase = true) + } + sign(signedPublications) if (isCI()) { useInMemoryPgpKeys( project.properties["signing.secretKey"] as String?,