11import japicmp.accept.AcceptingSetupRule
22import japicmp.accept.BinaryCompatRule
33import me.champeau.gradle.japicmp.JapicmpTask
4- import org.gradle.internal.resolve.ModuleVersionNotFoundException
4+ import java.net.URI
55import java.nio.charset.StandardCharsets
66import java.nio.file.Files
77import java.util.*
@@ -14,7 +14,41 @@ plugins {
1414repositories {
1515 maven {
1616 name = " EngineHub Repository (Releases Only)"
17- url = uri(" https://maven.enginehub.org/artifactory/libs-release-local/" )
17+ url = URI .create(" https://maven.enginehub.org/artifactory/libs-release-local/" )
18+ mavenContent {
19+ releasesOnly()
20+ }
21+ }
22+ maven {
23+ name = " EngineHub Repository (External Releases Only)"
24+ url = URI .create(" https://maven.enginehub.org/artifactory/ext-release-local/" )
25+ mavenContent {
26+ releasesOnly()
27+ includeGroupAndSubgroups(" com.sk89q.lib" )
28+ }
29+ }
30+ maven {
31+ name = " EngineHub Repository (Snapshots Only)"
32+ url = URI .create(" https://maven.enginehub.org/artifactory/libs-snapshot-local/" )
33+ mavenContent {
34+ snapshotsOnly()
35+ includeGroupAndSubgroups(" org.enginehub.lin-bus" )
36+ }
37+ }
38+ maven {
39+ name = " EngineHub Repository (PaperMC Proxy)"
40+ url = URI .create(" https://maven.enginehub.org/artifactory/papermc-proxy-cache/" )
41+ mavenContent {
42+ includeGroupAndSubgroups(" io.papermc" )
43+ includeGroupAndSubgroups(" net.md-5" )
44+ }
45+ }
46+ maven {
47+ name = " Fabric"
48+ url = uri(" https://maven.fabricmc.net/" )
49+ content {
50+ includeGroupAndSubgroups(" net.fabricmc" )
51+ }
1852 }
1953 maven {
2054 name = " EngineHub Repository (Snapshots Only)"
@@ -44,7 +78,8 @@ tasks.check {
4478// Pull the version before our current version.
4579val baseVersion = " (,${rootProject.version.toString().substringBefore(" -SNAPSHOT" )} ["
4680for (projectFragment in listOf (" bukkit" , " cli" , " core" , " fabric" , " forge" , " sponge" )) {
47- val capitalizedFragment = projectFragment.capitalize(Locale .ROOT )
81+ val capitalizedFragment =
82+ projectFragment.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale .ROOT ) else it.toString() }
4883 val proj = project(" :worldedit-$projectFragment " )
4984 evaluationDependsOn(proj.path)
5085
@@ -64,15 +99,46 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "spon
6499 dependsOn(resetChangeFileTask)
65100 }
66101
67- val conf = configurations.create(" ${projectFragment} OldJar" ) {
68- isCanBeResolved = true
102+ val baseConf = configurations.dependencyScope(" ${projectFragment} OldJar" ) {
69103 }
70- val projPublication = proj.the<PublishingExtension >().publications.getByName<MavenPublication >(" maven" )
71- conf.dependencies.add(
72- dependencies.create(" ${projPublication.groupId} :${projPublication.artifactId} :$baseVersion " ).apply {
73- (this as ? ModuleDependency )?.isTransitive = false
104+ val apiConf = configurations.resolvable(" ${projectFragment} OldJarApi" ) {
105+ extendsFrom(baseConf.get())
106+ attributes {
107+ attribute(
108+ TargetJvmEnvironment .TARGET_JVM_ENVIRONMENT_ATTRIBUTE ,
109+ objects.named(TargetJvmEnvironment .STANDARD_JVM )
110+ )
111+ attribute(
112+ Usage .USAGE_ATTRIBUTE ,
113+ objects.named(Usage .JAVA_API )
114+ )
74115 }
75- )
116+ }
117+ val runtimeConf = configurations.resolvable(" ${projectFragment} OldJarRuntime" ) {
118+ extendsFrom(baseConf.get())
119+ attributes {
120+ attribute(
121+ TargetJvmEnvironment .TARGET_JVM_ENVIRONMENT_ATTRIBUTE ,
122+ objects.named(TargetJvmEnvironment .STANDARD_JVM )
123+ )
124+ attribute(
125+ Usage .USAGE_ATTRIBUTE ,
126+ objects.named(Usage .JAVA_RUNTIME )
127+ )
128+ }
129+ }
130+ val projPublication = proj.the<PublishingExtension >().publications.getByName<MavenPublication >(" maven" )
131+ baseConf.configure {
132+ dependencies.add(
133+ project.dependencies.create(" ${projPublication.groupId} :${projPublication.artifactId} :$baseVersion " )
134+ )
135+ // Temporarily necessary until Mojang updates their Guava
136+ dependencyConstraints.add(
137+ project.dependencies.constraints.create(" com.google.guava:guava:${Versions .GUAVA } !!" ).apply {
138+ because(" Mojang provides Guava" )
139+ }
140+ )
141+ }
76142 val checkApi = tasks.register<JapicmpTask >(" check${capitalizedFragment} ApiCompatibility" ) {
77143 group = " API Compatibility"
78144 description = " Check API compatibility for $capitalizedFragment API"
@@ -86,26 +152,23 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "spon
86152 reportName.set(" api-compatibility-$projectFragment .html" )
87153 }
88154
89- onlyIf {
90- // Only check if we have a jar to compare against
91- try {
92- conf.resolvedConfiguration.rethrowFailure()
93- true
94- } catch (e: ResolveException ) {
95- if (e.cause is ModuleVersionNotFoundException ) {
96- it.logger.warn(" Skipping check for $projectFragment API compatibility because there is no jar to compare against" )
97- false
98- } else {
99- throw e
155+ oldClasspath.from(apiConf, runtimeConf)
156+ newClasspath.from(
157+ proj.configurations.named(" compileClasspath" ).get().incoming.artifactView {
158+ attributes {
159+ attribute(LibraryElements .LIBRARY_ELEMENTS_ATTRIBUTE , objects.named(LibraryElements .JAR ))
100160 }
101- }
102- }
103-
104- oldClasspath.from(conf)
105- newClasspath.from(proj.tasks.named(" jar" ))
161+ }.files,
162+ proj.tasks.named(
163+ when (projectFragment) {
164+ " fabric" -> " remapJar"
165+ " forge" -> " reobfJar"
166+ else -> " jar"
167+ }
168+ )
169+ )
106170 onlyModified.set(false )
107171 failOnModification.set(false ) // report does the failing (so we can accept)
108- ignoreMissingClasses.set(true )
109172
110173 // Internals are not API
111174 packageExcludes.add(" com.sk89q.worldedit*.internal*" )
@@ -125,15 +188,16 @@ tasks.named<JapicmpTask>("checkCoreApiCompatibility") {
125188 // Commands are not API
126189 packageExcludes.add(" com.sk89q.worldedit.command*" )
127190}
191+
192+ dependencies {
193+ " bukkitOldJar" (" io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT" )
194+ }
128195tasks.named<JapicmpTask >(" checkBukkitApiCompatibility" ) {
129196 // Internal Adapters are not API
130197 packageExcludes.add(" com.sk89q.worldedit.bukkit.adapter*" )
131198}
132- tasks.named<JapicmpTask >(" checkFabricApiCompatibility" ) {
133- // Need to check against the reobf JAR
134- newClasspath.setFrom(project(" :worldedit-fabric" ).tasks.named(" remapJar" ))
135- }
136- tasks.named<JapicmpTask >(" checkForgeApiCompatibility" ) {
137- // Need to check against the reobf JAR
138- newClasspath.builtBy(project(" :worldedit-forge" ).tasks.named(" reobfJar" ))
199+
200+ tasks.named<JapicmpTask >(" checkSpongeApiCompatibility" ) {
201+ // POM is broken
202+ ignoreMissingClasses.set(true )
139203}
0 commit comments