General cleanup
This commit is contained in:
		
							parent
							
								
									6083146127
								
							
						
					
					
						commit
						1955bcb2ea
					
				
					 34 changed files with 124 additions and 168 deletions
				
			
		|  | @ -1,5 +1,2 @@ | |||
| [*.kt] | ||||
| indent_style = tab | ||||
| 
 | ||||
| [*.gradle] | ||||
| [*.{gradle,java}] | ||||
| indent_style = tab | ||||
							
								
								
									
										58
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								build.gradle
									
									
									
									
									
								
							|  | @ -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,48 +123,48 @@ publishing { | |||
| 			artifactId project.archivesBaseName | ||||
| 			version project.version | ||||
| 
 | ||||
| 			from components["java"] | ||||
| 			from components['java'] | ||||
| 
 | ||||
| 			artifact sourcesJar | ||||
| 			artifact javadocJar | ||||
| 		} | ||||
| 
 | ||||
| 		//Also publish a snapshot so people can use the latest version if they wish | ||||
| 		// Also publish a snapshot so people can use the latest version if they wish | ||||
| 		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 | ||||
| 		} | ||||
| 
 | ||||
| 		//Manually crate the plugin marker for snapshot versions | ||||
| 		// 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' | ||||
|  |  | |||
|  | @ -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()); | ||||
| 									} | ||||
| 									}); | ||||
| 								}); | ||||
| 								})); | ||||
| 							} | ||||
| 						} | ||||
| 					}); | ||||
|  |  | |||
|  | @ -68,7 +68,7 @@ public class LoomGradleExtension { | |||
| 
 | ||||
| 	final List<LoomDecompiler> decompilers = new ArrayList<>(); | ||||
| 
 | ||||
| 	//Not to be set in the build.gradle | ||||
| 	// Not to be set in the build.gradle | ||||
| 	private final Project project; | ||||
| 	private LoomDependencyManager dependencyManager; | ||||
| 	private JarProcessorManager jarProcessorManager; | ||||
|  | @ -354,7 +354,7 @@ public class LoomGradleExtension { | |||
| 
 | ||||
| 	// Ideally this should use maven, but this is a lot easier | ||||
| 	public Function<String, String> getIntermediaryUrl() { | ||||
| 		//Done like this to work around this possibly not being a java string... | ||||
| 		// Done like this to work around this possibly not being a java string... | ||||
| 		return s -> intermediaryUrl.apply(s).toString(); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -81,7 +81,7 @@ public abstract class AbstractFernFlowerDecompiler implements LoomDecompiler { | |||
| 		args.add("-l=" + absolutePathOf(linemapDestination)); | ||||
| 		args.add("-m=" + absolutePathOf(metaData.javaDocs)); | ||||
| 
 | ||||
| 		//TODO, Decompiler breaks on jemalloc, J9 module-info.class? | ||||
| 		// TODO, Decompiler breaks on jemalloc, J9 module-info.class? | ||||
| 		for (Path library : metaData.libraries) { | ||||
| 			args.add("-e=" + absolutePathOf(library)); | ||||
| 		} | ||||
|  |  | |||
|  | @ -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); | ||||
|  | @ -92,7 +92,7 @@ public class ThreadIDFFLogger extends IFernflowerLogger { | |||
| 
 | ||||
| 	@Override | ||||
| 	public void startMethod(String methodName) { | ||||
| 		//No need to print out methods | ||||
| 		// No need to print out methods | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
|  |  | |||
|  | @ -41,7 +41,7 @@ public final class MappingsCache { | |||
| 
 | ||||
| 	private final Map<Path, SoftReference<TinyTree>> mappingsCache = new HashMap<>(); | ||||
| 
 | ||||
| 	//TODO: loom doesn't actually use new mappings when the mappings change until the gradle daemons are stopped | ||||
| 	// TODO: loom doesn't actually use new mappings when the mappings change until the gradle daemons are stopped | ||||
| 	public TinyTree get(Path mappingsPath) throws IOException { | ||||
| 		mappingsPath = mappingsPath.toAbsolutePath(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -81,7 +81,7 @@ public class MinecraftMappedProvider extends DependencyProvider { | |||
| 			try { | ||||
| 				mapMinecraftJar(); | ||||
| 			} catch (Throwable t) { | ||||
| 				//Cleanup some some things that may be in a bad state now | ||||
| 				// Cleanup some some things that may be in a bad state now | ||||
| 				minecraftMappedJar.delete(); | ||||
| 				minecraftIntermediaryJar.delete(); | ||||
| 				getExtension().getMappingsProvider().cleanFiles(); | ||||
|  |  | |||
|  | @ -57,7 +57,7 @@ public class MinecraftNativesProvider { | |||
| 					throw new GradleException("Native jar not found at " + libJarFile.getAbsolutePath()); | ||||
| 				} | ||||
| 
 | ||||
| 				//TODO possibly find a way to prevent needing to re-extract after each run, doesnt seem too slow | ||||
| 				// TODO possibly find a way to prevent needing to re-extract after each run, doesnt seem too slow | ||||
| 				ZipUtil.unpack(libJarFile, nativesDir); | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
|  | @ -127,10 +127,10 @@ public class MinecraftProvider extends DependencyProvider { | |||
| 
 | ||||
| 		if (offline) { | ||||
| 			if (manifests.exists()) { | ||||
| 				//If there is the manifests already we'll presume that's good enough | ||||
| 				// If there is the manifests already we'll presume that's good enough | ||||
| 				getProject().getLogger().debug("Found version manifests, presuming up-to-date"); | ||||
| 			} else { | ||||
| 				//If we don't have the manifests then there's nothing more we can do | ||||
| 				// If we don't have the manifests then there's nothing more we can do | ||||
| 				throw new GradleException("Version manifests not found at " + manifests.getAbsolutePath()); | ||||
| 			} | ||||
| 		} else { | ||||
|  |  | |||
|  | @ -53,7 +53,7 @@ public class GenIdeaProjectTask extends AbstractLoomTask { | |||
| 	public void genIdeaRuns() throws IOException, ParserConfigurationException, SAXException, TransformerException { | ||||
| 		Project project = this.getProject(); | ||||
| 
 | ||||
| 		//Only generate the idea runs on the root project | ||||
| 		// Only generate the idea runs on the root project | ||||
| 		if (!AbstractPlugin.isRootProject(project)) { | ||||
| 			return; | ||||
| 		} | ||||
|  | @ -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)); | ||||
|  |  | |||
|  | @ -39,7 +39,7 @@ import org.gradle.api.tasks.TaskAction; | |||
| import net.fabricmc.loom.LoomGradleExtension; | ||||
| import net.fabricmc.loom.util.RunConfig; | ||||
| 
 | ||||
| //Recommended vscode plugins: | ||||
| // Recommended vscode plugins: | ||||
| // https://marketplace.visualstudio.com/items?itemName=redhat.java | ||||
| // https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug | ||||
| // https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack | ||||
|  | @ -89,6 +89,7 @@ public class GenVsCodeProjectTask extends AbstractLoomTask { | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	@SuppressWarnings("unused") | ||||
| 	private static class VsCodeConfiguration { | ||||
| 		public String type = "java"; | ||||
| 		public String name; | ||||
|  |  | |||
|  | @ -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() { | ||||
|  |  | |||
|  | @ -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")) { | ||||
|  |  | |||
|  | @ -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); | ||||
| 		} | ||||
|  |  | |||
|  | @ -67,7 +67,7 @@ public class DownloadUtil { | |||
| 			to.delete(); | ||||
| 		} | ||||
| 
 | ||||
| 		//If the output already exists we'll use it's last modified time | ||||
| 		// If the output already exists we'll use it's last modified time | ||||
| 		if (to.exists()) { | ||||
| 			connection.setIfModifiedSince(to.lastModified()); | ||||
| 		} | ||||
|  | @ -79,13 +79,10 @@ public class DownloadUtil { | |||
| 			connection.setRequestProperty("If-None-Match", etag); | ||||
| 		} | ||||
| 
 | ||||
| 		//We want to download gzip compressed stuff | ||||
| 		// 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 | ||||
| 		// Try make the connection, it will hang here if the connection is bad | ||||
| 		connection.connect(); | ||||
| 
 | ||||
| 		int code = connection.getResponseCode(); | ||||
|  | @ -111,10 +108,10 @@ public class DownloadUtil { | |||
| 			logger.info("'{}' Changed, downloading {}", to, toNiceSize(contentLength)); | ||||
| 		} | ||||
| 
 | ||||
| 		try { //Try download to the output | ||||
| 		try { // Try download to the output | ||||
| 			FileUtils.copyInputStreamToFile(connection.getInputStream(), to); | ||||
| 		} catch (IOException e) { | ||||
| 			to.delete(); //Probably isn't good if it fails to copy/save | ||||
| 			to.delete(); // Probably isn't good if it fails to copy/save | ||||
| 			throw e; | ||||
| 		} | ||||
| 
 | ||||
|  |  | |||
|  | @ -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() | ||||
|  |  | |||
|  | @ -29,14 +29,14 @@ import java.lang.reflect.Method; | |||
| import org.gradle.api.Project; | ||||
| import org.gradle.api.file.RegularFileProperty; | ||||
| 
 | ||||
| //This is used to bridge the gap over large gradle api changes. | ||||
| // This is used to bridge the gap over large gradle api changes. | ||||
| public class GradleSupport { | ||||
| 	public static RegularFileProperty getfileProperty(Project project) { | ||||
| 		try { | ||||
| 			//First try the new method, if that fails fall back. | ||||
| 			// First try the new method, if that fails fall back. | ||||
| 			return getfilePropertyModern(project); | ||||
| 		} catch (Exception e) { | ||||
| 			//Nope | ||||
| 			// Nope | ||||
| 		} | ||||
| 
 | ||||
| 		try { | ||||
|  |  | |||
|  | @ -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()); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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)) { | ||||
|  |  | |||
|  | @ -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; | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -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(); | ||||
| 
 | ||||
|  | @ -174,7 +175,7 @@ public class ModCompileRemapper { | |||
| 			try { | ||||
| 				sourceRemapper.scheduleRemapSources(sources, remappedSources); | ||||
| 
 | ||||
| 				//Set the remapped sources creation date to match the sources if we're likely succeeded in making it | ||||
| 				// Set the remapped sources creation date to match the sources if we're likely succeeded in making it | ||||
| 				remappedSources.setLastModified(sources.lastModified()); | ||||
| 			} catch (Exception e) { | ||||
| 				e.printStackTrace(); | ||||
|  |  | |||
|  | @ -88,10 +88,10 @@ public class ModProcessor { | |||
| 	} | ||||
| 
 | ||||
| 	private static void stripNestedJars(File file) { | ||||
| 		//Strip out all contained jar info as we dont want loader to try and load the jars contained in dev. | ||||
| 		// 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(); | ||||
| 		} | ||||
|  |  | |||
|  | @ -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"); | ||||
| 
 | ||||
|  | @ -107,7 +107,7 @@ public class NestedJars { | |||
| 				ProjectDependency projectDependency = (ProjectDependency) dependency; | ||||
| 				Project dependencyProject = projectDependency.getDependencyProject(); | ||||
| 
 | ||||
| 				//TODO change this to allow just normal jar tasks, so a project can have a none loom sub project | ||||
| 				// TODO change this to allow just normal jar tasks, so a project can have a none loom sub project | ||||
| 				Collection<Task> remapJarTasks = dependencyProject.getTasksByName("remapJar", false); | ||||
| 				Collection<Task> jarTasks = dependencyProject.getTasksByName("jar", false); | ||||
| 
 | ||||
|  | @ -143,7 +143,7 @@ public class NestedJars { | |||
| 		return fileList; | ||||
| 	} | ||||
| 
 | ||||
| 	//Looks for any deps that require a sub project to be built first | ||||
| 	// Looks for any deps that require a sub project to be built first | ||||
| 	public static List<RemapJarTask> getRequiredTasks(Project project) { | ||||
| 		List<RemapJarTask> remapTasks = new ArrayList<>(); | ||||
| 
 | ||||
|  | @ -195,7 +195,7 @@ public class NestedJars { | |||
| 				ZipUtil.addEntry(tempFile, "fabric.mod.json", getMod(dependency).getBytes()); | ||||
| 				fileList.add(tempFile); | ||||
| 			} else { | ||||
| 				//Default copy the jar right in | ||||
| 				// Default copy the jar right in | ||||
| 				fileList.add(file); | ||||
| 			} | ||||
| 		} | ||||
|  | @ -203,7 +203,7 @@ public class NestedJars { | |||
| 		return fileList; | ||||
| 	} | ||||
| 
 | ||||
| 	//Generates a barebones mod for a dependency | ||||
| 	// Generates a barebones mod for a dependency | ||||
| 	private static String getMod(ResolvedDependency dependency) { | ||||
| 		JsonObject jsonObject = new JsonObject(); | ||||
| 		jsonObject.addProperty("schemaVersion", 1); | ||||
|  |  | |||
|  | @ -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"; | ||||
|  | @ -182,7 +173,7 @@ public class RunConfig { | |||
| 		return ideaServer; | ||||
| 	} | ||||
| 
 | ||||
| 	//This can be removed at somepoint, its not ideal but its the best solution I could thing of | ||||
| 	// This can be removed at somepoint, its not ideal but its the best solution I could thing of | ||||
| 	public static boolean needsUpgrade(File file) throws IOException { | ||||
| 		String contents = FileUtils.readFileToString(file, StandardCharsets.UTF_8); | ||||
| 		return !(contents.contains("net.fabricmc.devlaunchinjector.Main")); | ||||
|  |  | |||
|  | @ -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(); | ||||
|  | @ -76,7 +76,7 @@ public class AccessWidener { | |||
| 		Set<String> targets = new LinkedHashSet<>(); | ||||
| 
 | ||||
| 		while ((line = reader.readLine()) != null) { | ||||
| 			//Comment handling | ||||
| 			// Comment handling | ||||
| 			int commentPos = line.indexOf('#'); | ||||
| 
 | ||||
| 			if (commentPos >= 0) { | ||||
|  | @ -136,7 +136,7 @@ public class AccessWidener { | |||
| 		classes.addAll(parentClasses); | ||||
| 	} | ||||
| 
 | ||||
| 	//Could possibly be cleaner but should do its job for now | ||||
| 	// Could possibly be cleaner but should do its job for now | ||||
| 	public void write(StringWriter writer) { | ||||
| 		writer.write("accessWidener\tv1\t"); | ||||
| 		writer.write(namespace); | ||||
|  | @ -310,7 +310,7 @@ public class AccessWidener { | |||
| 
 | ||||
| 	private static int makeProtected(int i) { | ||||
| 		if ((i & Opcodes.ACC_PUBLIC) != 0) { | ||||
| 			//Return i if public | ||||
| 			// Return i if public | ||||
| 			return i; | ||||
| 		} | ||||
| 
 | ||||
|  |  | |||
|  | @ -173,7 +173,7 @@ public class AccessWidenerJarProcessor implements JarProcessor { | |||
| 			return true; | ||||
| 		} | ||||
| 
 | ||||
| 		return !Arrays.equals(inputHash, hash); //TODO how do we know if the current jar as the correct access applied? save the hash of the input? | ||||
| 		return !Arrays.equals(inputHash, hash); // TODO how do we know if the current jar as the correct access applied? save the hash of the input? | ||||
| 	} | ||||
| 
 | ||||
| 	private class AccessTransformer extends ClassVisitor { | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ public class AccessWidenerRemapper { | |||
| 	} | ||||
| 
 | ||||
| 	public AccessWidener remap() { | ||||
| 		//Dont remap if we dont need to | ||||
| 		// Dont remap if we dont need to | ||||
| 		if (input.namespace.equals(to)) { | ||||
| 			return input; | ||||
| 		} | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ | |||
| 
 | ||||
| package net.fabricmc.loom.util.assets; | ||||
| 
 | ||||
| @SuppressWarnings("unused") | ||||
| public class AssetObject { | ||||
| 	private String hash; | ||||
| 	private long size; | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -56,13 +56,13 @@ public class ProgressLogger { | |||
| 		Class<?> progressLoggerFactoryClass = null; | ||||
| 
 | ||||
| 		try { | ||||
| 			//Gradle 2.14 and higher | ||||
| 			// Gradle 2.14 and higher | ||||
| 			progressLoggerFactoryClass = Class.forName("org.gradle.internal.logging.progress.ProgressLoggerFactory"); | ||||
| 		} catch (ClassNotFoundException e) { | ||||
| 			//prior to Gradle 2.14 | ||||
| 			// prior to Gradle 2.14 | ||||
| 			try { | ||||
| 				progressLoggerFactoryClass = Class.forName("org.gradle.logging.ProgressLoggerFactory"); | ||||
| 			} catch (ClassNotFoundException e1) { | ||||
| 			} catch (ClassNotFoundException ignored) { | ||||
| 				// Unsupported Gradle version | ||||
| 			} | ||||
| 		} | ||||
|  | @ -75,7 +75,7 @@ public class ProgressLogger { | |||
| 			try { | ||||
| 				return logger.getClass().getMethod(methodName, args); | ||||
| 			} catch (NoSuchMethodException ignored) { | ||||
| 				//Nope | ||||
| 				// Nope | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | @ -88,7 +88,7 @@ public class ProgressLogger { | |||
| 				method.setAccessible(true); | ||||
| 				return method.invoke(logger, args); | ||||
| 			} catch (IllegalAccessException | InvocationTargetException ignored) { | ||||
| 				//Nope | ||||
| 				// Nope | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue