General cleanup

dev/0.11
Reece Dunham 2020-07-26 21:32:10 +01:00 committed by modmuss50
parent 6083146127
commit 1955bcb2ea
34 changed files with 124 additions and 168 deletions

View File

@ -1,5 +1,2 @@
[*.kt]
indent_style = tab
[*.gradle]
[*.{gradle,java}]
indent_style = tab

View File

@ -15,18 +15,18 @@ group = 'net.fabricmc'
archivesBaseName = project.name
def baseVersion = '0.5'
def build = "local"
def build = 'local'
def ENV = System.getenv()
if (ENV.BUILD_NUMBER) {
build = "jenkins #${ENV.BUILD_NUMBER}"
version = baseVersion + "." + ENV.BUILD_NUMBER
build = 'jenkins #${ENV.BUILD_NUMBER}'
version = baseVersion + '.' + ENV.BUILD_NUMBER
} else {
version = baseVersion + ".local"
version = baseVersion + '.local'
}
repositories {
maven {
name = "Fabric"
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
@ -63,18 +63,18 @@ dependencies {
implementation ('org.cadixdev:mercury:0.1.0.fabric-SNAPSHOT')
// Kapt integration
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72')
// Testing
testImplementation(gradleTestKit())
testImplementation("org.spockframework:spock-core:1.3-groovy-2.4") {
testImplementation('org.spockframework:spock-core:1.3-groovy-2.4') {
exclude module: 'groovy-all'
}
}
jar {
manifest {
attributes 'Implementation-Version': version + " Build(" + build + ")"
attributes 'Implementation-Version': version + ' Build(' + build + ')'
}
}
@ -95,7 +95,7 @@ license {
}
checkstyle {
configFile = file("checkstyle.xml")
configFile = file('checkstyle.xml')
toolVersion = '8.25'
}
@ -106,8 +106,8 @@ checkstyleMain {
gradlePlugin {
plugins {
fabricLoom {
id = "fabric-loom"
implementationClass = "net.fabricmc.loom.LoomGradlePlugin"
id = 'fabric-loom'
implementationClass = 'net.fabricmc.loom.LoomGradlePlugin'
}
}
}
@ -123,7 +123,7 @@ publishing {
artifactId project.archivesBaseName
version project.version
from components["java"]
from components['java']
artifact sourcesJar
artifact javadocJar
@ -133,9 +133,9 @@ publishing {
snapshot(MavenPublication) { publication ->
groupId project.group
artifactId project.archivesBaseName
version baseVersion + "-SNAPSHOT"
version baseVersion + '-SNAPSHOT'
from components["java"]
from components['java']
artifact sourcesJar
artifact javadocJar
@ -143,28 +143,28 @@ publishing {
// Manually crate the plugin marker for snapshot versions
snapshotPlugin(MavenPublication) { publication ->
groupId "fabric-loom"
artifactId "fabric-loom.gradle.plugin"
version baseVersion + "-SNAPSHOT"
groupId 'fabric-loom'
artifactId 'fabric-loom.gradle.plugin'
version baseVersion + '-SNAPSHOT'
pom.withXml({
//Based of org.gradle.plugin.devel.plugins.MavenPluginPublishPlugin
// Based off org.gradle.plugin.devel.plugins.MavenPluginPublishPlugin
Element root = asElement()
Document document = root.getOwnerDocument()
Node dependencies = root.appendChild(document.createElement("dependencies"))
Node dependency = dependencies.appendChild(document.createElement("dependency"))
Node groupId = dependency.appendChild(document.createElement("groupId"))
groupId.setTextContent("net.fabricmc")
Node artifactId = dependency.appendChild(document.createElement("artifactId"))
artifactId.setTextContent("fabric-loom")
Node version = dependency.appendChild(document.createElement("version"))
version.setTextContent(baseVersion + "-SNAPSHOT")
Node dependencies = root.appendChild(document.createElement('dependencies'))
Node dependency = dependencies.appendChild(document.createElement('dependency'))
Node groupId = dependency.appendChild(document.createElement('groupId'))
groupId.setTextContent('net.fabricmc')
Node artifactId = dependency.appendChild(document.createElement('artifactId'))
artifactId.setTextContent('fabric-loom')
Node version = dependency.appendChild(document.createElement('version'))
version.setTextContent(baseVersion + '-SNAPSHOT')
})
}
}
repositories {
maven {
url "http://mavenupload.modmuss50.me/"
url 'http://mavenupload.modmuss50.me/'
if (project.hasProperty('mavenPass')) {
credentials {
username 'buildslave'

View File

@ -161,7 +161,7 @@ public class AbstractPlugin implements Plugin<Project> {
/**
* Permit to add a Maven repository to a target project.
*
* @param target The garget project
* @param target The target project
* @param name The name of the repository
* @param url The URL of the repository
* @return An object containing the name and the URL of the repository that can be modified later
@ -330,7 +330,7 @@ public class AbstractPlugin implements Plugin<Project> {
}
parentTask.dependsOn(remapSourcesJarTask);
} catch (UnknownTaskException e) {
} catch (UnknownTaskException ignored) {
// pass
}
} else {
@ -374,8 +374,7 @@ public class AbstractPlugin implements Plugin<Project> {
mavenPublish.publications((publications) -> {
for (Publication publication : publications) {
if (publication instanceof MavenPublication) {
((MavenPublication) publication).pom((pom) -> {
pom.withXml((xml) -> {
((MavenPublication) publication).pom((pom) -> pom.withXml((xml) -> {
Node dependencies = GroovyXmlUtil.getOrCreateNode(xml.asNode(), "dependencies");
Set<String> foundArtifacts = new HashSet<>();
@ -399,8 +398,7 @@ public class AbstractPlugin implements Plugin<Project> {
depNode.appendNode("version", dependency.getVersion());
depNode.appendNode("scope", entry.getMavenScope());
}
});
});
}));
}
}
});

View File

@ -40,8 +40,8 @@ public class ThreadIDFFLogger extends IFernflowerLogger {
public final PrintStream stdOut;
public final PrintStream stdErr;
private ThreadLocal<Stack<String>> workingClass = ThreadLocal.withInitial(Stack::new);
private ThreadLocal<Stack<String>> line = ThreadLocal.withInitial(Stack::new);
private final ThreadLocal<Stack<String>> workingClass = ThreadLocal.withInitial(Stack::new);
private final ThreadLocal<Stack<String>> line = ThreadLocal.withInitial(Stack::new);
public ThreadIDFFLogger() {
this(System.err, System.out);

View File

@ -25,7 +25,6 @@
package net.fabricmc.loom.providers;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
@ -38,10 +37,9 @@ import net.fabricmc.loom.util.MinecraftVersionInfo;
public class MinecraftLibraryProvider {
public File MINECRAFT_LIBS;
private Collection<File> libs = new HashSet<>();
private final Collection<File> libs = new HashSet<>();
public void provide(MinecraftProvider minecraftProvider, Project project) throws IOException {
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
public void provide(MinecraftProvider minecraftProvider, Project project) {
MinecraftVersionInfo versionInfo = minecraftProvider.getVersionInfo();
initFiles(project, minecraftProvider);

View File

@ -79,7 +79,7 @@ public class GenIdeaProjectTask extends AbstractLoomTask {
}
if (runManager == null) {
throw new RuntimeException("Failed to generate intellij run configurations (runManager was not found)");
throw new RuntimeException("Failed to generate IntelliJ run configurations (runManager was not found)");
}
runManager.appendChild(RunConfig.clientRunConfig(project).genRuns(runManager));

View File

@ -89,6 +89,7 @@ public class GenVsCodeProjectTask extends AbstractLoomTask {
}
}
@SuppressWarnings("unused")
private static class VsCodeConfiguration {
public String type = "java";
public String name;

View File

@ -55,9 +55,9 @@ import net.fabricmc.tinyremapper.TinyRemapper;
import net.fabricmc.tinyremapper.TinyUtils;
public class RemapJarTask extends Jar {
private RegularFileProperty input;
private Property<Boolean> addNestedDependencies;
private Property<Boolean> remapAccessWidener;
private final RegularFileProperty input;
private final Property<Boolean> addNestedDependencies;
private final Property<Boolean> remapAccessWidener;
public JarRemapper jarRemapper;
public RemapJarTask() {

View File

@ -24,7 +24,6 @@
package net.fabricmc.loom.util;
import java.io.IOException;
import java.io.OutputStream;
import java.util.function.Consumer;
@ -41,7 +40,7 @@ public class ConsumingOutputStream extends OutputStream {
}
@Override
public void write(int b) throws IOException {
public void write(int b) {
char ch = (char) (b & 0xFF);
buffer.append(ch);
@ -51,7 +50,7 @@ public class ConsumingOutputStream extends OutputStream {
}
@Override
public void flush() throws IOException {
public void flush() {
String str = buffer.toString();
if (str.endsWith("\r") || str.endsWith("\n")) {

View File

@ -132,8 +132,6 @@ public abstract class DependencyProvider {
return sourceConfiguration;
}
// TODO: Can this be done with stable APIs only?
@SuppressWarnings("UnstableApiUsage")
public Set<File> resolve() {
return sourceConfiguration.files(dependency);
}

View File

@ -82,9 +82,6 @@ public class DownloadUtil {
// We want to download gzip compressed stuff
connection.setRequestProperty("Accept-Encoding", "gzip");
//We shouldn't need to set a user agent, but it's here just in case
//connection.setRequestProperty("User-Agent", null);
// Try make the connection, it will hang here if the connection is bad
connection.connect();

View File

@ -42,13 +42,13 @@ import org.w3c.dom.NodeList;
import net.fabricmc.loom.LoomGradleExtension;
public class FabricApiExtension {
private Project project;
private final Project project;
public FabricApiExtension(Project project) {
this.project = project;
}
private static HashMap<String, Map<String, String>> moduleVersionCache = new HashMap<>();
private static final HashMap<String, Map<String, String>> moduleVersionCache = new HashMap<>();
public Dependency module(String moduleName, String fabricApiVersion) {
return project.getDependencies()

View File

@ -26,7 +26,6 @@ package net.fabricmc.loom.util;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import groovy.util.Node;
@ -58,8 +57,4 @@ public final class GroovyXmlUtil {
//noinspection unchecked
return (Stream<Node>) (Stream) (((List<Object>) node.children()).stream().filter((i) -> i instanceof Node));
}
public static Iterable<Node> childrenNodes(Node node) {
return childrenNodesStream(node).collect(Collectors.toList());
}
}

View File

@ -174,7 +174,7 @@ public class LineNumberRemapper {
private final String name;
private int maxLine;
private int maxLineDest;
private Map<Integer, Integer> lineMap = new HashMap<>();
private final Map<Integer, Integer> lineMap = new HashMap<>();
private RClass(String name) {
this.name = name;

View File

@ -52,7 +52,7 @@ public class LoomDependencyManager {
}
}
private List<DependencyProvider> dependencyProviderList = new ArrayList<>();
private final List<DependencyProvider> dependencyProviderList = new ArrayList<>();
public void addProvider(DependencyProvider provider) {
if (dependencyProviderList.contains(provider)) {

View File

@ -91,32 +91,11 @@ public final class MixinRefmapHelper {
}
}
}
} catch (Exception e) {
} catch (Exception ignored) {
// ...
}
}
});
return mixinFilename;
}
private static Set<String> findRefmaps(File output) {
// first, identify all of the mixin refmaps
Set<String> mixinRefmapFilenames = new HashSet<>();
// TODO: this is also a lovely hack
ZipUtil.iterate(output, (stream, entry) -> {
if (!entry.isDirectory() && entry.getName().endsWith(".json") && !entry.getName().contains("/") && !entry.getName().contains("\\")) {
// JSON file in root directory
try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) {
JsonObject json = GSON.fromJson(inputStreamReader, JsonObject.class);
if (json != null && json.has("refmap")) {
mixinRefmapFilenames.add(json.get("refmap").getAsString());
}
} catch (Exception e) {
// ...
}
}
});
return mixinRefmapFilenames;
}
}

View File

@ -83,7 +83,7 @@ public class ModCompileRemapper {
final String notation = group + ":" + name + ":" + version + classifierSuffix;
if (!isFabricMod(project, logger, artifact, notation)) {
if (!isFabricMod(logger, artifact, notation)) {
addToRegularCompile(project, regularConfig, notation);
continue;
}
@ -122,7 +122,7 @@ public class ModCompileRemapper {
/**
* Checks if an artifact is a fabric mod, according to the presence of a fabric.mod.json.
*/
private static boolean isFabricMod(Project project, Logger logger, ResolvedArtifact artifact, String notation) {
private static boolean isFabricMod(Logger logger, ResolvedArtifact artifact, String notation) {
File input = artifact.getFile();
try (ZipFile zipFile = new ZipFile(input)) {
@ -166,7 +166,8 @@ public class ModCompileRemapper {
}
private static void scheduleSourcesRemapping(Project project, SourceRemapper sourceRemapper, File sources, String remappedLog, String remappedFilename, File modStore) {
project.getLogger().info(":providing " + remappedLog + " sources");
project.getLogger().debug(":providing " + remappedLog + " sources");
File remappedSources = new File(modStore, remappedFilename + "-sources.jar");
boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies();

View File

@ -91,7 +91,7 @@ public class ModProcessor {
// Strip out all contained jar info as we dont want loader to try and load the jars contained in dev.
ZipUtil.transformEntries(file, new ZipEntryTransformerEntry[] {(new ZipEntryTransformerEntry("fabric.mod.json", new StringZipEntryTransformer() {
@Override
protected String transform(ZipEntry zipEntry, String input) throws IOException {
protected String transform(ZipEntry zipEntry, String input) {
JsonObject json = GSON.fromJson(input, JsonObject.class);
json.remove("jars");
return GSON.toJson(json);
@ -146,7 +146,8 @@ public class ModProcessor {
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
for (File inputFile : project.getConfigurations().getByName(entry.getSourceConfiguration()).getFiles()) {
if (remapList.stream().noneMatch(info -> info.getInputFile().equals(inputFile))) {
project.getLogger().info("Adding " + inputFile + " onto the remap classpath");
project.getLogger().debug("Adding " + inputFile + " onto the remap classpath");
remapper.readClassPathAsync(inputFile.toPath());
}
}
@ -154,7 +155,9 @@ public class ModProcessor {
for (ModDependencyInfo info : remapList) {
InputTag tag = remapper.createInputTag();
project.getLogger().info("Adding " + info.getInputFile() + " as a remap input");
project.getLogger().debug("Adding " + info.getInputFile() + " as a remap input");
remapper.readInputsAsync(tag, info.getInputFile().toPath());
tagMap.put(info, tag);
}
@ -191,7 +194,6 @@ public class ModProcessor {
String launchMethod = extension.getLoaderLaunchMethod();
String jsonStr;
int priority = 0;
try (JarFile jarFile = new JarFile(file)) {
ZipEntry entry = null;
@ -206,7 +208,6 @@ public class ModProcessor {
if (entry == null) {
entry = jarFile.getEntry("fabric-installer.json");
priority++;
if (entry == null) {
return null;
@ -218,8 +219,7 @@ public class ModProcessor {
}
}
JsonObject jsonObject = GSON.fromJson(jsonStr, JsonObject.class);
return jsonObject;
return GSON.fromJson(jsonStr, JsonObject.class);
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -75,7 +75,7 @@ public class NestedJars {
return ZipUtil.transformEntries(modJar, single(new ZipEntryTransformerEntry("fabric.mod.json", new StringZipEntryTransformer() {
@Override
protected String transform(ZipEntry zipEntry, String input) throws IOException {
protected String transform(ZipEntry zipEntry, String input) {
JsonObject json = GSON.fromJson(input, JsonObject.class);
JsonArray nestedJars = json.getAsJsonArray("jars");

View File

@ -34,9 +34,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@ -51,7 +48,6 @@ import org.gradle.api.Project;
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.providers.MinecraftProvider;
public class RunConfig {
public String configName;
@ -62,7 +58,7 @@ public class RunConfig {
public String vmArgs;
public String programArgs;
public Element genRuns(Element doc) throws IOException, ParserConfigurationException, TransformerException {
public Element genRuns(Element doc) {
Element root = this.addXml(doc, "component", ImmutableMap.of("name", "ProjectRunConfigurationManager"));
root = addXml(root, "configuration", ImmutableMap.of("default", "false", "name", configName, "type", "Application", "factoryName", "Application"));
@ -115,16 +111,13 @@ public class RunConfig {
runConfig.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
runConfig.vmArgs = "";
switch (extension.getLoaderLaunchMethod()) {
case "launchwrapper":
if ("launchwrapper".equals(extension.getLoaderLaunchMethod())) {
runConfig.mainClass = "net.minecraft.launchwrapper.Launch";
runConfig.programArgs = "--tweakClass " + ("client".equals(mode) ? Constants.DEFAULT_FABRIC_CLIENT_TWEAKER : Constants.DEFAULT_FABRIC_SERVER_TWEAKER);
break;
default:
} else {
runConfig.mainClass = "net.fabricmc.devlaunchinjector.Main";
runConfig.programArgs = "";
runConfig.vmArgs = "-Dfabric.dli.config=" + encodeEscaped(extension.getDevLauncherConfig().getAbsolutePath()) + " -Dfabric.dli.env=" + mode.toLowerCase();
break;
}
if (extension.getLoaderLaunchMethod().equals("launchwrapper")) {
@ -159,8 +152,6 @@ public class RunConfig {
public static RunConfig clientRunConfig(Project project) {
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
MinecraftProvider minecraftProvider = extension.getMinecraftProvider();
MinecraftVersionInfo minecraftVersionInfo = minecraftProvider.getVersionInfo();
RunConfig ideaClient = new RunConfig();
ideaClient.configName = "Minecraft Client";

View File

@ -44,7 +44,7 @@ public class AccessWidener {
public Map<String, Access> classAccess = new HashMap<>();
public Map<EntryTriple, Access> methodAccess = new HashMap<>();
public Map<EntryTriple, Access> fieldAccess = new HashMap<>();
private Set<String> classes = new LinkedHashSet<>();
private final Set<String> classes = new LinkedHashSet<>();
public void read(BufferedReader reader) throws IOException {
String headerStr = reader.readLine();

View File

@ -29,6 +29,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
@SuppressWarnings("unused")
public class AssetIndex {
private final Map<String, AssetObject> objects;
private boolean virtual;

View File

@ -24,6 +24,7 @@
package net.fabricmc.loom.util.assets;
@SuppressWarnings("unused")
public class AssetObject {
private String hash;
private long size;

View File

@ -78,7 +78,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
put("defaultObfuscationEnv", "named:intermediary");
}};
project.getLogger().info("Outputting refmap to dir: " + getDestinationDir(task) + " for compile task: " + task);
project.getLogger().debug("Outputting refmap to dir: " + getDestinationDir(task) + " for compile task: " + task);
args.forEach((k, v) -> passArgument(task, k, v));
} catch (IOException e) {
project.getLogger().error("Could not configure mixin annotation processors", e);

View File

@ -62,7 +62,7 @@ public class ProgressLogger {
// prior to Gradle 2.14
try {
progressLoggerFactoryClass = Class.forName("org.gradle.logging.ProgressLoggerFactory");
} catch (ClassNotFoundException e1) {
} catch (ClassNotFoundException ignored) {
// Unsupported Gradle version
}
}