Skip to content

Commit d2b7dbc

Browse files
Copilottrask
andauthored
Apply otel.japicmp-conventions centrally in otel.publish-conventions (#14869)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: trask <[email protected]>
1 parent 57d3e2e commit d2b7dbc

File tree

10 files changed

+50
-53
lines changed

10 files changed

+50
-53
lines changed

conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,57 +51,60 @@ fun findArtifact(version: String): File {
5151
// generate the api diff report for any module that is stable
5252
if (project.findProperty("otel.stable") == "true") {
5353
afterEvaluate {
54-
tasks {
55-
val jApiCmp by registering(JapicmpTask::class) {
56-
dependsOn("jar")
54+
// Only apply japicmp to projects that have a jar task (i.e. not BOMs or platforms)
55+
tasks.findByName("jar")?.let {
56+
tasks {
57+
val jApiCmp by registering(JapicmpTask::class) {
58+
dependsOn("jar")
5759

58-
// the japicmp "new" version is either the user-specified one, or the locally built jar.
59-
val apiNewVersion: String? by project
60-
val newArtifact = apiNewVersion?.let { findArtifact(it) }
61-
?: file(getByName<Jar>("jar").archiveFile)
62-
newClasspath.from(files(newArtifact))
60+
// the japicmp "new" version is either the user-specified one, or the locally built jar.
61+
val apiNewVersion: String? by project
62+
val newArtifact = apiNewVersion?.let { findArtifact(it) }
63+
?: file(getByName<Jar>("jar").archiveFile)
64+
newClasspath.from(files(newArtifact))
6365

64-
// only output changes, not everything
65-
onlyModified.set(true)
66+
// only output changes, not everything
67+
onlyModified.set(true)
6668

67-
// the japicmp "old" version is either the user-specified one, or the latest release.
68-
val apiBaseVersion: String? by project
69-
val baselineVersion = apiBaseVersion ?: latestReleasedVersion
70-
oldClasspath.from(
71-
try {
72-
files(findArtifact(baselineVersion))
73-
} catch (e: Exception) {
74-
// if we can't find the baseline artifact, this is probably one that's never been published before,
75-
// so publish the whole API. We do that by flipping this flag, and comparing the current against nothing.
76-
onlyModified.set(false)
77-
files()
69+
// the japicmp "old" version is either the user-specified one, or the latest release.
70+
val apiBaseVersion: String? by project
71+
val baselineVersion = apiBaseVersion ?: latestReleasedVersion
72+
oldClasspath.from(
73+
try {
74+
files(findArtifact(baselineVersion))
75+
} catch (e: Exception) {
76+
// if we can't find the baseline artifact, this is probably one that's never been published before,
77+
// so publish the whole API. We do that by flipping this flag, and comparing the current against nothing.
78+
onlyModified.set(false)
79+
files()
80+
}
81+
)
82+
83+
// Reproduce defaults from https://github.com/melix/japicmp-gradle-plugin/blob/09f52739ef1fccda6b4310cf3f4b19dc97377024/src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java#L130
84+
// only changing the BinaryIncompatibleRule to our custom one that allows new default methods
85+
// on interfaces, and adding default implementations to interface methods previously
86+
// abstract.
87+
richReport {
88+
addSetupRule(RecordSeenMembersSetup::class.java)
89+
addRule(JApiChangeStatus.NEW, SourceCompatibleRule::class.java)
90+
addRule(JApiChangeStatus.MODIFIED, SourceCompatibleRule::class.java)
91+
addRule(JApiChangeStatus.UNCHANGED, UnchangedMemberRule::class.java)
92+
addRule(SourceCompatibleRule::class.java)
7893
}
79-
)
8094

81-
// Reproduce defaults from https://github.com/melix/japicmp-gradle-plugin/blob/09f52739ef1fccda6b4310cf3f4b19dc97377024/src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java#L130
82-
// only changing the BinaryIncompatibleRule to our custom one that allows new default methods
83-
// on interfaces, and adding default implementations to interface methods previously
84-
// abstract.
85-
richReport {
86-
addSetupRule(RecordSeenMembersSetup::class.java)
87-
addRule(JApiChangeStatus.NEW, SourceCompatibleRule::class.java)
88-
addRule(JApiChangeStatus.MODIFIED, SourceCompatibleRule::class.java)
89-
addRule(JApiChangeStatus.UNCHANGED, UnchangedMemberRule::class.java)
90-
addRule(SourceCompatibleRule::class.java)
95+
// this is needed so that we only consider the current artifact, and not dependencies
96+
ignoreMissingClasses.set(true)
97+
packageExcludes.addAll("*.internal", "*.internal.*")
98+
val baseVersionString = if (apiBaseVersion == null) "latest" else baselineVersion
99+
txtOutputFile.set(
100+
apiNewVersion?.let { file("$rootDir/docs/apidiffs/${apiNewVersion}_vs_$baselineVersion/${base.archivesName.get()}.txt") }
101+
?: file("$rootDir/docs/apidiffs/current_vs_$baseVersionString/${base.archivesName.get()}.txt")
102+
)
103+
}
104+
// have the jApiCmp task run every time the jar task is run, to make it more likely it will get used.
105+
named("jar") {
106+
finalizedBy(jApiCmp)
91107
}
92-
93-
// this is needed so that we only consider the current artifact, and not dependencies
94-
ignoreMissingClasses.set(true)
95-
packageExcludes.addAll("*.internal", "*.internal.*")
96-
val baseVersionString = if (apiBaseVersion == null) "latest" else baselineVersion
97-
txtOutputFile.set(
98-
apiNewVersion?.let { file("$rootDir/docs/apidiffs/${apiNewVersion}_vs_$baselineVersion/${base.archivesName.get()}.txt") }
99-
?: file("$rootDir/docs/apidiffs/current_vs_$baseVersionString/${base.archivesName.get()}.txt")
100-
)
101-
}
102-
// have the jApiCmp task run every time the jar task is run, to make it more likely it will get used.
103-
named("jar") {
104-
finalizedBy(jApiCmp)
105108
}
106109
}
107110
}

conventions/src/main/kotlin/otel.publish-conventions.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
`maven-publish`
33
signing
4+
5+
id("otel.japicmp-conventions")
46
}
57

68
publishing {

instrumentation-annotations-support/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
plugins {
22
id("otel.java-conventions")
33
id("otel.jacoco-conventions")
4-
id("otel.japicmp-conventions")
54
id("otel.publish-conventions")
65
}
76

instrumentation-annotations/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id("otel.java-conventions")
3-
id("otel.japicmp-conventions")
43
id("otel.publish-conventions")
54

65
id("otel.animalsniffer-conventions")

instrumentation-api-incubator/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
id("otel.java-conventions")
55
id("otel.animalsniffer-conventions")
66
id("otel.jacoco-conventions")
7-
id("otel.japicmp-conventions")
87
id("otel.publish-conventions")
98
id("otel.nullaway-conventions")
109
}

instrumentation-api/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
id("otel.java-conventions")
55
id("otel.animalsniffer-conventions")
66
id("otel.jacoco-conventions")
7-
id("otel.japicmp-conventions")
87
id("otel.publish-conventions")
98
id("otel.jmh-conventions")
109
id("otel.nullaway-conventions")

instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id("otel.library-instrumentation")
3-
id("otel.japicmp-conventions")
43
}
54

65
base.archivesName.set("opentelemetry-spring-boot-autoconfigure")

instrumentation/spring/starters/spring-boot-starter/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
plugins {
22
id("otel.java-conventions")
33
id("otel.publish-conventions")
4-
id("otel.japicmp-conventions")
54
}
65

76
group = "io.opentelemetry.instrumentation"

javaagent-extension-api/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id("otel.java-conventions")
3-
id("otel.japicmp-conventions")
43
id("otel.publish-conventions")
54
}
65

muzzle/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id("otel.java-conventions")
3-
id("otel.japicmp-conventions")
43
id("otel.publish-conventions")
54
}
65

0 commit comments

Comments
 (0)