1
1
import japicmp.accept.AcceptingSetupRule
2
2
import japicmp.accept.BinaryCompatRule
3
3
import me.champeau.gradle.japicmp.JapicmpTask
4
- import org.gradle.internal.resolve.ModuleVersionNotFoundException
4
+ import java.net.URI
5
5
import java.nio.charset.StandardCharsets
6
6
import java.nio.file.Files
7
7
import java.util.*
@@ -14,7 +14,41 @@ plugins {
14
14
repositories {
15
15
maven {
16
16
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
+ }
18
52
}
19
53
maven {
20
54
name = " EngineHub Repository (Snapshots Only)"
@@ -44,7 +78,8 @@ tasks.check {
44
78
// Pull the version before our current version.
45
79
val baseVersion = " (,${rootProject.version.toString().substringBefore(" -SNAPSHOT" )} ["
46
80
for (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() }
48
83
val proj = project(" :worldedit-$projectFragment " )
49
84
evaluationDependsOn(proj.path)
50
85
@@ -64,15 +99,46 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "spon
64
99
dependsOn(resetChangeFileTask)
65
100
}
66
101
67
- val conf = configurations.create(" ${projectFragment} OldJar" ) {
68
- isCanBeResolved = true
102
+ val baseConf = configurations.dependencyScope(" ${projectFragment} OldJar" ) {
69
103
}
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
+ )
74
115
}
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
+ }
76
142
val checkApi = tasks.register<JapicmpTask >(" check${capitalizedFragment} ApiCompatibility" ) {
77
143
group = " API Compatibility"
78
144
description = " Check API compatibility for $capitalizedFragment API"
@@ -86,26 +152,23 @@ for (projectFragment in listOf("bukkit", "cli", "core", "fabric", "forge", "spon
86
152
reportName.set(" api-compatibility-$projectFragment .html" )
87
153
}
88
154
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 ))
100
160
}
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
+ )
106
170
onlyModified.set(false )
107
171
failOnModification.set(false ) // report does the failing (so we can accept)
108
- ignoreMissingClasses.set(true )
109
172
110
173
// Internals are not API
111
174
packageExcludes.add(" com.sk89q.worldedit*.internal*" )
@@ -125,15 +188,16 @@ tasks.named<JapicmpTask>("checkCoreApiCompatibility") {
125
188
// Commands are not API
126
189
packageExcludes.add(" com.sk89q.worldedit.command*" )
127
190
}
191
+
192
+ dependencies {
193
+ " bukkitOldJar" (" io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT" )
194
+ }
128
195
tasks.named<JapicmpTask >(" checkBukkitApiCompatibility" ) {
129
196
// Internal Adapters are not API
130
197
packageExcludes.add(" com.sk89q.worldedit.bukkit.adapter*" )
131
198
}
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 )
139
203
}
0 commit comments