Add javax annotations for Forge

Forge uses the "default" annotations such as ParametersAreNonnullByDefault.
This commit is contained in:
Juuxel
2020-12-03 22:16:16 +02:00
parent 8baa801394
commit 3655421422
3 changed files with 19 additions and 8 deletions

View File

@@ -105,6 +105,10 @@ public class LaunchProvider extends DependencyProvider {
addDependency(Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER, "runtimeOnly");
annotationDependency = addDependency(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS, "compileOnly");
if (getExtension().isForge()) {
addDependency(Constants.Dependencies.JAVAX_ANNOTATIONS + Constants.Dependencies.Versions.JAVAX_ANNOTATIONS, "compileOnly");
}
postPopulationScheduler.accept(this::writeRemapClassPath);
}

View File

@@ -182,16 +182,21 @@ public class MinecraftMappedProvider extends DependencyProvider {
}
public TinyRemapper getTinyRemapper(String fromM, String toM) throws IOException {
return TinyRemapper.newRemapper()
TinyRemapper.Builder builder = TinyRemapper.newRemapper()
.withMappings(TinyRemapperMappingsHelper.create(getExtension().getMappingsProvider().getMappings(), fromM, toM, true))
.withMappings(out -> JSR_TO_JETBRAINS.forEach(out::acceptClass))
.renameInvalidLocals(true)
.rebuildSourceFilenames(true)
/* FORGE: Required for classes like aej$OptionalNamedTag (1.16.4) which are added by Forge patches.
* They won't get remapped to their proper packages, so IllegalAccessErrors will happen without ._.
*/
.fixPackageAccess(true)
.build();
.rebuildSourceFilenames(true);
if (getExtension().isForge()) {
/* FORGE: Required for classes like aej$OptionalNamedTag (1.16.4) which are added by Forge patches.
* They won't get remapped to their proper packages, so IllegalAccessErrors will happen without ._.
*/
builder.fixPackageAccess(true);
} else {
builder.withMappings(out -> JSR_TO_JETBRAINS.forEach(out::acceptClass));
}
return builder.build();
}
public Path[] getRemapClasspath() {

View File

@@ -80,6 +80,7 @@ public class Constants {
public static final String DEV_LAUNCH_INJECTOR = "net.fabricmc:dev-launch-injector:";
public static final String TERMINAL_CONSOLE_APPENDER = "net.minecrell:terminalconsoleappender:";
public static final String JETBRAINS_ANNOTATIONS = "org.jetbrains:annotations:";
public static final String JAVAX_ANNOTATIONS = "com.google.code.findbugs:jsr305:"; // I hate that I have to add these.
private Dependencies() {
}
@@ -92,6 +93,7 @@ public class Constants {
public static final String DEV_LAUNCH_INJECTOR = "0.2.1+build.8";
public static final String TERMINAL_CONSOLE_APPENDER = "1.2.0";
public static final String JETBRAINS_ANNOTATIONS = "19.0.0";
public static final String JAVAX_ANNOTATIONS = "3.0.2";
private Versions() {
}