parent
2a1aca87cc
commit
032c815d19
|
@ -35,7 +35,6 @@ import org.gradle.api.artifacts.Configuration;
|
||||||
import org.gradle.api.artifacts.Dependency;
|
import org.gradle.api.artifacts.Dependency;
|
||||||
import org.gradle.api.artifacts.ModuleDependency;
|
import org.gradle.api.artifacts.ModuleDependency;
|
||||||
import org.gradle.api.artifacts.ResolvedArtifact;
|
import org.gradle.api.artifacts.ResolvedArtifact;
|
||||||
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
|
|
||||||
import org.gradle.api.artifacts.dsl.DependencyHandler;
|
import org.gradle.api.artifacts.dsl.DependencyHandler;
|
||||||
import org.gradle.api.artifacts.query.ArtifactResolutionQuery;
|
import org.gradle.api.artifacts.query.ArtifactResolutionQuery;
|
||||||
import org.gradle.api.artifacts.result.ArtifactResult;
|
import org.gradle.api.artifacts.result.ArtifactResult;
|
||||||
|
@ -66,25 +65,16 @@ public class ModCompileRemapper {
|
||||||
List<ModDependencyInfo> modDependencies = new ArrayList<>();
|
List<ModDependencyInfo> modDependencies = new ArrayList<>();
|
||||||
|
|
||||||
for (ResolvedArtifact artifact : sourceConfig.getResolvedConfiguration().getResolvedArtifacts()) {
|
for (ResolvedArtifact artifact : sourceConfig.getResolvedConfiguration().getResolvedArtifacts()) {
|
||||||
String group;
|
// TODO: This collection doesn't appear to include FileCollection dependencies
|
||||||
String name;
|
// Might have to go based on the dependencies, rather than their resolved form?
|
||||||
String version;
|
// File dependencies use SelfResolvingDependency, which appears to be handled differently
|
||||||
|
String group = artifact.getModuleVersion().getId().getGroup();
|
||||||
|
String name = artifact.getModuleVersion().getId().getName();
|
||||||
|
String version = artifact.getModuleVersion().getId().getVersion();
|
||||||
String classifierSuffix = artifact.getClassifier() == null ? "" : (":" + artifact.getClassifier());
|
String classifierSuffix = artifact.getClassifier() == null ? "" : (":" + artifact.getClassifier());
|
||||||
|
|
||||||
if (artifact.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier) {
|
if (!isFabricMod(logger, artifact)) {
|
||||||
group = ((ModuleComponentIdentifier) artifact.getId().getComponentIdentifier()).getGroup();
|
addToRegularCompile(project, regularConfig, artifact);
|
||||||
name = ((ModuleComponentIdentifier) artifact.getId().getComponentIdentifier()).getModule();
|
|
||||||
version = ((ModuleComponentIdentifier) artifact.getId().getComponentIdentifier()).getVersion();
|
|
||||||
} else {
|
|
||||||
group = "net.fabricmc.synthetic";
|
|
||||||
name = artifact.getId().getComponentIdentifier().getDisplayName().replace('.', '-').replace(" :", "-");
|
|
||||||
version = "0.1.0";
|
|
||||||
}
|
|
||||||
|
|
||||||
final String notation = group + ":" + name + ":" + version + classifierSuffix;
|
|
||||||
|
|
||||||
if (!isFabricMod(logger, artifact, notation)) {
|
|
||||||
addToRegularCompile(project, regularConfig, notation);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,12 +112,12 @@ 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(Logger logger, ResolvedArtifact artifact, String notation) {
|
private static boolean isFabricMod(Logger logger, ResolvedArtifact artifact) {
|
||||||
File input = artifact.getFile();
|
File input = artifact.getFile();
|
||||||
|
|
||||||
try (ZipFile zipFile = new ZipFile(input)) {
|
try (ZipFile zipFile = new ZipFile(input)) {
|
||||||
if (zipFile.getEntry("fabric.mod.json") != null) {
|
if (zipFile.getEntry("fabric.mod.json") != null) {
|
||||||
logger.info("Found Fabric mod in modCompile: {}", notation);
|
logger.info("Found Fabric mod in modCompile: {}", artifact.getId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,10 +127,11 @@ public class ModCompileRemapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addToRegularCompile(Project project, Configuration regularCompile, String notation) {
|
private static void addToRegularCompile(Project project, Configuration regularCompile, ResolvedArtifact artifact) {
|
||||||
project.getLogger().info(":providing " + notation);
|
project.getLogger().info(":providing " + artifact);
|
||||||
DependencyHandler dependencies = project.getDependencies();
|
DependencyHandler dependencies = project.getDependencies();
|
||||||
Dependency dep = dependencies.module(notation);
|
Dependency dep = dependencies.module(artifact.getModuleVersion().toString()
|
||||||
|
+ (artifact.getClassifier() == null ? "" : ':' + artifact.getClassifier())); // the owning module of the artifact
|
||||||
|
|
||||||
if (dep instanceof ModuleDependency) {
|
if (dep instanceof ModuleDependency) {
|
||||||
((ModuleDependency) dep).setTransitive(false);
|
((ModuleDependency) dep).setTransitive(false);
|
||||||
|
|
Loading…
Reference in New Issue