| @@ -0,0 +1,14 | |||
|
|
1 | package org.implab.gradle.variants.internal; | |
|
|
2 | ||
|
|
3 | import org.gradle.api.Named; | |
|
|
4 | import org.gradle.api.NamedDomainObjectContainer; | |
|
|
5 | import org.gradle.api.model.ObjectFactory; | |
|
|
6 | ||
|
|
7 | public final class IdentityContainerFactory { | |
|
|
8 | private IdentityContainerFactory() { | |
|
|
9 | } | |
|
|
10 | ||
|
|
11 | public static <T extends Named> NamedDomainObjectContainer<T> create(ObjectFactory objectFactory, Class<T> type) { | |
|
|
12 | return objectFactory.domainObjectContainer(type, name -> objectFactory.named(type, name)); | |
|
|
13 | } | |
|
|
14 | } | |
| @@ -0,0 +1,7 | |||
|
|
1 | /** | |
|
|
2 | * Internal implementation utilities of the variants module. | |
|
|
3 | * | |
|
|
4 | * <p>Types in this package are not part of the public API. They may change, | |
|
|
5 | * move, or be removed without compatibility guarantees. | |
|
|
6 | */ | |
|
|
7 | package org.implab.gradle.variants.internal; | |
| @@ -0,0 +1,9 | |||
|
|
1 | /** | |
|
|
2 | * Internal implementation of the variant sources plugin. | |
|
|
3 | * | |
|
|
4 | * <p>Types in this package are not part of the public API. They may change, | |
|
|
5 | * move, or be removed without compatibility guarantees. Build logic should use | |
|
|
6 | * the public contracts from {@link org.implab.gradle.variants.sources} | |
|
|
7 | * instead. | |
|
|
8 | */ | |
|
|
9 | package org.implab.gradle.variants.sources.internal; | |
| @@ -36,6 +36,10 test { | |||
|
|
36 | 36 | useJUnitPlatform() |
|
|
37 | 37 | } |
|
|
38 | 38 | |
|
|
39 | javadoc { | |
|
|
40 | exclude "**/internal/**" | |
|
|
41 | } | |
|
|
42 | ||
|
|
39 | 43 | publishing { |
|
|
40 | 44 | repositories { |
|
|
41 | 45 | ivy { |
| @@ -58,7 +58,7 public abstract class VariantArtifactsPl | |||
|
|
58 | 58 | // apply materialization policy hooks to outgoing variants |
|
|
59 | 59 | outgoing.configureEach(materializationHandler::execute); |
|
|
60 | 60 | |
|
|
61 |
sourcesExtension.when |
|
|
|
61 | sourcesExtension.whenAvailable(sources -> { | |
|
|
62 | 62 | var assemblyHandler = new ArtifactAssemblyHandler( |
|
|
63 | 63 | objects, |
|
|
64 | 64 | tasks, |
| @@ -77,7 +77,7 public abstract class VariantSourcesPlug | |||
|
|
77 | 77 | |
|
|
78 | 78 | var variantSourcesExtension = new VariantSourcesExtension() { |
|
|
79 | 79 | @Override |
|
|
80 |
public void when |
|
|
|
80 | public void whenAvailable(Action<? super VariantSourcesContext> action) { | |
|
|
81 | 81 | deferred.whenResolved(action::execute); |
|
|
82 | 82 | } |
|
|
83 | 83 | |
| @@ -98,7 +98,7 public abstract class VariantSourcesPlug | |||
|
|
98 | 98 | |
|
|
99 | 99 | lateConfigurationPolicy.finalizePolicy(); |
|
|
100 | 100 | |
|
|
101 |
when |
|
|
|
101 | whenAvailable(ctx -> ctx.configureVariant(resolveVariant(ctx.getVariants(), variantName), action)); | |
|
|
102 | 102 | } |
|
|
103 | 103 | |
|
|
104 | 104 | @Override |
| @@ -109,7 +109,7 public abstract class VariantSourcesPlug | |||
|
|
109 | 109 | |
|
|
110 | 110 | lateConfigurationPolicy.finalizePolicy(); |
|
|
111 | 111 | |
|
|
112 |
when |
|
|
|
112 | whenAvailable(ctx -> ctx.configureLayer(resolveLayer(ctx.getVariants(), layerName), action)); | |
|
|
113 | 113 | } |
|
|
114 | 114 | |
|
|
115 | 115 | @Override |
| @@ -120,7 +120,7 public abstract class VariantSourcesPlug | |||
|
|
120 | 120 | |
|
|
121 | 121 | lateConfigurationPolicy.finalizePolicy(); |
|
|
122 | 122 | |
|
|
123 |
when |
|
|
|
123 | whenAvailable(ctx -> ctx.configureUnit(resolveCompileUnit(ctx, variantName, layerName), action)); | |
|
|
124 | 124 | } |
|
|
125 | 125 | }; |
|
|
126 | 126 | |
| @@ -6,13 +6,13 import org.gradle.api.Plugin; | |||
|
|
6 | 6 | import org.gradle.api.Project; |
|
|
7 | 7 | import org.gradle.api.model.ObjectFactory; |
|
|
8 | 8 | import org.implab.gradle.common.core.lang.Deferred; |
|
|
9 | import org.implab.gradle.internal.IdentityContainerFactory; | |
|
|
10 | 9 | import org.implab.gradle.variants.core.Layer; |
|
|
11 | 10 | import org.implab.gradle.variants.core.Role; |
|
|
12 | 11 | import org.implab.gradle.variants.core.Variant; |
|
|
13 | 12 | import org.implab.gradle.variants.core.VariantDefinition; |
|
|
14 | 13 | import org.implab.gradle.variants.core.VariantsExtension; |
|
|
15 | 14 | import org.implab.gradle.variants.core.VariantsView; |
|
|
15 | import org.implab.gradle.variants.internal.IdentityContainerFactory; | |
|
|
16 | 16 | |
|
|
17 | 17 | /** |
|
|
18 | 18 | * <ul> |
| @@ -14,11 +14,11 import org.gradle.api.artifacts.Configur | |||
|
|
14 | 14 | import org.gradle.api.artifacts.ConfigurationContainer; |
|
|
15 | 15 | import org.gradle.api.model.ObjectFactory; |
|
|
16 | 16 | import org.gradle.api.provider.Property; |
|
|
17 | import org.implab.gradle.internal.IdentityContainerFactory; | |
|
|
18 | 17 | import org.implab.gradle.common.core.lang.ReplayableQueue; |
|
|
19 | 18 | import org.implab.gradle.variants.artifacts.OutgoingVariant; |
|
|
20 | 19 | import org.implab.gradle.variants.artifacts.Slot; |
|
|
21 | 20 | import org.implab.gradle.variants.core.Variant; |
|
|
21 | import org.implab.gradle.variants.internal.IdentityContainerFactory; | |
|
|
22 | 22 | |
|
|
23 | 23 | /** |
|
|
24 | 24 | * Registry of variant-level outgoing models. |
| @@ -17,9 +17,9 public interface VariantSourcesExtension | |||
|
|
17 | 17 | * <li>it must be selected before the first selector rule is registered via |
|
|
18 | 18 | * {@link #variant(String, Action)}, {@link #layer(String, Action)} or |
|
|
19 | 19 | * {@link #unit(String, String, Action)};</li> |
|
|
20 |
* <li>it must be selected before the |
|
|
|
21 |
* {@link #when |
|
|
|
22 |
* <li>once selected or once |
|
|
|
20 | * <li>it must be selected before the source context becomes observable via | |
|
|
21 | * {@link #whenAvailable(Action)};</li> | |
|
|
22 | * <li>once selected or once source context creation begins, it cannot | |
|
|
23 | 23 | * be changed later;</li> |
|
|
24 | 24 | * <li>the policy controls both diagnostics and late-application semantics.</li> |
|
|
25 | 25 | * </ul> |
| @@ -34,14 +34,14 public interface VariantSourcesExtension | |||
|
|
34 | 34 | } |
|
|
35 | 35 | |
|
|
36 | 36 | /** |
|
|
37 |
* Selects how compile-unit name collisions are handled when the |
|
|
|
38 | * source context is created. | |
|
|
37 | * Selects how compile-unit name collisions are handled when the source | |
|
|
38 | * context is created from the finalized variant model. | |
|
|
39 | 39 | * |
|
|
40 | 40 | * <p>This policy is single-valued: |
|
|
41 | 41 | * <ul> |
|
|
42 | 42 | * <li>it must be selected before the finalized |
|
|
43 | 43 | * {@link VariantSourcesContext} becomes observable through |
|
|
44 |
* {@link #when |
|
|
|
44 | * {@link #whenAvailable(Action)};</li> | |
|
|
45 | 45 | * <li>once the context is being created, the policy is fixed and cannot be |
|
|
46 | 46 | * changed later;</li> |
|
|
47 | 47 | * <li>the policy governs validation of compile-unit names produced by the |
| @@ -97,7 +97,7 public interface VariantSourcesExtension | |||
|
|
97 | 97 | } |
|
|
98 | 98 | |
|
|
99 | 99 | /** |
|
|
100 |
* Invoked when |
|
|
|
100 | * Invoked when the variants-derived source context becomes available. | |
|
|
101 | 101 | * |
|
|
102 | 102 | * Replayable: |
|
|
103 | 103 | * <ul> |
| @@ -109,10 +109,10 public interface VariantSourcesExtension | |||
|
|
109 | 109 | * policy has already been fixed and symbolic source-set names for finalized |
|
|
110 | 110 | * compile units are determined. |
|
|
111 | 111 | */ |
|
|
112 |
void when |
|
|
|
112 | void whenAvailable(Action<? super VariantSourcesContext> action); | |
|
|
113 | 113 | |
|
|
114 |
default void when |
|
|
|
115 |
when |
|
|
|
114 | default void whenAvailable(Closure<?> closure) { | |
|
|
115 | whenAvailable(Closures.action(closure)); | |
|
|
116 | 116 | } |
|
|
117 | 117 | |
|
|
118 | 118 | |
| @@ -26,7 +26,7 class VariantSourcesPluginFunctionalTest | |||
|
|
26 | 26 | |
|
|
27 | 27 | def lines = [] |
|
|
28 | 28 | |
|
|
29 |
variantSources.when |
|
|
|
29 | variantSources.whenAvailable { ctx -> | |
|
|
30 | 30 | lines << "units=" + ctx.compileUnits.units |
|
|
31 | 31 | .collect { "${it.variant().name}:${it.layer().name}" } |
|
|
32 | 32 | .sort() |
| @@ -50,7 +50,7 class VariantSourcesPluginFunctionalTest | |||
|
|
50 | 50 | } |
|
|
51 | 51 | |
|
|
52 | 52 | afterEvaluate { |
|
|
53 |
variantSources.when |
|
|
|
53 | variantSources.whenAvailable { ctx -> | |
|
|
54 | 54 | lines << "late:variants=" + ctx.variants.variants.collect { it.name }.sort().join(',') |
|
|
55 | 55 | } |
|
|
56 | 56 | } |
| @@ -107,7 +107,7 class VariantSourcesPluginFunctionalTest | |||
|
|
107 | 107 | } |
|
|
108 | 108 | |
|
|
109 | 109 | afterEvaluate { |
|
|
110 |
variantSources.when |
|
|
|
110 | variantSources.whenAvailable { ctx -> | |
|
|
111 | 111 | def browser = ctx.variants.variants.find { it.name == 'browser' } |
|
|
112 | 112 | def node = ctx.variants.variants.find { it.name == 'node' } |
|
|
113 | 113 | def mainLayer = ctx.variants.layers.find { it.name == 'main' } |
| @@ -146,7 +146,7 class VariantSourcesPluginFunctionalTest | |||
|
|
146 | 146 | } |
|
|
147 | 147 | |
|
|
148 | 148 | afterEvaluate { |
|
|
149 |
variantSources.when |
|
|
|
149 | variantSources.whenAvailable { ctx -> | |
|
|
150 | 150 | def browser = ctx.variants.variants.find { it.name == 'browser' } |
|
|
151 | 151 | def mainLayer = ctx.variants.layers.find { it.name == 'main' } |
|
|
152 | 152 | def unit = ctx.compileUnits.requireUnit(browser, mainLayer) |
| @@ -182,7 +182,7 class VariantSourcesPluginFunctionalTest | |||
|
|
182 | 182 | } |
|
|
183 | 183 | |
|
|
184 | 184 | afterEvaluate { |
|
|
185 |
variantSources.when |
|
|
|
185 | variantSources.whenAvailable { ctx -> | |
|
|
186 | 186 | def browser = ctx.variants.variants.find { it.name == 'browser' } |
|
|
187 | 187 | def mainLayer = ctx.variants.layers.find { it.name == 'main' } |
|
|
188 | 188 | def unit = ctx.compileUnits.requireUnit(browser, mainLayer) |
| @@ -221,7 +221,7 class VariantSourcesPluginFunctionalTest | |||
|
|
221 | 221 | } |
|
|
222 | 222 | |
|
|
223 | 223 | afterEvaluate { |
|
|
224 |
variantSources.when |
|
|
|
224 | variantSources.whenAvailable { ctx -> | |
|
|
225 | 225 | def browser = ctx.variants.variants.find { it.name == 'browser' } |
|
|
226 | 226 | def mainLayer = ctx.variants.layers.find { it.name == 'main' } |
|
|
227 | 227 | def unit = ctx.compileUnits.requireUnit(browser, mainLayer) |
| @@ -315,7 +315,7 class VariantSourcesPluginFunctionalTest | |||
|
|
315 | 315 | } |
|
|
316 | 316 | |
|
|
317 | 317 | afterEvaluate { |
|
|
318 |
variantSources.when |
|
|
|
318 | variantSources.whenAvailable { ctx -> | |
|
|
319 | 319 | def foo = ctx.variants.variants.find { it.name == 'foo' } |
|
|
320 | 320 | def fooVariant = ctx.variants.variants.find { it.name == 'fooVariant' } |
|
|
321 | 321 | def variantBar = ctx.variants.layers.find { it.name == 'variantBar' } |
| @@ -419,7 +419,7 class VariantSourcesPluginFunctionalTest | |||
|
|
419 | 419 | role('production') { layers('main') } |
|
|
420 | 420 | } |
|
|
421 | 421 | |
|
|
422 |
variantSources.when |
|
|
|
422 | variantSources.whenAvailable { | |
|
|
423 | 423 | variantSources.namingPolicy { |
|
|
424 | 424 | resolveNameCollision() |
|
|
425 | 425 | } |
| @@ -442,7 +442,7 class VariantSourcesPluginFunctionalTest | |||
|
|
442 | 442 | role('production') { layers('main') } |
|
|
443 | 443 | } |
|
|
444 | 444 | |
|
|
445 |
variantSources.when |
|
|
|
445 | variantSources.whenAvailable { | |
|
|
446 | 446 | variantSources.lateConfigurationPolicy { |
|
|
447 | 447 | allowLateConfiguration() |
|
|
448 | 448 | } |
|
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now
