Make named jar use jetbrain annotations (#2094)

* Make named jar use jetbrain annotations

and subsequent javadoc tweaks

Signed-off-by: liach <liach@users.noreply.github.com>

* Thanks modmuss

Signed-off-by: liach <liach@users.noreply.github.com>

Co-authored-by: liach <liach@users.noreply.github.com>
This commit is contained in:
liach 2021-02-23 09:40:14 -06:00 committed by GitHub
parent b4973c0b60
commit d9f1375826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -64,7 +64,7 @@ dependencies {
enigmaRuntime "cuchaz:enigma-swing:${project.enigma_version}"
enigmaRuntime "net.fabricmc:stitch:${project.stitch_version}"
javadocClasspath "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
javadocClasspath "com.google.code.findbugs:jsr305:3.0.2"
javadocClasspath "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
decompileClasspath "org.benf:cfr:0.150"
mappingPoetJar 'net.fabricmc:mappingpoet:0.2.6'
}
@ -582,10 +582,22 @@ task mapNamedJar(dependsOn: ["mergeV2", mapIntermediaryJar]) {
//Force the task to always run
outputs.upToDateWhen { false }
def jsrToJetbrains = [
"javax/annotation/Nullable": "org/jetbrains/annotations/Nullable",
"javax/annotation/Nonnull": "org/jetbrains/annotations/NotNull",
"javax/annotation/concurrent/Immutable": "org/jetbrains/annotations/Unmodifiable"
]
doLast {
logger.lifecycle(":mapping minecraft to named")
mapJar(namedJar, intermediaryJar, mergeV2.output, libraries, "intermediary", "named")
mapJar(namedJar, intermediaryJar, mergeV2.output, libraries, "intermediary", "named") {
it.withMappings { out ->
jsrToJetbrains.each { e ->
out.acceptClass e.key, e.value
}
}
}
}
}
@ -732,8 +744,7 @@ javadoc {
'https://guava.dev/releases/21.0/api/docs/',
'https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.0/',
'https://logging.apache.org/log4j/2.x/log4j-api/apidocs/',
// jsr305 need to come before jdk or the anno links are broken
'https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/',
"https://javadoc.io/doc/org.jetbrains/annotations/${project.jetbrains_annotations_version}/",
'https://javadoc.lwjgl.org/',
'http://fastutil.di.unimi.it/docs/',
'https://netty.io/4.1/api/',
@ -817,16 +828,18 @@ publishing {
}
}
void mapJar(File output, File input, File mappings, File libraries, String from, String to) {
void mapJar(File output, File input, File mappings, File libraries, String from, String to,
Action<TinyRemapper.Builder> action = { }) {
if (output.exists()) {
output.delete()
}
def remapper = TinyRemapper.newRemapper()
def remapperBuilder = TinyRemapper.newRemapper()
.withMappings(TinyUtils.createTinyMappingProvider(mappings.toPath(), from, to))
.renameInvalidLocals(true)
.rebuildSourceFilenames(true)
action.execute(remapperBuilder)
def remapper = remapperBuilder
.build()
try {

View File

@ -5,3 +5,4 @@ enigma_version=0.23.0
stitch_version=0.5.1+build.77
# Loader is only used by javadoc generation/linking
fabric_loader_version=0.11.1
jetbrains_annotations_version=20.1.0