Reformat to use Fabric API's checkstyle (#137)

* Reformat to use Fabric API's checkstyle

* Fix

* Fix

* Update

* Travis and fixes

* possible fix for checkstyle?

* Helps if i push the checkstyle.xml file...

* Log checkstyle issues to console - used by travis

* Fix some more issues

* opps
This commit is contained in:
modmuss50
2019-11-02 20:23:27 +00:00
committed by GitHub
parent 2bd339241f
commit f85daec559
59 changed files with 2129 additions and 1655 deletions

View File

@@ -24,7 +24,11 @@
package net.fabricmc.loom.util;
import net.fabricmc.loom.LoomGradleExtension;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
@@ -40,10 +44,7 @@ import org.gradle.api.logging.Logger;
import org.gradle.jvm.JvmLibrary;
import org.gradle.language.base.artifact.SourcesArtifact;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import net.fabricmc.loom.LoomGradleExtension;
public class ModCompileRemapper {
public static void remapDependencies(Project project, String mappingsPrefix, LoomGradleExtension extension, Configuration modCompile, Configuration modCompileRemapped, Configuration regularCompile, Consumer<Runnable> postPopulationScheduler) {
@@ -93,7 +94,7 @@ public class ModCompileRemapper {
}
/**
* Checks if an artifact is a fabric mod, according to the presence of a fabric.mod.json
* 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) {
File input = artifact.getFile();
@@ -112,15 +113,18 @@ public class ModCompileRemapper {
project.getLogger().info(":providing " + notation);
DependencyHandler dependencies = project.getDependencies();
Dependency dep = dependencies.module(notation);
if (dep instanceof ModuleDependency) {
((ModuleDependency) dep).setTransitive(false);
}
dependencies.add(regularCompile.getName(), dep);
}
private static void remapArtifact(Project project, Configuration config, ResolvedArtifact artifact, String remappedFilename, File modStore) {
File input = artifact.getFile();
File output = new File(modStore, remappedFilename + ".jar");
if (!output.exists() || input.lastModified() <= 0 || input.lastModified() > output.lastModified()) {
//If the output doesn't exist, or appears to be outdated compared to the input we'll remap it
try {
@@ -129,7 +133,7 @@ public class ModCompileRemapper {
throw new RuntimeException("Failed to remap mod", e);
}
if (!output.exists()){
if (!output.exists()) {
throw new RuntimeException("Failed to remap mod");
}
@@ -142,10 +146,10 @@ public class ModCompileRemapper {
}
private static File findSources(DependencyHandler dependencies, ResolvedArtifact artifact) {
@SuppressWarnings ("unchecked")
ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery()//
@SuppressWarnings("unchecked") ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery()//
.forComponents(artifact.getId().getComponentIdentifier())//
.withArtifacts(JvmLibrary.class, SourcesArtifact.class);
for (ComponentArtifactsResult result : query.execute().getResolvedComponents()) {
for (ArtifactResult srcArtifact : result.getArtifacts(SourcesArtifact.class)) {
if (srcArtifact instanceof ResolvedArtifactResult) {
@@ -153,6 +157,7 @@ public class ModCompileRemapper {
}
}
}
return null;
}