Make the sub project requirement a bit more intelligent, no longer blindly depends on all sub projects.
parent
0d92da79c6
commit
4b9db57aaa
|
@ -32,6 +32,7 @@ import net.fabricmc.loom.task.RemapJar;
|
||||||
import net.fabricmc.loom.task.RemapSourcesJar;
|
import net.fabricmc.loom.task.RemapSourcesJar;
|
||||||
import net.fabricmc.loom.util.Constants;
|
import net.fabricmc.loom.util.Constants;
|
||||||
import net.fabricmc.loom.util.LoomDependencyManager;
|
import net.fabricmc.loom.util.LoomDependencyManager;
|
||||||
|
import net.fabricmc.loom.util.NestedJars;
|
||||||
import net.fabricmc.loom.util.SetupIntelijRunConfigs;
|
import net.fabricmc.loom.util.SetupIntelijRunConfigs;
|
||||||
import org.gradle.api.*;
|
import org.gradle.api.*;
|
||||||
import org.gradle.api.artifacts.Configuration;
|
import org.gradle.api.artifacts.Configuration;
|
||||||
|
@ -50,6 +51,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class AbstractPlugin implements Plugin<Project> {
|
public class AbstractPlugin implements Plugin<Project> {
|
||||||
protected Project project;
|
protected Project project;
|
||||||
|
@ -266,7 +268,7 @@ public class AbstractPlugin implements Plugin<Project> {
|
||||||
remapJarTask.dependsOn(project1.getTasks().getByName("jar"));
|
remapJarTask.dependsOn(project1.getTasks().getByName("jar"));
|
||||||
project1.getTasks().getByName("build").dependsOn(remapJarTask);
|
project1.getTasks().getByName("build").dependsOn(remapJarTask);
|
||||||
//Run all the sub project remap jars tasks before the root projects jar, this is to allow us to include projects
|
//Run all the sub project remap jars tasks before the root projects jar, this is to allow us to include projects
|
||||||
project1.subprojects(subProject -> remapJarTask.dependsOn(subProject.getTasksByName("remapJar", false)));
|
NestedJars.getRequiredTasks(project1).forEach(remapJarTask::dependsOn);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AbstractArchiveTask sourcesTask = (AbstractArchiveTask) project1.getTasks().getByName("sourcesJar");
|
AbstractArchiveTask sourcesTask = (AbstractArchiveTask) project1.getTasks().getByName("sourcesJar");
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.zeroturnaround.zip.transform.ZipEntryTransformerEntry;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
|
@ -112,6 +113,26 @@ public class NestedJars {
|
||||||
return fileList;
|
return fileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Looks for any deps that require a sub project to be built first
|
||||||
|
public static List<RemapJar> getRequiredTasks(Project project){
|
||||||
|
List<RemapJar> remapTasks = new ArrayList<>();
|
||||||
|
|
||||||
|
Configuration configuration = project.getConfigurations().getByName(Constants.INCLUDE);
|
||||||
|
DependencySet dependencies = configuration.getDependencies();
|
||||||
|
for (Dependency dependency : dependencies) {
|
||||||
|
if (dependency instanceof ProjectDependency) {
|
||||||
|
ProjectDependency projectDependency = (ProjectDependency) dependency;
|
||||||
|
Project dependencyProject = projectDependency.getDependencyProject();
|
||||||
|
for (Task task : dependencyProject.getTasksByName("remapJar", false)) {
|
||||||
|
if (task instanceof RemapJar) {
|
||||||
|
remapTasks.add((RemapJar) task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return remapTasks;
|
||||||
|
}
|
||||||
|
|
||||||
private static ZipEntryTransformerEntry[] single(ZipEntryTransformerEntry element) {
|
private static ZipEntryTransformerEntry[] single(ZipEntryTransformerEntry element) {
|
||||||
return new ZipEntryTransformerEntry[]{element};
|
return new ZipEntryTransformerEntry[]{element};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue