pull in annotationProcessor dependencies from fabric-loader JSON too

dev/0.11
asie 2019-05-27 22:14:35 +02:00
parent 89d207d06b
commit 4134c7ef50
3 changed files with 15 additions and 7 deletions

View File

@ -177,7 +177,9 @@ public class AbstractPlugin implements Plugin<Project> {
if (module instanceof ResolvedDependencyResult) { if (module instanceof ResolvedDependencyResult) {
if (module.getFrom().getId() instanceof ModuleComponentIdentifier) { if (module.getFrom().getId() instanceof ModuleComponentIdentifier) {
ModuleComponentIdentifier mci = ((ModuleComponentIdentifier) module.getFrom().getId()); ModuleComponentIdentifier mci = ((ModuleComponentIdentifier) module.getFrom().getId());
proj.getDependencies().add(configuration, proj.getDependencies().module(mci.getGroup() + ":" + mci.getModule() + ":" + mci.getVersion())); String moduleId = mci.getGroup() + ":" + mci.getModule() + ":" + mci.getVersion();
proj.getDependencies().add(configuration, proj.getDependencies().module(moduleId));
proj.getLogger().debug("Loom addModule " + moduleId + " to " + configuration);
} }
for (DependencyResult child : ((ResolvedDependencyResult) module).getSelected().getDependencies()) { for (DependencyResult child : ((ResolvedDependencyResult) module).getSelected().getDependencies()) {

View File

@ -139,12 +139,13 @@ public class LoomGradleExtension {
} }
@Nullable @Nullable
private static Dependency findDependency(Collection<Configuration> configs, BiPredicate<String, String> groupNameFilter) { private static Dependency findDependency(Project p, Collection<Configuration> configs, BiPredicate<String, String> groupNameFilter) {
for (Configuration config : configs) { for (Configuration config : configs) {
for (Dependency dependency : config.getDependencies()) { for (Dependency dependency : config.getDependencies()) {
String group = dependency.getGroup(); String group = dependency.getGroup();
String name = dependency.getName(); String name = dependency.getName();
if (groupNameFilter.test(group, name)) { if (groupNameFilter.test(group, name)) {
p.getLogger().debug("Loom findDependency found: " + group + ":" + name + ":" + dependency.getVersion());
return dependency; return dependency;
} }
} }
@ -171,12 +172,12 @@ public class LoomGradleExtension {
private Dependency getMixinDependency() { private Dependency getMixinDependency() {
return recurseProjects((p) -> { return recurseProjects((p) -> {
List<Configuration> configs = new ArrayList<>(); List<Configuration> configs = new ArrayList<>();
// check compile first // check compile classpath first
configs.add(p.getConfigurations().getByName("compile")); configs.add(p.getConfigurations().getByName("compileClasspath"));
// failing that, buildscript // failing that, buildscript
configs.addAll(p.getBuildscript().getConfigurations()); configs.addAll(p.getBuildscript().getConfigurations());
return findDependency(configs, (group, name) -> { return findDependency(p, configs, (group, name) -> {
if (name.equalsIgnoreCase("mixin") && group.equalsIgnoreCase("org.spongepowered")) { if (name.equalsIgnoreCase("mixin") && group.equalsIgnoreCase("org.spongepowered")) {
return true; return true;
} }

View File

@ -154,13 +154,18 @@ public class LoomDependencyManager {
private static void handleInstallerJson(JsonObject jsonObject, Project project){ private static void handleInstallerJson(JsonObject jsonObject, Project project){
JsonObject libraries = jsonObject.get("libraries").getAsJsonObject(); JsonObject libraries = jsonObject.get("libraries").getAsJsonObject();
Configuration mcDepsConfig = project.getConfigurations().getByName(Constants.MINECRAFT_DEPENDENCIES);
Configuration apDepsConfig = project.getConfigurations().getByName("annotationProcessor");
libraries.get("common").getAsJsonArray().forEach(jsonElement -> { libraries.get("common").getAsJsonArray().forEach(jsonElement -> {
String name = jsonElement.getAsJsonObject().get("name").getAsString(); String name = jsonElement.getAsJsonObject().get("name").getAsString();
Configuration configuration = project.getConfigurations().getByName(Constants.MINECRAFT_DEPENDENCIES);
ExternalModuleDependency modDep = (ExternalModuleDependency) project.getDependencies().create(name); ExternalModuleDependency modDep = (ExternalModuleDependency) project.getDependencies().create(name);
modDep.setTransitive(false); modDep.setTransitive(false);
configuration.getDependencies().add(modDep); mcDepsConfig.getDependencies().add(modDep);
apDepsConfig.getDependencies().add(modDep);
project.getLogger().debug("Loom adding " + name + " from installer JSON");
if(jsonElement.getAsJsonObject().has("url")){ if(jsonElement.getAsJsonObject().has("url")){
String url = jsonElement.getAsJsonObject().get("url").getAsString(); String url = jsonElement.getAsJsonObject().get("url").getAsString();