Skip to content

Commit

Permalink
Make sure AWs, ATs, and IIs are shared over inherited features that s…
Browse files Browse the repository at this point in the history
…hare configurations.
  • Loading branch information
lukebemish committed Dec 31, 2024
1 parent d2f0d94 commit ad5c6b6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ public void forLocalFeature(SourceSet sourceSet, Action<FabricSourceSetDependenc
forFeatureShared(sourceSet, action, true);
}

@Override
protected List<String> getInstallationConfigurationNames() {
var out = new ArrayList<>(super.getInstallationConfigurationNames());
out.add("AccessWideners");
return out;
}

private Configuration forRunRemapping(Run run, RunType runType) {
/*
General architecture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.lukebemish.crochet.internal.CrochetPlugin;
import dev.lukebemish.crochet.internal.FeatureUtils;
import dev.lukebemish.crochet.internal.IdeaModelHandlerPlugin;
import dev.lukebemish.crochet.internal.InheritanceMarker;
import dev.lukebemish.crochet.internal.tasks.TaskGraphExecution;
import org.apache.commons.lang3.StringUtils;
import org.gradle.api.Named;
Expand All @@ -17,6 +18,7 @@
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskProvider;

import javax.inject.Inject;
Expand All @@ -26,6 +28,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -321,9 +324,47 @@ public void forLocalFeature(SourceSet sourceSet) {
});
}

private static final List<String> INSTALLATION_CONFIGURATION_NAMES = List.of(
"AccessTransformers",
"AccessTransformersApi",
"InterfaceInjections",
"InterfaceInjectionsApi"
);

protected List<String> getInstallationConfigurationNames() {
return INSTALLATION_CONFIGURATION_NAMES;
}

private void forFeatureShared(FeatureUtils.Context context) {
context.withCapabilities(accessTransformersElements.get());
context.withCapabilities(injectedInterfacesElements.get());

var project = crochetExtension.project;
var sourceSet = context.getSourceSet();
// Link up inheritance via CrochetFeatureContexts for the injected configurations
var marker = InheritanceMarker.getOrCreate(project.getObjects(), sourceSet);
marker.getShouldTakeConfigurationsFrom().configureEach(name -> {
var otherSourceSet = project.getExtensions().getByType(SourceSetContainer.class).findByName(name);
var otherInstallation = crochetExtension.findInstallation(otherSourceSet);
if (otherInstallation != this && otherInstallation != null) {
for (var confName : getInstallationConfigurationNames()) {
var thisConf = project.getConfigurations().getByName(this.name + confName);
var otherConf = project.getConfigurations().getByName(otherInstallation.name + confName);
thisConf.extendsFrom(otherConf);
}
}
});
marker.getShouldGiveConfigurationsTo().configureEach(name -> {
var otherSourceSet = project.getExtensions().getByType(SourceSetContainer.class).findByName(name);
var otherInstallation = crochetExtension.findInstallation(otherSourceSet);
if (otherInstallation != this && otherInstallation != null) {
for (var confName : getInstallationConfigurationNames()) {
var thisConf = project.getConfigurations().getByName(this.name + confName);
var otherConf = project.getConfigurations().getByName(otherInstallation.name + confName);
otherConf.extendsFrom(thisConf);
}
}
});
}

protected final AbstractInstallationDependencies dependencies;
Expand Down

0 comments on commit ad5c6b6

Please sign in to comment.