Skip to content

Commit fb16118

Browse files
committed
WIP: work on using full classpaths with japicmp
Update japicmp, still doesn't work Need to add in the MC dependencies where appropriate, and possibly a bunch of optional dependencies to core and bukkit
1 parent 2be1150 commit fb16118

File tree

3 files changed

+67
-24
lines changed

3 files changed

+67
-24
lines changed

build-logic/src/main/kotlin/japicmp/accept/BinaryCompatRule.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package japicmp.accept
33
import japicmp.model.*
44
import me.champeau.gradle.japicmp.report.Violation
55

6+
private val IGNORED_CHANGE_TYPES: List<JApiCompatibilityChangeType> = listOf(
7+
JApiCompatibilityChangeType.METHOD_REMOVED_IN_SUPERCLASS, // the removal of the method will be reported
8+
JApiCompatibilityChangeType.INTERFACE_REMOVED, // the removed methods will be reported
9+
JApiCompatibilityChangeType.INTERFACE_ADDED, // the added methods will be reported
10+
JApiCompatibilityChangeType.ANNOTATION_DEPRECATED_ADDED, // semver detection is broken
11+
)
612

713
class BinaryCompatRule() : AbstractAcceptingRule() {
8-
private val IGNORED_CHANGE_TYPES: List<JApiCompatibilityChange> = listOf(
9-
JApiCompatibilityChange.METHOD_REMOVED_IN_SUPERCLASS, // the removal of the method will be reported
10-
JApiCompatibilityChange.INTERFACE_REMOVED, // the removed methods will be reported
11-
JApiCompatibilityChange.INTERFACE_ADDED, // the added methods will be reported
12-
JApiCompatibilityChange.ANNOTATION_DEPRECATED_ADDED, // semver detection is broken
13-
)
1414

1515
override fun maybeViolation(member: JApiCompatibility): Violation? {
1616
if (member.isBinaryCompatible) {
@@ -26,13 +26,13 @@ class BinaryCompatRule() : AbstractAcceptingRule() {
2626
return null
2727
}
2828
for (change in member.compatibilityChanges) {
29-
if (IGNORED_CHANGE_TYPES.contains(change)) {
29+
if (IGNORED_CHANGE_TYPES.contains(change.type)) {
3030
return null
3131
}
3232
}
3333
return checkAcceptance(
3434
member,
35-
member.compatibilityChanges.map { it.name },
35+
member.compatibilityChanges.map { it.type.name },
3636
Violation.notBinaryCompatible(member),
3737
)
3838
}

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sponge-vanillagradle = { module = "org.spongepowered:vanillagradle", version.ref
4141

4242
licenser = "gradle.plugin.org.cadixdev.gradle:licenser:0.6.1"
4343
grgit = "org.ajoberstar.grgit:grgit-gradle:5.2.2"
44-
japicmp = "me.champeau.gradle:japicmp-gradle-plugin:0.4.2"
44+
japicmp = "me.champeau.gradle:japicmp-gradle-plugin:0.4.6"
4545
shadow = "com.github.johnrengelman:shadow:8.1.1"
4646
jfrog-buildinfo = "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"
4747

verification/build.gradle.kts

+58-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import japicmp.accept.AcceptingSetupRule
22
import japicmp.accept.BinaryCompatRule
33
import me.champeau.gradle.japicmp.JapicmpTask
44
import org.gradle.internal.resolve.ModuleVersionNotFoundException
5+
import java.net.URI
56
import java.nio.charset.StandardCharsets
67
import java.nio.file.Files
78
import java.util.*
@@ -51,19 +52,44 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "neoforge", "s
5152
dependsOn(resetChangeFileTask)
5253
}
5354

54-
val conf = configurations.create("${projectFragment}OldJar") {
55-
isCanBeResolved = true
55+
val baseConf = configurations.dependencyScope("${projectFragment}OldJar") {
5656
}
57-
val projPublication = proj.the<PublishingExtension>().publications.getByName<MavenPublication>("maven")
58-
conf.dependencies.add(
59-
dependencies.create("${projPublication.groupId}:${projPublication.artifactId}:$baseVersion").apply {
60-
(this as? ModuleDependency)?.isTransitive = false
57+
val apiConf = configurations.resolvable("${projectFragment}OldJarApi") {
58+
extendsFrom(baseConf.get())
59+
attributes {
60+
attribute(
61+
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
62+
objects.named(TargetJvmEnvironment.STANDARD_JVM)
63+
)
64+
attribute(
65+
Usage.USAGE_ATTRIBUTE,
66+
objects.named(Usage.JAVA_API)
67+
)
68+
}
69+
}
70+
val runtimeConf = configurations.resolvable("${projectFragment}OldJarRuntime") {
71+
extendsFrom(baseConf.get())
72+
attributes {
73+
attribute(
74+
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
75+
objects.named(TargetJvmEnvironment.STANDARD_JVM)
76+
)
77+
attribute(
78+
Usage.USAGE_ATTRIBUTE,
79+
objects.named(Usage.JAVA_RUNTIME)
80+
)
6181
}
62-
)
82+
}
83+
val projPublication = proj.the<PublishingExtension>().publications.getByName<MavenPublication>("maven")
84+
baseConf.configure {
85+
dependencies.add(
86+
project.dependencies.create("${projPublication.groupId}:${projPublication.artifactId}:$baseVersion")
87+
)
88+
}
6389
val resolvedOldJar = files({
6490
try {
65-
conf.resolvedConfiguration.rethrowFailure()
66-
conf
91+
apiConf.get().resolvedConfiguration.rethrowFailure()
92+
apiConf
6793
} catch (e: ResolveException) {
6894
if (e.cause is ModuleVersionNotFoundException) {
6995
logger.warn("Skipping check for $projectFragment API compatibility because there is no jar to compare against")
@@ -92,18 +118,31 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "neoforge", "s
92118
!resolvedOldJar.isEmpty
93119
}
94120

95-
oldClasspath.from(resolvedOldJar)
96-
newClasspath.from(proj.tasks.named("jar"))
121+
oldClasspath.from(apiConf, runtimeConf)
122+
newClasspath.from(
123+
proj.configurations.named("compileClasspath").get().incoming.artifactView {
124+
attributes {
125+
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
126+
}
127+
}.files,
128+
proj.tasks.named(
129+
when (projectFragment) {
130+
"fabric" -> "remapJar"
131+
else -> "jar"
132+
}
133+
)
134+
)
97135
onlyModified.set(false)
98136
failOnModification.set(false) // report does the failing (so we can accept)
99-
ignoreMissingClasses.set(true)
100137

101138
// Internals are not API
102139
packageExcludes.add("com.sk89q.worldedit*.internal*")
103140
// Mixins are not API
104141
packageExcludes.add("com.sk89q.worldedit*.mixin*")
105142
// Experimental is not API
106143
packageExcludes.add("com.sk89q.worldedit*.experimental*")
144+
145+
maxWorkerHeap = "2G"
107146
}
108147

109148
checkApiCompatibility {
@@ -116,11 +155,15 @@ tasks.named<JapicmpTask>("checkCoreApiCompatibility") {
116155
// Commands are not API
117156
packageExcludes.add("com.sk89q.worldedit.command*")
118157
}
158+
159+
dependencies {
160+
"bukkitOldJar"("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
161+
}
119162
tasks.named<JapicmpTask>("checkBukkitApiCompatibility") {
120163
// Internal Adapters are not API
121164
packageExcludes.add("com.sk89q.worldedit.bukkit.adapter*")
122165
}
123-
tasks.named<JapicmpTask>("checkFabricApiCompatibility") {
124-
// Need to check against the reobf JAR
125-
newClasspath.setFrom(project(":worldedit-fabric").tasks.named("remapJar"))
166+
tasks.named<JapicmpTask>("checkSpongeApiCompatibility") {
167+
// POM is broken
168+
ignoreMissingClasses.set(true)
126169
}

0 commit comments

Comments
 (0)