Skip to content
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

WIP: work on using full classpaths with japicmp #2497

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
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Versions {
const val JUNIT = "5.8.1"
const val MOCKITO = "4.3.1"
const val FAST_UTIL = "8.5.9"
const val GUAVA = "31.1-jre"
const val GUAVA = "32.1.3-jre"
const val GSON = "2.10"
const val LOG4J = "2.19.0"
const val LIN_BUS = "0.1.0-SNAPSHOT"
Expand Down
132 changes: 98 additions & 34 deletions verification/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,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 All @@ -14,7 +14,41 @@ plugins {
repositories {
maven {
name = "EngineHub Repository (Releases Only)"
url = uri("https://maven.enginehub.org/artifactory/libs-release-local/")
url = URI.create("https://maven.enginehub.org/artifactory/libs-release-local/")
mavenContent {
releasesOnly()
}
}
maven {
name = "EngineHub Repository (External Releases Only)"
url = URI.create("https://maven.enginehub.org/artifactory/ext-release-local/")
mavenContent {
releasesOnly()
includeGroupAndSubgroups("com.sk89q.lib")
}
}
maven {
name = "EngineHub Repository (Snapshots Only)"
url = URI.create("https://maven.enginehub.org/artifactory/libs-snapshot-local/")
mavenContent {
snapshotsOnly()
includeGroupAndSubgroups("org.enginehub.lin-bus")
}
}
maven {
name = "EngineHub Repository (PaperMC Proxy)"
url = URI.create("https://maven.enginehub.org/artifactory/papermc-proxy-cache/")
mavenContent {
includeGroupAndSubgroups("io.papermc")
includeGroupAndSubgroups("net.md-5")
}
}
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
content {
includeGroupAndSubgroups("net.fabricmc")
}
}
maven {
name = "EngineHub Repository (Snapshots Only)"
Expand Down Expand Up @@ -44,7 +78,8 @@ tasks.check {
// Pull the version before our current version.
val baseVersion = "(,${rootProject.version.toString().substringBefore("-SNAPSHOT")}["
for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "sponge")) {
val capitalizedFragment = projectFragment.capitalize(Locale.ROOT)
val capitalizedFragment =
projectFragment.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.ROOT) else it.toString() }
val proj = project(":worldedit-$projectFragment")
evaluationDependsOn(proj.path)

Expand All @@ -64,15 +99,46 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "spon
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")
)
// Temporarily necessary until Mojang updates their Guava
dependencyConstraints.add(
project.dependencies.constraints.create("com.google.guava:guava:${Versions.GUAVA}!!").apply {
because("Mojang provides Guava")
}
)
}
val checkApi = tasks.register<JapicmpTask>("check${capitalizedFragment}ApiCompatibility") {
group = "API Compatibility"
description = "Check API compatibility for $capitalizedFragment API"
Expand All @@ -86,26 +152,23 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "spon
reportName.set("api-compatibility-$projectFragment.html")
}

onlyIf {
// Only check if we have a jar to compare against
try {
conf.resolvedConfiguration.rethrowFailure()
true
} catch (e: ResolveException) {
if (e.cause is ModuleVersionNotFoundException) {
it.logger.warn("Skipping check for $projectFragment API compatibility because there is no jar to compare against")
false
} else {
throw e
oldClasspath.from(apiConf, runtimeConf)
newClasspath.from(
proj.configurations.named("compileClasspath").get().incoming.artifactView {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
}
}
}

oldClasspath.from(conf)
newClasspath.from(proj.tasks.named("jar"))
}.files,
proj.tasks.named(
when (projectFragment) {
"fabric" -> "remapJar"
"forge" -> "reobfJar"
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*")
Expand All @@ -125,15 +188,16 @@ 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>("checkForgeApiCompatibility") {
// Need to check against the reobf JAR
newClasspath.builtBy(project(":worldedit-forge").tasks.named("reobfJar"))

tasks.named<JapicmpTask>("checkSpongeApiCompatibility") {
// POM is broken
ignoreMissingClasses.set(true)
}
Loading