Skip to content

Commit

Permalink
Allow chained expose(consume(...)) syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Apr 21, 2024
1 parent 91d139e commit ef24cc9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ConfigurablePublishArtifact;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.dsl.ArtifactHandler;
import org.gradle.api.artifacts.dsl.DependencyHandler;

Expand All @@ -24,22 +25,28 @@ public AccessTransformersExtension(Project project) {
}

@Override
public void consume(Object notation) {
this.projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_CONFIGURATION, notation);
public Dependency consume(Object notation) {
return this.projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_CONFIGURATION, notation);
}

@Override
public void consumeApi(Object notation) {
this.projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_API_CONFIGURATION, notation);
public Dependency consumeApi(Object notation) {
return this.projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_API_CONFIGURATION, notation);
}

@Override
public void expose(Object path, Action<ConfigurablePublishArtifact> action) {
file(path);
projectArtifacts.add(CommonProjectPlugin.ACCESS_TRANSFORMER_ELEMENTS_CONFIGURATION, path, action);
}

@Override
public void expose(Object path) {
expose(path, artifacts -> {});
}

@Override
public void expose(Dependency dependency) {
projectDependencies.add(CommonProjectPlugin.ACCESS_TRANSFORMER_API_CONFIGURATION, dependency);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import groovy.transform.CompileStatic
import net.minecraftforge.gdi.BaseDSLElementWithFilesAndEntries
import org.gradle.api.Action
import org.gradle.api.artifacts.ConfigurablePublishArtifact
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.dsl.DependencyCollector

/**
* Defines a DSL extension which allows for the specification of access transformers.
*/
@CompileStatic
interface AccessTransformers extends BaseDSLElementWithFilesAndEntries<AccessTransformers> {
void consume(Object notation)
Dependency consume(Object notation)

void consumeApi(Object notation)
Dependency consumeApi(Object notation)

void expose(Dependency dependency)

void expose(Object path)

Expand Down

0 comments on commit ef24cc9

Please sign in to comment.