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