Skip to content

Commit

Permalink
Prepare stable release (#130)
Browse files Browse the repository at this point in the history
* Remove -alpha suffix from opentelemetry-semconv artifact

* Remove deprecated ResourceAttributes, SemanticAttributes

* Update japicmp to generate diff for first release

* jApiCmp

---------

Co-authored-by: Trask Stalnaker <[email protected]>
  • Loading branch information
jack-berg and trask authored Jan 27, 2025
1 parent dc2c13d commit 09a6578
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 6,188 deletions.
23 changes: 14 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ val schemaUrlVersions = listOf(
"1.25.0",
"1.24.0")

// Compute the artifact version, which includes the "-alpha" suffix and includes "-SNAPSHOT" suffix if not releasing
// Release example: version=1.21.0-alpha
// Snapshot example: version=1.21.0-alpha-SNAPSHOT
var releaseVersion = semanticConventionsVersion + "-alpha"
if (snapshot) {
releaseVersion += "-SNAPSHOT"
}

allprojects {
version = releaseVersion
// Compute the artifact version.
// Include the "-alpha" suffix if the artifact contains a gradle.properties file with contents "otel.release=alpha".
// Include the "-SNAPSHOT" suffix if not releasing.
// Release example: 1.21.0 OR 1.21.0-alpha
// Snapshot example: 1.21.0-SNAPSHOT OR 1.21.0-alpha-SNAPSHOT
var ver = semanticConventionsVersion
val release = findProperty("otel.release")
if (release != null) {
ver += "-" + release
}
if (snapshot) {
ver += "-SNAPSHOT"
}
version = ver
}

nexusPublishing {
Expand Down
50 changes: 26 additions & 24 deletions buildSrc/src/main/kotlin/otel.japicmp-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import japicmp.model.JApiChangeStatus
import japicmp.model.JApiClass
import japicmp.model.JApiCompatibility
import japicmp.model.JApiCompatibilityChange
import japicmp.model.JApiMethod
import japicmp.model.*
import me.champeau.gradle.japicmp.JapicmpTask
import me.champeau.gradle.japicmp.report.Violation
import me.champeau.gradle.japicmp.report.stdrules.AbstractRecordingSeenMembers
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule
import me.champeau.gradle.japicmp.report.stdrules.*


plugins {
Expand All @@ -34,7 +26,7 @@ val latestReleasedVersion: String by lazy {
class SourceIncompatibleRule : AbstractRecordingSeenMembers() {
override fun maybeAddViolation(member: JApiCompatibility): Violation? {
if (!member.isSourceCompatible()) {
return Violation.error(member, "Not source compatible")
return Violation.error(member, "Not source compatible: $member")
}
return null
}
Expand All @@ -52,7 +44,7 @@ fun findArtifact(version: String): File {
val depModule = "io.opentelemetry.semconv:${base.archivesName.get()}:$version@jar"
val depJar = "${base.archivesName.get()}-$version.jar"
val configuration: Configuration = configurations.detachedConfiguration(
dependencies.create(depModule),
dependencies.create(depModule),
)
return files(configuration.files).filter {
it.name.equals(depJar)
Expand All @@ -72,7 +64,7 @@ if (!project.hasProperty("otel.release")) {
// 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>("jar").archiveFile)
?: file(getByName<Jar>("jar").archiveFile)
newClasspath.from(files(newArtifact))

// only output changes, not everything
Expand All @@ -81,20 +73,23 @@ if (!project.hasProperty("otel.release")) {
// 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()
},
)
// TODO: uncomment after first stable release
// 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
// with some changes.
val exclusions = mutableListOf<String>()
// Generics are not detected correctly
exclusions.add("CLASS_GENERIC_TEMPLATE_CHANGED")
// Allow new default methods on interfaces
exclusions.add("METHOD_NEW_DEFAULT")
// Allow adding default implementations for default methods
Expand All @@ -115,7 +110,14 @@ if (!project.hasProperty("otel.release")) {

// this is needed so that we only consider the current artifact, and not dependencies
ignoreMissingClasses.set(true)
packageExcludes.addAll("*.internal", "*.internal.*")
// TODO: remove exclusions after first stable release
classExcludes.add("io.opentelemetry.semconv.ResourceAttributes")
classExcludes.add("io.opentelemetry.semconv.SemanticAttributes")
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 check task depend on the api comparison task, to make it more likely it will get used.
named("check") {
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
`maven-publish`
signing

id("otel.japicmp-conventions")
}

publishing {
Expand Down
Loading

0 comments on commit 09a6578

Please sign in to comment.