You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Temporarily change the group name because we want to fetch an artifact with the same
79
+
// Maven coordinates as the project, which Gradle would not allow otherwise.
66
80
val existingGroup = group
81
+
group ="virtual_group"
67
82
try {
68
-
// Temporarily change the group name because we want to fetch an artifact with the same
69
-
// Maven coordinates as the project, which Gradle would not allow otherwise.
70
-
group ="virtual_group"
71
-
val depModule ="io.opentelemetry:${base.archivesName.get()}:$version@jar"
72
-
val depJar ="${base.archivesName.get()}-$version.jar"
73
-
val configuration:Configuration= configurations.detachedConfiguration(
74
-
dependencies.create(depModule),
75
-
)
76
-
return files(configuration.files).filter {
77
-
it.name.equals(depJar)
78
-
}.singleFile
83
+
return getAllPublishedModules().map {
84
+
val depModule ="io.opentelemetry:${it.base.archivesName.get()}:$version@jar"
85
+
val depJar ="${it.base.archivesName.get()}-$version.jar"
86
+
val configuration:Configuration= configurations.detachedConfiguration(
87
+
dependencies.create(depModule),
88
+
)
89
+
files(configuration.files).filter { file ->
90
+
file.name.equals(depJar)
91
+
}.singleFile
92
+
}.toList()
79
93
} finally {
80
94
group = existingGroup
81
95
}
82
96
}
83
97
98
+
fungetNewClassPath(): List<File> {
99
+
return getAllPublishedModules().map {
100
+
val archiveFile = it.tasks.getByName<Jar>("jar").archiveFile
101
+
archiveFile.get().asFile
102
+
}.toList()
103
+
}
104
+
84
105
// generate the api diff report for any module that is stable and publishes a jar.
85
106
if (!project.hasProperty("otel.release") &&!project.name.startsWith("bom")) {
86
107
afterEvaluate {
87
108
tasks {
88
109
val jApiCmp by registering(JapicmpTask::class) {
89
-
dependsOn("jar")
110
+
// Depends on jar task for all published modules. See notes below.
111
+
getAllPublishedModules().forEach {
112
+
dependsOn(it.tasks.getByName("jar"))
113
+
}
90
114
91
115
// the japicmp "new" version is either the user-specified one, or the locally built jar.
92
116
val apiNewVersion:String? by project
93
-
val newArtifact = apiNewVersion?.let { findArtifact(it) }
94
-
?: file(getByName<Jar>("jar").archiveFile)
95
-
newClasspath.from(files(newArtifact))
96
-
97
-
// only output changes, not everything
98
-
onlyModified.set(true)
99
-
100
117
// the japicmp "old" version is either the user-specified one, or the latest release.
101
118
val apiBaseVersion:String? by project
102
119
val baselineVersion = apiBaseVersion ?: latestReleasedVersion
103
-
oldClasspath.from(
104
-
try {
105
-
files(findArtifact(baselineVersion))
106
-
} catch (e:Exception) {
107
-
// if we can't find the baseline artifact, this is probably one that's never been published before,
108
-
// so publish the whole API. We do that by flipping this flag, and comparing the current against nothing.
109
-
onlyModified.set(false)
110
-
files()
111
-
},
112
-
)
120
+
121
+
// Setup new and old classpath, new and old archives.
122
+
// New and old classpaths are set to the set of all artifacts published by this project, at
123
+
// the appropriate version. Without this, japicmp is unable to resolve inheritance across module
124
+
// boundaries (i.e. Span from opentelemetry-api extends ImplicitContextKeyed from opentelemetry-context)
125
+
// and generates false positive compatibility errors when methods are lifted into superclasses,
126
+
// superinterfaces.
127
+
val archiveName = base.archivesName.get()
128
+
val newClassPath = getNewClassPath()
129
+
val oldClassPath = getOldClassPath(baselineVersion)
130
+
val pattern = (archiveName +"-([0-9\\.]*)(-SNAPSHOT)?.jar").toRegex()
131
+
val newArchive = newClassPath.singleOrNull { it.name.matches(pattern) }
132
+
val oldArchive = oldClassPath.singleOrNull { it.name.matches(pattern) }
133
+
newClasspath.from(newClassPath)
134
+
oldClasspath.from(oldClassPath)
135
+
newArchives.from(newArchive)
136
+
oldArchives.from(oldArchive)
137
+
138
+
// Only generate API diff for changes.
139
+
onlyModified.set(true)
113
140
114
141
// Reproduce defaults from https://github.com/melix/japicmp-gradle-plugin/blob/09f52739ef1fccda6b4310cf3f4b19dc97377024/src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java#L130
0 commit comments