Use jetbrains annotations by default. (#240)

Minecraft is also remapped to use them. Any use of jsr should be removed.
dev/0.11
modmuss50 2020-07-26 20:57:58 +01:00 committed by GitHub
parent bc3ff0180a
commit 9d318dd859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -74,6 +74,7 @@ public class LaunchProvider extends DependencyProvider {
addDependency("net.fabricmc:dev-launch-injector:" + Constants.DEV_LAUNCH_INJECTOR_VERSION, "runtimeOnly");
addDependency("net.minecrell:terminalconsoleappender:" + Constants.TERMINAL_CONSOLE_APPENDER_VERSION, "runtimeOnly");
addDependency("org.jetbrains:annotations:" + Constants.JETBRAINS_ANNOTATIONS_VERSION, "compileOnly");
}
private File getLog4jConfigFile() {

View File

@ -29,8 +29,10 @@ import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.function.Consumer;
import com.google.common.collect.ImmutableMap;
import org.gradle.api.Project;
import net.fabricmc.loom.util.TinyRemapperMappingsHelper;
@ -40,6 +42,12 @@ import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.DependencyProvider;
public class MinecraftMappedProvider extends DependencyProvider {
private static final Map<String, String> JSR_TO_JETBRAINS = new ImmutableMap.Builder<String, String>()
.put("javax/annotation/Nullable", "org/jetbrains/annotations/Nullable")
.put("javax/annotation/Nonnull", "org/jetbrains/annotations/NotNull")
.put("javax/annotation/concurrent/Immutable", "org/jetbrains/annotations/Unmodifiable")
.build();
private File minecraftMappedJar;
private File minecraftIntermediaryJar;
@ -120,6 +128,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
public TinyRemapper getTinyRemapper(String fromM, String toM) throws IOException {
return TinyRemapper.newRemapper()
.withMappings(TinyRemapperMappingsHelper.create(getExtension().getMappingsProvider().getMappings(), fromM, toM, true))
.withMappings(out -> JSR_TO_JETBRAINS.forEach(out::acceptClass))
.renameInvalidLocals(true)
.rebuildSourceFilenames(true)
.build();

View File

@ -57,4 +57,5 @@ public class Constants {
public static final String MIXIN_COMPILE_EXTENSIONS_VERSION = "0.3.1.5";
public static final String DEV_LAUNCH_INJECTOR_VERSION = "0.2.1+build.8";
public static final String TERMINAL_CONSOLE_APPENDER_VERSION = "1.2.0";
public static final String JETBRAINS_ANNOTATIONS_VERSION = "19.0.0";
}