44 */
55package net .minecraftforge .accesstransformers .gradle ;
66
7- import groovy .lang .Closure ;
8- import groovy .lang .DelegatesTo ;
9- import groovy .transform .stc .ClosureParams ;
10- import groovy .transform .stc .SimpleType ;
11- import net .minecraftforge .gradleutils .shared .Closures ;
127import org .gradle .api .Action ;
138import org .gradle .api .Project ;
149import org .gradle .api .artifacts .Dependency ;
15- import org .gradle .api .attributes .Attribute ;
10+ import org .gradle .api .attributes .HasConfigurableAttributes ;
1611import org .gradle .api .file .ConfigurableFileCollection ;
1712import org .gradle .api .file .FileCollection ;
18- import org .gradle .api .file .RegularFileProperty ;
1913import org .gradle .api .logging .LogLevel ;
2014import org .gradle .api .provider .ListProperty ;
2115import org .gradle .api .provider .Property ;
22- import org .gradle .api .provider .Provider ;
23- import org .gradle .api .provider .ProviderConvertible ;
2416import org .gradle .jvm .toolchain .JavaLauncher ;
2517import org .jetbrains .annotations .ApiStatus ;
2618
27- import java .util .function .UnaryOperator ;
28-
2919/// Represents a container of dependencies that will be access transformed.
3020///
31- /// Containers are created with [AccessTransformersExtension#register(Attribute, Action)]. Dependencies can be added
32- /// using [#dep(Object, Closure )].
21+ /// Containers are created with [AccessTransformersExtension#register(Action)]. Dependencies can be registered to it
22+ /// inside their configuring closures using [#configure(Dependency )].
3323///
3424/// @apiNote This interface is effectively sealed and [must not be extended][ApiStatus.NonExtendable].
3525/// @see AccessTransformersExtension
3626public sealed interface AccessTransformersContainer permits AccessTransformersContainerInternal , AccessTransformersExtension {
3727 /// Registers a new container using the given attribute and options.
3828 ///
39- /// @param project The project to make the container for
40- /// @param attribute The boolean attribute to use for this container
41- /// @param options The options to apply
29+ /// @param project The project to make the container for]
30+ /// @param options The options to apply
4231 /// @return The registered container
4332 /// @see AccessTransformersContainer.Options
44- static AccessTransformersContainer register (Project project , Attribute < Boolean > attribute , Action <? super AccessTransformersContainer .Options > options ) {
45- return AccessTransformersContainerInternal .register (project , attribute , options );
33+ static AccessTransformersContainer register (Project project , Action <? super AccessTransformersContainer .Options > options ) {
34+ return AccessTransformersContainerInternal .register (project , options );
4635 }
4736
48- /// Gets the attribute used by the [transformer][ArtifactAccessTransformer]. It must be unique to this container.
49- ///
50- /// @return The attribute
51- /// @see <a href="https://docs.gradle.org/current/userguide/artifact_transforms.html">Artifact Transforms</a>
52- Attribute <Boolean > getAttribute ();
53-
5437 /// Gets the access transformer options.
5538 ///
5639 /// @return The options
@@ -65,103 +48,22 @@ default void options(Action<? super AccessTransformersContainer.Options> action)
6548 action .execute (this .getOptions ());
6649 }
6750
68- /// Queues the given dependency to be transformed by AccessTransformers.
51+ /// Configures the given dependency to use this AccessTransformers container .
6952 ///
70- /// @param dependencyNotation The dependency (notation)
71- /// @param closure A configuring closure for the dependency
72- /// @return The dependency to be transformed
73- Dependency dep (
74- Object dependencyNotation ,
75- @ DelegatesTo (Dependency .class )
76- @ ClosureParams (value = SimpleType .class , options = "org.gradle.api.artifacts.Dependency" )
77- Closure <?> closure
78- );
79-
80- /// Queues the given dependency to be transformed by AccessTransformers.
81- ///
82- /// @param dependencyNotation The dependency (notation)
83- /// @param action A configuring action for the dependency
84- /// @return The dependency to be transformed
85- default Dependency dep (Object dependencyNotation , Action <? super Dependency > action ) {
86- return this .dep (dependencyNotation , Closures .action (this , action ));
53+ /// @param dependency The dependency to configure AccessTransformers for
54+ default void configure (Dependency dependency ) {
55+ this .configure (dependency , it -> { });
8756 }
8857
89- /// Queues the given dependency to be transformed by AccessTransformers.
58+ /// Configures the given dependency to use this AccessTransformers container .
9059 ///
91- /// @param dependencyNotation The dependency (notation)
92- /// @return The dependency to be transformed
93- default Dependency dep (Object dependencyNotation ) {
94- return this .dep (dependencyNotation , Closures .<Dependency >unaryOperator (this , UnaryOperator .identity ()));
95- }
60+ /// @param dependency The dependency to configure AccessTransformers for
61+ /// @param action A configuring action to modify dependency-level AccessTransformer options
62+ void configure (Dependency dependency , Action <? super AccessTransformersConfiguration > action );
9663
97- /// Queues the given dependency to be transformed by AccessTransformers.
98- ///
99- /// @param dependencyNotation The dependency (notation)
100- /// @param closure A configuring closure for the dependency
101- /// @return The dependency to be transformed
102- Provider <?> dep (
103- Provider <?> dependencyNotation ,
104- @ DelegatesTo (Dependency .class )
105- @ ClosureParams (value = SimpleType .class , options = "org.gradle.api.artifacts.Dependency" )
106- Closure <?> closure
107- );
108-
109- /// Queues the given dependency to be transformed by AccessTransformers.
110- ///
111- /// @param dependencyNotation The dependency (notation)
112- /// @param action A configuring action for the dependency
113- /// @return The dependency to be transformed
114- default Provider <?> dep (Provider <?> dependencyNotation , Action <? super Dependency > action ) {
115- return this .dep (dependencyNotation , Closures .action (this , action ));
116- }
117-
118- /// Queues the given dependency to be transformed by AccessTransformers.
119- ///
120- /// @param dependencyNotation The dependency (notation)
121- /// @return The dependency to be transformed
122- default Provider <?> dep (Provider <?> dependencyNotation ) {
123- return this .dep (dependencyNotation , Closures .<Dependency >unaryOperator (this , UnaryOperator .identity ()));
124- }
125-
126- /// Queues the given dependency to be transformed by AccessTransformers.
127- ///
128- /// @param dependencyNotation The dependency (notation)
129- /// @param closure A configuring closure for the dependency
130- /// @return The dependency to be transformed
131- default Provider <?> dep (
132- ProviderConvertible <?> dependencyNotation ,
133- @ DelegatesTo (Dependency .class )
134- @ ClosureParams (value = SimpleType .class , options = "org.gradle.api.artifacts.Dependency" )
135- Closure <?> closure
136- ) {
137- return this .dep (dependencyNotation .asProvider (), closure );
138- }
139-
140- /// Queues the given dependency to be transformed by AccessTransformers.
141- ///
142- /// @param dependencyNotation The dependency (notation)
143- /// @param action A configuring action for the dependency
144- /// @return The dependency to be transformed
145- default Provider <?> dep (ProviderConvertible <?> dependencyNotation , Action <? super Dependency > action ) {
146- return this .dep (dependencyNotation , Closures .action (this , action ));
147- }
148-
149- /// Queues the given dependency to be transformed by AccessTransformers.
150- ///
151- /// @param dependencyNotation The dependency (notation)
152- /// @return The dependency to be transformed
153- default Provider <?> dep (ProviderConvertible <?> dependencyNotation ) {
154- return this .dep (dependencyNotation , Closures .<Dependency >unaryOperator (this , UnaryOperator .identity ()));
155- }
156-
157- /// When initially registering an AccessTransformers container, the consumer must define key information regarding
64+ /// When initially registering an AccessTransformers container, the consumer should define key information regarding
15865 /// how AccessTransformers will be used. This interface is used to define that information.
159- sealed interface Options permits AccessTransformersContainerInternal .Options {
160- /// Gets the AccessTransformer configuration to use.
161- ///
162- /// @return The property for the configuration
163- RegularFileProperty getConfig ();
164-
66+ sealed interface Options extends AccessTransformersConfiguration permits AccessTransformersContainerInternal .Options {
16567 /// Gets the log level to pipe the output of AccessTransformers to.
16668 ///
16769 /// @return The property log level to use
0 commit comments