Fix classifier handling for remapped dependencies
parent
792a64e2ef
commit
841fc5a4db
|
@ -76,14 +76,13 @@ public class ModCompileRemapper {
|
||||||
String group = artifact.getModuleVersion().getId().getGroup();
|
String group = artifact.getModuleVersion().getId().getGroup();
|
||||||
String name = artifact.getModuleVersion().getId().getName();
|
String name = artifact.getModuleVersion().getId().getName();
|
||||||
String version = artifact.getModuleVersion().getId().getVersion();
|
String version = artifact.getModuleVersion().getId().getVersion();
|
||||||
String classifierSuffix = artifact.getClassifier() == null ? "" : (":" + artifact.getClassifier());
|
|
||||||
|
|
||||||
if (!isFabricMod(logger, artifact)) {
|
if (!isFabricMod(logger, artifact)) {
|
||||||
addToRegularCompile(project, regularConfig, artifact);
|
addToRegularCompile(project, regularConfig, artifact);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModDependencyInfo info = new ModDependencyInfo(group, name, version, classifierSuffix, artifact.getFile(), remappedConfig, remapData);
|
ModDependencyInfo info = new ModDependencyInfo(group, name, version, artifact.getClassifier(), artifact.getFile(), remappedConfig, remapData);
|
||||||
|
|
||||||
if (refreshDeps) {
|
if (refreshDeps) {
|
||||||
info.forceRemap();
|
info.forceRemap();
|
||||||
|
@ -91,16 +90,16 @@ public class ModCompileRemapper {
|
||||||
|
|
||||||
modDependencies.add(info);
|
modDependencies.add(info);
|
||||||
|
|
||||||
String remappedLog = group + ":" + name + ":" + version + classifierSuffix + " (" + mappingsSuffix + ")";
|
String remappedLog = group + ":" + name + ":" + version + (artifact.getClassifier() == null ? "" : ":" + artifact.getClassifier()) + " (" + mappingsSuffix + ")";
|
||||||
project.getLogger().info(":providing " + remappedLog);
|
project.getLogger().info(":providing " + remappedLog);
|
||||||
|
|
||||||
File remappedSources = new File(info.getRemappedOutput().getAbsolutePath().replace(".jar", "-sources.jar"));
|
File remappedSources = info.getRemappedOutput("sources");
|
||||||
|
|
||||||
if (!remappedSources.exists() || refreshDeps) {
|
if (!remappedSources.exists() || refreshDeps) {
|
||||||
File sources = findSources(dependencies, artifact);
|
File sources = findSources(dependencies, artifact);
|
||||||
|
|
||||||
if (sources != null) {
|
if (sources != null) {
|
||||||
scheduleSourcesRemapping(project, sourceRemapper, sources, info.getRemappedNotation(), info.getRemappedOutput(), modStore);
|
scheduleSourcesRemapping(project, sourceRemapper, sources, info.getRemappedNotation(), remappedSources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +112,7 @@ public class ModCompileRemapper {
|
||||||
|
|
||||||
// Add all of the remapped mods onto the config
|
// Add all of the remapped mods onto the config
|
||||||
for (ModDependencyInfo info : modDependencies) {
|
for (ModDependencyInfo info : modDependencies) {
|
||||||
project.getDependencies().add(info.targetConfig.getName(), project.getDependencies().module(info.getRemappedNotation()));
|
project.getDependencies().add(info.targetConfig.getName(), info.getRemappedNotation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,10 +164,9 @@ public class ModCompileRemapper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void scheduleSourcesRemapping(Project project, SourceRemapper sourceRemapper, File sources, String remappedLog, File remappedJar, File modStore) {
|
private static void scheduleSourcesRemapping(Project project, SourceRemapper sourceRemapper, File sources, String remappedLog, File remappedSources) {
|
||||||
project.getLogger().debug(":providing " + remappedLog + " sources");
|
project.getLogger().debug(":providing " + remappedLog + " sources");
|
||||||
|
|
||||||
File remappedSources = new File(remappedJar.getAbsolutePath().replace(".jar", "-sources.jar"));
|
|
||||||
boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies();
|
boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies();
|
||||||
|
|
||||||
if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified() || refreshDeps) {
|
if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified() || refreshDeps) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.google.gson.JsonObject;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.gradle.api.artifacts.Configuration;
|
import org.gradle.api.artifacts.Configuration;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradlePlugin;
|
import net.fabricmc.loom.LoomGradlePlugin;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ public class ModDependencyInfo {
|
||||||
private final String group;
|
private final String group;
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String version;
|
public final String version;
|
||||||
|
@Nullable
|
||||||
public final String classifier;
|
public final String classifier;
|
||||||
public final File inputFile;
|
public final File inputFile;
|
||||||
public final Configuration targetConfig;
|
public final Configuration targetConfig;
|
||||||
|
@ -51,7 +53,7 @@ public class ModDependencyInfo {
|
||||||
|
|
||||||
private boolean forceRemap = false;
|
private boolean forceRemap = false;
|
||||||
|
|
||||||
public ModDependencyInfo(String group, String name, String version, String classifier, File inputFile, Configuration targetConfig, RemapData remapData) {
|
public ModDependencyInfo(String group, String name, String version, @Nullable String classifier, File inputFile, Configuration targetConfig, RemapData remapData) {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
@ -62,31 +64,35 @@ public class ModDependencyInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRemappedNotation() {
|
public String getRemappedNotation() {
|
||||||
if (classifier == null || classifier.isEmpty()) {
|
if (!hasClassifier()) {
|
||||||
return String.format("%s:%s:%s", getGroup(), name, version);
|
return String.format("%s:%s:%s", getGroup(), name, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format("%s:%s:%s:%s", getGroup(), name, version, classifier);
|
return String.format("%s:%s:%s:%s", getGroup(), name, version, classifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRemappedFilename() {
|
public String getRemappedFilename(boolean withClassifier) {
|
||||||
if (classifier == null || classifier.isEmpty()) {
|
if (!hasClassifier() || !withClassifier) {
|
||||||
return String.format("%s-%s", name, version);
|
return String.format("%s-%s", name, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format("%s-%s@%s", name, version, classifier.replace(':', '-'));
|
return String.format("%s-%s-%s", name, version, classifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getRemappedDir() {
|
public File getRemappedDir() {
|
||||||
return new File(remapData.modStore, String.format("%s/%s/%s", getGroup().replace(".", "/"), name, version));
|
return new File(remapData.modStore, String.format("%s/%s/%s", getGroup().replace(".", "/"), name, version));
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getRemappedOutput() {
|
public File getRemappedOutput() {
|
||||||
return new File(getRemappedDir(), getRemappedFilename() + ".jar");
|
return new File(getRemappedDir(), getRemappedFilename(true) + ".jar");
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getRemappedOutput(String classifier) {
|
||||||
|
return new File(getRemappedDir(), getRemappedFilename(false) + "-" + classifier + ".jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getRemappedPom() {
|
private File getRemappedPom() {
|
||||||
return new File(getRemappedOutput().getAbsolutePath().replace(".jar", ".pom"));
|
return new File(getRemappedDir(), String.format("%s-%s", name, version) + ".pom");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGroup() {
|
private String getGroup() {
|
||||||
|
@ -135,7 +141,11 @@ public class ModDependencyInfo {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s:%s:%s:%s", group, name, version, classifier);
|
return getRemappedNotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasClassifier() {
|
||||||
|
return classifier != null && !classifier.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessWidener() throws IOException {
|
public String getAccessWidener() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue