Skip to content

WIP: work on using full classpaths with japicmp #2497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: version/7.3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions build-logic/src/main/kotlin/japicmp/accept/BinaryCompatRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package japicmp.accept
import japicmp.model.*
import me.champeau.gradle.japicmp.report.Violation

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

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

override fun maybeViolation(member: JApiCompatibility): Violation? {
if (member.isBinaryCompatible) {
Expand All @@ -26,13 +26,13 @@ class BinaryCompatRule() : AbstractAcceptingRule() {
return null
}
for (change in member.compatibilityChanges) {
if (IGNORED_CHANGE_TYPES.contains(change)) {
if (IGNORED_CHANGE_TYPES.contains(change.type)) {
return null
}
}
return checkAcceptance(
member,
member.compatibilityChanges.map { it.name },
member.compatibilityChanges.map { it.type.name },
Violation.notBinaryCompatible(member),
)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sponge-vanillagradle = { module = "org.spongepowered:vanillagradle", version.ref

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

Expand Down
73 changes: 58 additions & 15 deletions verification/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import japicmp.accept.AcceptingSetupRule
import japicmp.accept.BinaryCompatRule
import me.champeau.gradle.japicmp.JapicmpTask
import org.gradle.internal.resolve.ModuleVersionNotFoundException
import java.net.URI
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.util.*
Expand Down Expand Up @@ -51,19 +52,44 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "neoforge", "s
dependsOn(resetChangeFileTask)
}

val conf = configurations.create("${projectFragment}OldJar") {
isCanBeResolved = true
val baseConf = configurations.dependencyScope("${projectFragment}OldJar") {
}
val projPublication = proj.the<PublishingExtension>().publications.getByName<MavenPublication>("maven")
conf.dependencies.add(
dependencies.create("${projPublication.groupId}:${projPublication.artifactId}:$baseVersion").apply {
(this as? ModuleDependency)?.isTransitive = false
val apiConf = configurations.resolvable("${projectFragment}OldJarApi") {
extendsFrom(baseConf.get())
attributes {
attribute(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment.STANDARD_JVM)
)
attribute(
Usage.USAGE_ATTRIBUTE,
objects.named(Usage.JAVA_API)
)
}
}
val runtimeConf = configurations.resolvable("${projectFragment}OldJarRuntime") {
extendsFrom(baseConf.get())
attributes {
attribute(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment.STANDARD_JVM)
)
attribute(
Usage.USAGE_ATTRIBUTE,
objects.named(Usage.JAVA_RUNTIME)
)
}
)
}
val projPublication = proj.the<PublishingExtension>().publications.getByName<MavenPublication>("maven")
baseConf.configure {
dependencies.add(
project.dependencies.create("${projPublication.groupId}:${projPublication.artifactId}:$baseVersion")
)
}
val resolvedOldJar = files({
try {
conf.resolvedConfiguration.rethrowFailure()
conf
apiConf.get().resolvedConfiguration.rethrowFailure()
apiConf
} catch (e: ResolveException) {
if (e.cause is ModuleVersionNotFoundException) {
logger.warn("Skipping check for $projectFragment API compatibility because there is no jar to compare against")
Expand Down Expand Up @@ -92,18 +118,31 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "neoforge", "s
!resolvedOldJar.isEmpty
}

oldClasspath.from(resolvedOldJar)
newClasspath.from(proj.tasks.named("jar"))
oldClasspath.from(apiConf, runtimeConf)
newClasspath.from(
proj.configurations.named("compileClasspath").get().incoming.artifactView {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
}
}.files,
proj.tasks.named(
when (projectFragment) {
"fabric" -> "remapJar"
else -> "jar"
}
)
)
onlyModified.set(false)
failOnModification.set(false) // report does the failing (so we can accept)
ignoreMissingClasses.set(true)

// Internals are not API
packageExcludes.add("com.sk89q.worldedit*.internal*")
// Mixins are not API
packageExcludes.add("com.sk89q.worldedit*.mixin*")
// Experimental is not API
packageExcludes.add("com.sk89q.worldedit*.experimental*")

maxWorkerHeap = "2G"
}

checkApiCompatibility {
Expand All @@ -116,11 +155,15 @@ tasks.named<JapicmpTask>("checkCoreApiCompatibility") {
// Commands are not API
packageExcludes.add("com.sk89q.worldedit.command*")
}

dependencies {
"bukkitOldJar"("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
}
tasks.named<JapicmpTask>("checkBukkitApiCompatibility") {
// Internal Adapters are not API
packageExcludes.add("com.sk89q.worldedit.bukkit.adapter*")
}
tasks.named<JapicmpTask>("checkFabricApiCompatibility") {
// Need to check against the reobf JAR
newClasspath.setFrom(project(":worldedit-fabric").tasks.named("remapJar"))
tasks.named<JapicmpTask>("checkSpongeApiCompatibility") {
// POM is broken
ignoreMissingClasses.set(true)
}
Loading