diff --git a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts index 2deb9af3415b..ce300386521e 100644 --- a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts @@ -51,57 +51,60 @@ fun findArtifact(version: String): File { // generate the api diff report for any module that is stable if (project.findProperty("otel.stable") == "true") { afterEvaluate { - tasks { - val jApiCmp by registering(JapicmpTask::class) { - dependsOn("jar") + // Only apply japicmp to projects that have a jar task (i.e. not BOMs or platforms) + tasks.findByName("jar")?.let { + tasks { + val jApiCmp by registering(JapicmpTask::class) { + dependsOn("jar") - // the japicmp "new" version is either the user-specified one, or the locally built jar. - val apiNewVersion: String? by project - val newArtifact = apiNewVersion?.let { findArtifact(it) } - ?: file(getByName("jar").archiveFile) - newClasspath.from(files(newArtifact)) + // the japicmp "new" version is either the user-specified one, or the locally built jar. + val apiNewVersion: String? by project + val newArtifact = apiNewVersion?.let { findArtifact(it) } + ?: file(getByName("jar").archiveFile) + newClasspath.from(files(newArtifact)) - // only output changes, not everything - onlyModified.set(true) + // only output changes, not everything + onlyModified.set(true) - // the japicmp "old" version is either the user-specified one, or the latest release. - val apiBaseVersion: String? by project - val baselineVersion = apiBaseVersion ?: latestReleasedVersion - oldClasspath.from( - try { - files(findArtifact(baselineVersion)) - } catch (e: Exception) { - // if we can't find the baseline artifact, this is probably one that's never been published before, - // so publish the whole API. We do that by flipping this flag, and comparing the current against nothing. - onlyModified.set(false) - files() + // the japicmp "old" version is either the user-specified one, or the latest release. + val apiBaseVersion: String? by project + val baselineVersion = apiBaseVersion ?: latestReleasedVersion + oldClasspath.from( + try { + files(findArtifact(baselineVersion)) + } catch (e: Exception) { + // if we can't find the baseline artifact, this is probably one that's never been published before, + // so publish the whole API. We do that by flipping this flag, and comparing the current against nothing. + onlyModified.set(false) + files() + } + ) + + // Reproduce defaults from https://github.com/melix/japicmp-gradle-plugin/blob/09f52739ef1fccda6b4310cf3f4b19dc97377024/src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java#L130 + // only changing the BinaryIncompatibleRule to our custom one that allows new default methods + // on interfaces, and adding default implementations to interface methods previously + // abstract. + richReport { + addSetupRule(RecordSeenMembersSetup::class.java) + addRule(JApiChangeStatus.NEW, SourceCompatibleRule::class.java) + addRule(JApiChangeStatus.MODIFIED, SourceCompatibleRule::class.java) + addRule(JApiChangeStatus.UNCHANGED, UnchangedMemberRule::class.java) + addRule(SourceCompatibleRule::class.java) } - ) - // Reproduce defaults from https://github.com/melix/japicmp-gradle-plugin/blob/09f52739ef1fccda6b4310cf3f4b19dc97377024/src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java#L130 - // only changing the BinaryIncompatibleRule to our custom one that allows new default methods - // on interfaces, and adding default implementations to interface methods previously - // abstract. - richReport { - addSetupRule(RecordSeenMembersSetup::class.java) - addRule(JApiChangeStatus.NEW, SourceCompatibleRule::class.java) - addRule(JApiChangeStatus.MODIFIED, SourceCompatibleRule::class.java) - addRule(JApiChangeStatus.UNCHANGED, UnchangedMemberRule::class.java) - addRule(SourceCompatibleRule::class.java) + // this is needed so that we only consider the current artifact, and not dependencies + ignoreMissingClasses.set(true) + packageExcludes.addAll("*.internal", "*.internal.*") + val baseVersionString = if (apiBaseVersion == null) "latest" else baselineVersion + txtOutputFile.set( + apiNewVersion?.let { file("$rootDir/docs/apidiffs/${apiNewVersion}_vs_$baselineVersion/${base.archivesName.get()}.txt") } + ?: file("$rootDir/docs/apidiffs/current_vs_$baseVersionString/${base.archivesName.get()}.txt") + ) + } + // have the jApiCmp task run every time the jar task is run, to make it more likely it will get used. + named("jar") { + finalizedBy(jApiCmp) } - - // this is needed so that we only consider the current artifact, and not dependencies - ignoreMissingClasses.set(true) - packageExcludes.addAll("*.internal", "*.internal.*") - val baseVersionString = if (apiBaseVersion == null) "latest" else baselineVersion - txtOutputFile.set( - apiNewVersion?.let { file("$rootDir/docs/apidiffs/${apiNewVersion}_vs_$baselineVersion/${base.archivesName.get()}.txt") } - ?: file("$rootDir/docs/apidiffs/current_vs_$baseVersionString/${base.archivesName.get()}.txt") - ) - } - // have the jApiCmp task run every time the jar task is run, to make it more likely it will get used. - named("jar") { - finalizedBy(jApiCmp) } } } diff --git a/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts b/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts index d96fde36afb5..73011c444d55 100644 --- a/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts @@ -1,6 +1,8 @@ plugins { `maven-publish` signing + + id("otel.japicmp-conventions") } publishing { diff --git a/instrumentation-annotations-support/build.gradle.kts b/instrumentation-annotations-support/build.gradle.kts index 89851aa23a05..37e69efd6e21 100644 --- a/instrumentation-annotations-support/build.gradle.kts +++ b/instrumentation-annotations-support/build.gradle.kts @@ -1,7 +1,6 @@ plugins { id("otel.java-conventions") id("otel.jacoco-conventions") - id("otel.japicmp-conventions") id("otel.publish-conventions") } diff --git a/instrumentation-annotations/build.gradle.kts b/instrumentation-annotations/build.gradle.kts index 7a0e2dac5de6..07ed26a0ca20 100644 --- a/instrumentation-annotations/build.gradle.kts +++ b/instrumentation-annotations/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("otel.java-conventions") - id("otel.japicmp-conventions") id("otel.publish-conventions") id("otel.animalsniffer-conventions") diff --git a/instrumentation-api-incubator/build.gradle.kts b/instrumentation-api-incubator/build.gradle.kts index 7731d16c76b1..59cdf1bdda89 100644 --- a/instrumentation-api-incubator/build.gradle.kts +++ b/instrumentation-api-incubator/build.gradle.kts @@ -4,7 +4,6 @@ plugins { id("otel.java-conventions") id("otel.animalsniffer-conventions") id("otel.jacoco-conventions") - id("otel.japicmp-conventions") id("otel.publish-conventions") id("otel.nullaway-conventions") } diff --git a/instrumentation-api/build.gradle.kts b/instrumentation-api/build.gradle.kts index 0d43409de6bf..faef1a4df263 100644 --- a/instrumentation-api/build.gradle.kts +++ b/instrumentation-api/build.gradle.kts @@ -4,7 +4,6 @@ plugins { id("otel.java-conventions") id("otel.animalsniffer-conventions") id("otel.jacoco-conventions") - id("otel.japicmp-conventions") id("otel.publish-conventions") id("otel.jmh-conventions") id("otel.nullaway-conventions") diff --git a/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts b/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts index 513b8d89488b..c3010d5e8aff 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts +++ b/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("otel.library-instrumentation") - id("otel.japicmp-conventions") } base.archivesName.set("opentelemetry-spring-boot-autoconfigure") diff --git a/instrumentation/spring/starters/spring-boot-starter/build.gradle.kts b/instrumentation/spring/starters/spring-boot-starter/build.gradle.kts index dead08199126..e81fd7ba05cb 100644 --- a/instrumentation/spring/starters/spring-boot-starter/build.gradle.kts +++ b/instrumentation/spring/starters/spring-boot-starter/build.gradle.kts @@ -1,7 +1,6 @@ plugins { id("otel.java-conventions") id("otel.publish-conventions") - id("otel.japicmp-conventions") } group = "io.opentelemetry.instrumentation" diff --git a/javaagent-extension-api/build.gradle.kts b/javaagent-extension-api/build.gradle.kts index 144a3a459bf3..d50a3ef40bd1 100644 --- a/javaagent-extension-api/build.gradle.kts +++ b/javaagent-extension-api/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("otel.java-conventions") - id("otel.japicmp-conventions") id("otel.publish-conventions") } diff --git a/muzzle/build.gradle.kts b/muzzle/build.gradle.kts index 5e8f5ff9b9f6..b4f917b43cf4 100644 --- a/muzzle/build.gradle.kts +++ b/muzzle/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("otel.java-conventions") - id("otel.japicmp-conventions") id("otel.publish-conventions") }