From d9f137582654294f6f89668217291714497b103b Mon Sep 17 00:00:00 2001 From: liach <7806504+liach@users.noreply.github.com> Date: Tue, 23 Feb 2021 09:40:14 -0600 Subject: [PATCH] Make named jar use jetbrain annotations (#2094) * Make named jar use jetbrain annotations and subsequent javadoc tweaks Signed-off-by: liach * Thanks modmuss Signed-off-by: liach Co-authored-by: liach --- build.gradle | 27 ++++++++++++++++++++------- gradle.properties | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 030bbc09e4..9295f9c754 100644 --- a/build.gradle +++ b/build.gradle @@ -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 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 { diff --git a/gradle.properties b/gradle.properties index 8e7ec7a820..654a6438a7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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