##// END OF EJS Templates
variants: expose compile unit source set specs...
cin -
r58:a4138749793f default
parent child
Show More
@@ -0,0 +1,69
1 package org.implab.gradle.variants.sources;
2
3 import org.gradle.api.Action;
4 import org.implab.gradle.common.core.lang.Closures;
5 import org.implab.gradle.variants.core.Layer;
6 import org.implab.gradle.variants.core.Variant;
7
8 import groovy.lang.Closure;
9
10 /**
11 * Source-set materialization context for one compile unit.
12 *
13 * <p>This type keeps compile-unit identity next to the materialized
14 * {@link GenericSourceSet} without turning the selector DSL into a second
15 * source-set API. Use {@link #getCompileUnit()} for selection metadata and
16 * {@link #sourceSet(Action)} when the underlying source set body must be
17 * configured.
18 */
19 public interface CompileUnitSourceSetSpec {
20 /**
21 * Returns the compile unit represented by this source set.
22 *
23 * @return compile-unit identity
24 */
25 CompileUnit getCompileUnit();
26
27 /**
28 * Returns the variant part of the compile-unit identity.
29 *
30 * @return variant identity
31 */
32 default Variant getVariant() {
33 return getCompileUnit().variant();
34 }
35
36 /**
37 * Returns the layer part of the compile-unit identity.
38 *
39 * @return layer identity
40 */
41 default Layer getLayer() {
42 return getCompileUnit().layer();
43 }
44
45 /**
46 * Returns the materialized source set body.
47 *
48 * @return source set body
49 */
50 GenericSourceSet getSourceSet();
51
52 /**
53 * Configures the materialized source set body.
54 *
55 * @param action source set configuration action
56 */
57 default void sourceSet(Action<? super GenericSourceSet> action) {
58 action.execute(getSourceSet());
59 }
60
61 /**
62 * Configures the materialized source set body.
63 *
64 * @param closure source set configuration closure
65 */
66 default void sourceSet(Closure<?> closure) {
67 sourceSet(Closures.action(closure));
68 }
69 }
@@ -0,0 +1,25
1 package org.implab.gradle.variants.sources.internal;
2
3 import org.implab.gradle.variants.sources.CompileUnit;
4 import org.implab.gradle.variants.sources.CompileUnitSourceSetSpec;
5 import org.implab.gradle.variants.sources.GenericSourceSet;
6
7 class DefaultCompileUnitSourceSetSpec implements CompileUnitSourceSetSpec {
8 private final CompileUnit compileUnit;
9 private final GenericSourceSet sourceSet;
10
11 DefaultCompileUnitSourceSetSpec(CompileUnit compileUnit, GenericSourceSet sourceSet) {
12 this.compileUnit = compileUnit;
13 this.sourceSet = sourceSet;
14 }
15
16 @Override
17 public CompileUnit getCompileUnit() {
18 return compileUnit;
19 }
20
21 @Override
22 public GenericSourceSet getSourceSet() {
23 return sourceSet;
24 }
25 }
@@ -16,8 +16,8 import org.implab.gradle.variants.core.V
16 16 import org.implab.gradle.variants.core.VariantsExtension;
17 17 import org.implab.gradle.variants.core.VariantsView;
18 18 import org.implab.gradle.variants.sources.CompileUnit;
19 import org.implab.gradle.variants.sources.CompileUnitSourceSetSpec;
19 20 import org.implab.gradle.variants.sources.CompileUnitsView;
20 import org.implab.gradle.variants.sources.GenericSourceSet;
21 21 import org.implab.gradle.variants.sources.RoleProjectionsView;
22 22 import org.implab.gradle.variants.sources.VariantSourcesContext;
23 23 import org.implab.gradle.variants.sources.VariantSourcesExtension;
@@ -92,7 +92,7 public abstract class VariantSourcesPlug
92 92 }
93 93
94 94 @Override
95 public void variant(String variantName, Action<? super GenericSourceSet> action) {
95 public void variant(String variantName, Action<? super CompileUnitSourceSetSpec> action) {
96 96 Strings.argumentNotNullOrBlank(variantName, "variantName");
97 97 Objects.requireNonNull(action, "action can't be null");
98 98
@@ -102,7 +102,7 public abstract class VariantSourcesPlug
102 102 }
103 103
104 104 @Override
105 public void layer(String layerName, Action<? super GenericSourceSet> action) {
105 public void layer(String layerName, Action<? super CompileUnitSourceSetSpec> action) {
106 106 // protect external DSL
107 107 Strings.argumentNotNullOrBlank(layerName, "layerName");
108 108 Objects.requireNonNull(action, "action can't be null");
@@ -113,7 +113,7 public abstract class VariantSourcesPlug
113 113 }
114 114
115 115 @Override
116 public void unit(String variantName, String layerName, Action<? super GenericSourceSet> action) {
116 public void unit(String variantName, String layerName, Action<? super CompileUnitSourceSetSpec> action) {
117 117 Strings.argumentNotNullOrBlank(layerName, "layerName");
118 118 Strings.argumentNotNullOrBlank(variantName, "variantName");
119 119 Objects.requireNonNull(action, "action can't be null");
@@ -122,6 +122,15 public abstract class VariantSourcesPlug
122 122
123 123 whenAvailable(ctx -> ctx.configureUnit(resolveCompileUnit(ctx, variantName, layerName), action));
124 124 }
125
126 @Override
127 public void configureEach(Action<? super CompileUnitSourceSetSpec> action) {
128 Objects.requireNonNull(action, "action can't be null");
129
130 lateConfigurationPolicy.finalizePolicy();
131
132 whenAvailable(ctx -> ctx.configureEach(action));
133 }
125 134 };
126 135
127 136 extensions.add(VariantSourcesExtension.class, VARIANT_SOURCES_EXTENSION, variantSourcesExtension);
@@ -26,10 +26,6 import org.gradle.api.file.ProjectLayout
26 26 import org.gradle.api.file.SourceDirectorySet;
27 27 import org.gradle.api.model.ObjectFactory;
28 28 import org.gradle.api.tasks.TaskProvider;
29 import org.gradle.util.Configurable;
30 import org.implab.gradle.common.core.lang.Closures;
31
32 import groovy.lang.Closure;
33 29
34 30 /**
35 31 * A configurable source set abstraction with named outputs.
@@ -50,8 +46,7 import groovy.lang.Closure;
50 46 * {@link InvalidUserDataException}.
51 47 * </p>
52 48 */
53 public abstract class GenericSourceSet
54 implements Named, Configurable<GenericSourceSet> {
49 public abstract class GenericSourceSet implements Named {
55 50 private final String name;
56 51
57 52 private final NamedDomainObjectContainer<SourceDirectorySet> sourceDirectorySets;
@@ -172,16 +167,6 public abstract class GenericSourceSet
172 167 .builtBy(task);
173 168 }
174 169
175 /**
176 * Applies a Groovy closure to this source set, enabling DSL-style
177 * configuration.
178 */
179 @Override
180 public GenericSourceSet configure(Closure configure) {
181 Closures.apply(configure, this);
182 return this;
183 }
184
185 170 private SourceDirectorySet createSourceDirectorySet(String name) {
186 171 return objects.sourceDirectorySet(name, name);
187 172 }
@@ -35,7 +35,7 public interface VariantSourcesContext {
35 35 SourceSetMaterializer getSourceSets();
36 36
37 37 /**
38 * Configures all GenericSourceSets produced from the given layer.
38 * Configures all source sets produced from the given layer.
39 39 *
40 40 * The action is applied:
41 41 * - to already materialized source sets of this layer
@@ -52,10 +52,10 public interface VariantSourcesContext {
52 52 * @throws org.gradle.api.InvalidUserDataException if the layer is not part of
53 53 * the finalized variant model
54 54 */
55 void configureLayer(Layer layer, Action<? super GenericSourceSet> action);
55 void configureLayer(Layer layer, Action<? super CompileUnitSourceSetSpec> action);
56 56
57 57 /**
58 * Configures all GenericSourceSets produced from the given variant.
58 * Configures all source sets produced from the given variant.
59 59 *
60 60 * <p>Late application semantics for already materialized source sets are
61 61 * governed by
@@ -64,10 +64,10 public interface VariantSourcesContext {
64 64 * @throws org.gradle.api.InvalidUserDataException if the variant is not part
65 65 * of the finalized variant model
66 66 */
67 void configureVariant(Variant variant, Action<? super GenericSourceSet> action);
67 void configureVariant(Variant variant, Action<? super CompileUnitSourceSetSpec> action);
68 68
69 69 /**
70 * Configures the GenericSourceSet produced from the given compile unit.
70 * Configures the source set produced from the given compile unit.
71 71 *
72 72 * <p>Late application semantics for already materialized source sets are
73 73 * governed by
@@ -76,6 +76,18 public interface VariantSourcesContext {
76 76 * @throws org.gradle.api.InvalidUserDataException if the compile unit is not
77 77 * part of the finalized variant model
78 78 */
79 void configureUnit(CompileUnit unit, Action<? super GenericSourceSet> action);
79 void configureUnit(CompileUnit unit, Action<? super CompileUnitSourceSetSpec> action);
80
81 /**
82 * Configures every source set materialized from the finalized compile-unit
83 * model.
84 *
85 * <p>This selector is applied before variant-, layer-, and unit-specific
86 * selectors.
87 *
88 * @throws org.gradle.api.InvalidUserDataException if late configuration is
89 * rejected by the selected policy
90 */
91 void configureEach(Action<? super CompileUnitSourceSetSpec> action);
80 92
81 93 }
@@ -10,7 +10,7 public interface VariantSourcesExtension
10 10
11 11 /**
12 12 * Selects how selector rules behave when they target an already materialized
13 * {@link GenericSourceSet}.
13 * source set.
14 14 *
15 15 * <p>This policy is single-valued:
16 16 * <ul>
@@ -64,7 +64,7 public interface VariantSourcesExtension
64 64 * {@link #lateConfigurationPolicy(Action)} for the remaining extension
65 65 * lifecycle.
66 66 */
67 void layer(String layerName, Action<? super GenericSourceSet> action);
67 void layer(String layerName, Action<? super CompileUnitSourceSetSpec> action);
68 68
69 69 default void layer(String layerName, Closure<?> closure) {
70 70 layer(layerName, Closures.action(closure));
@@ -77,7 +77,7 public interface VariantSourcesExtension
77 77 * {@link #lateConfigurationPolicy(Action)} for the remaining extension
78 78 * lifecycle.
79 79 */
80 void variant(String variantName, Action<? super GenericSourceSet> action);
80 void variant(String variantName, Action<? super CompileUnitSourceSetSpec> action);
81 81
82 82 default void variant(String variantName, Closure<?> closure) {
83 83 variant(variantName, Closures.action(closure));
@@ -90,13 +90,27 public interface VariantSourcesExtension
90 90 * {@link #lateConfigurationPolicy(Action)} for the remaining extension
91 91 * lifecycle.
92 92 */
93 void unit(String variantName, String layerName, Action<? super GenericSourceSet> action);
93 void unit(String variantName, String layerName, Action<? super CompileUnitSourceSetSpec> action);
94 94
95 95 default void unit(String variantName, String layerName, Closure<?> closure) {
96 96 unit(variantName, layerName, Closures.action(closure));
97 97 }
98 98
99 99 /**
100 * Registers a selector rule for every materialized compile-unit source set.
101 *
102 * <p>Registering the first selector rule fixes the selected
103 * {@link #lateConfigurationPolicy(Action)} for the remaining extension
104 * lifecycle. This selector is applied before variant-, layer-, and unit-specific
105 * selectors.
106 */
107 void configureEach(Action<? super CompileUnitSourceSetSpec> action);
108
109 default void configureEach(Closure<?> closure) {
110 configureEach(Closures.action(closure));
111 }
112
113 /**
100 114 * Invoked when the variants-derived source context becomes available.
101 115 *
102 116 * Replayable:
@@ -9,6 +9,7 import org.implab.gradle.variants.core.L
9 9 import org.implab.gradle.variants.core.Variant;
10 10 import org.implab.gradle.variants.core.VariantsView;
11 11 import org.implab.gradle.variants.sources.CompileUnit;
12 import org.implab.gradle.variants.sources.CompileUnitSourceSetSpec;
12 13 import org.implab.gradle.variants.sources.CompileUnitsView;
13 14 import org.implab.gradle.variants.sources.GenericSourceSet;
14 15 import org.implab.gradle.variants.sources.RoleProjectionsView;
@@ -62,26 +63,32 public class DefaultVariantSourcesContex
62 63 }
63 64
64 65 @Override
65 public void configureLayer(Layer layer, Action<? super GenericSourceSet> action) {
66 public void configureLayer(Layer layer, Action<? super CompileUnitSourceSetSpec> action) {
66 67 variantsView.assertLayer(layer);
67 68 Objects.requireNonNull(action, "action can't be null");
68 69 sourceSetConfigurationRegistry.addLayerAction(layer, action);
69 70 }
70 71
71 72 @Override
72 public void configureVariant(Variant variant, Action<? super GenericSourceSet> action) {
73 public void configureVariant(Variant variant, Action<? super CompileUnitSourceSetSpec> action) {
73 74 variantsView.assertVariant(variant);
74 75 Objects.requireNonNull(action, "action can't be null");
75 76 sourceSetConfigurationRegistry.addVariantAction(variant, action);
76 77 }
77 78
78 79 @Override
79 public void configureUnit(CompileUnit unit, Action<? super GenericSourceSet> action) {
80 public void configureUnit(CompileUnit unit, Action<? super CompileUnitSourceSetSpec> action) {
80 81 assertCompileUnit(unit);
81 82 Objects.requireNonNull(action, "action can't be null");
82 83 sourceSetConfigurationRegistry.addCompileUnitAction(unit, action);
83 84 }
84 85
86 @Override
87 public void configureEach(Action<? super CompileUnitSourceSetSpec> action) {
88 Objects.requireNonNull(action, "action can't be null");
89 sourceSetConfigurationRegistry.addAction(action);
90 }
91
85 92 private void assertCompileUnit(CompileUnit unit) {
86 93 Objects.requireNonNull(unit, "unit can't be null");
87 94 variantsView.assertVariant(unit.variant());
@@ -17,15 +17,17 import org.implab.gradle.common.core.lan
17 17 import org.implab.gradle.variants.core.Layer;
18 18 import org.implab.gradle.variants.core.Variant;
19 19 import org.implab.gradle.variants.sources.CompileUnit;
20 import org.implab.gradle.variants.sources.CompileUnitSourceSetSpec;
20 21 import org.implab.gradle.variants.sources.GenericSourceSet;
21 22
22 23 @NonNullByDefault
23 24 public class SourceSetConfigurationRegistry {
24 25 private static final Logger logger = Logging.getLogger(SourceSetConfigurationRegistry.class);
25 26
26 private final Map<Layer, ReplayableQueue<GenericSourceSet>> sourcesByLayer = new LinkedHashMap<>();
27 private final Map<Variant, ReplayableQueue<GenericSourceSet>> sourcesByVariant = new LinkedHashMap<>();
28 private final Map<CompileUnit, ReplayableQueue<GenericSourceSet>> sourcesByUnit = new LinkedHashMap<>();
27 private final ReplayableQueue<CompileUnitSourceSetSpec> sources = new ReplayableQueue<>();
28 private final Map<Layer, ReplayableQueue<CompileUnitSourceSetSpec>> sourcesByLayer = new LinkedHashMap<>();
29 private final Map<Variant, ReplayableQueue<CompileUnitSourceSetSpec>> sourcesByVariant = new LinkedHashMap<>();
30 private final Map<CompileUnit, ReplayableQueue<CompileUnitSourceSetSpec>> sourcesByUnit = new LinkedHashMap<>();
29 31
30 32 private final Supplier<LateConfigurationMode> lateConfigurationMode;
31 33
@@ -33,7 +35,14 public class SourceSetConfigurationRegis
33 35 this.lateConfigurationMode = lateConfigurationMode;
34 36 }
35 37
36 public void addLayerAction(Layer layer, Action<? super GenericSourceSet> action) {
38 public void addAction(Action<? super CompileUnitSourceSetSpec> action) {
39 addToActions(
40 sources,
41 action,
42 "Source sets already materialized");
43 }
44
45 public void addLayerAction(Layer layer, Action<? super CompileUnitSourceSetSpec> action) {
37 46 addToActions(
38 47 sourcesByLayer.computeIfAbsent(layer, key -> new ReplayableQueue<>()),
39 48 action,
@@ -42,7 +51,7 public class SourceSetConfigurationRegis
42 51 layer.getName()));
43 52 }
44 53
45 public void addVariantAction(Variant variant, Action<? super GenericSourceSet> action) {
54 public void addVariantAction(Variant variant, Action<? super CompileUnitSourceSetSpec> action) {
46 55 addToActions(
47 56 sourcesByVariant.computeIfAbsent(variant, key -> new ReplayableQueue<>()),
48 57 action,
@@ -52,7 +61,7 public class SourceSetConfigurationRegis
52 61
53 62 }
54 63
55 public void addCompileUnitAction(CompileUnit unit, Action<? super GenericSourceSet> action) {
64 public void addCompileUnitAction(CompileUnit unit, Action<? super CompileUnitSourceSetSpec> action) {
56 65 addToActions(
57 66 sourcesByUnit.computeIfAbsent(unit, key -> new ReplayableQueue<>()),
58 67 action,
@@ -63,18 +72,21 public class SourceSetConfigurationRegis
63 72 }
64 73
65 74 private void addToActions(
66 ReplayableQueue<GenericSourceSet> actions,
67 Action<? super GenericSourceSet> action,
75 ReplayableQueue<CompileUnitSourceSetSpec> actions,
76 Action<? super CompileUnitSourceSetSpec> action,
68 77 String assertMessage) {
69 78 assertLazyConfiguration(actions.values(), assertMessage);
70 79 actions.forEach(action::execute);
71 80 }
72 81
73 void assertLazyConfiguration(List<GenericSourceSet> sets, String message) {
82 void assertLazyConfiguration(List<CompileUnitSourceSetSpec> sets, String message) {
74 83 if (sets.size() == 0)
75 84 return;
76 85
77 var names = sets.stream().map(Named::getName).collect(Collectors.joining(", "));
86 var names = sets.stream()
87 .map(CompileUnitSourceSetSpec::getSourceSet)
88 .map(Named::getName)
89 .collect(Collectors.joining(", "));
78 90
79 91 switch (lateConfigurationMode.get()) {
80 92 case FAIL:
@@ -88,8 +100,10 public class SourceSetConfigurationRegis
88 100 }
89 101
90 102 public void applyConfiguration(CompileUnit unit, GenericSourceSet sourceSet) {
91 sourcesByVariant.computeIfAbsent(unit.variant(), key -> new ReplayableQueue<>()).add(sourceSet);
92 sourcesByLayer.computeIfAbsent(unit.layer(), key -> new ReplayableQueue<>()).add(sourceSet);
93 sourcesByUnit.computeIfAbsent(unit, key -> new ReplayableQueue<>()).add(sourceSet);
103 var spec = new DefaultCompileUnitSourceSetSpec(unit, sourceSet);
104 sources.add(spec);
105 sourcesByVariant.computeIfAbsent(unit.variant(), key -> new ReplayableQueue<>()).add(spec);
106 sourcesByLayer.computeIfAbsent(unit.layer(), key -> new ReplayableQueue<>()).add(spec);
107 sourcesByUnit.computeIfAbsent(unit, key -> new ReplayableQueue<>()).add(spec);
94 108 }
95 109 }
@@ -197,14 +197,18 class VariantArtifactsPluginFunctionalTe
197 197
198 198 variantSources {
199 199 layer('mainBase') {
200 sourceSet {
200 201 declareOutputs('js')
201 202 registerOutput('js', layout.projectDirectory.file('inputs/base.js'))
202 203 }
204 }
203 205 layer('mainAmd') {
206 sourceSet {
204 207 declareOutputs('js')
205 208 registerOutput('js', layout.projectDirectory.file('inputs/amd.js'))
206 209 }
207 210 }
211 }
208 212
209 213 variantArtifacts {
210 214 variant('browser') {
@@ -349,8 +353,10 class VariantArtifactsPluginFunctionalTe
349 353 }
350 354
351 355 variantSources.layer('main') {
356 sourceSet {
352 357 declareOutputs('types')
353 358 }
359 }
354 360
355 361 variantArtifacts {
356 362 variant('browser') {
@@ -432,9 +438,11 class VariantArtifactsPluginFunctionalTe
432 438 }
433 439
434 440 variantSources.layer('main') {
441 sourceSet {
435 442 declareOutputs('js')
436 443 registerOutput('js', layout.projectDirectory.file('inputs/base.js'))
437 444 }
445 }
438 446
439 447 variantArtifacts {
440 448 variant('browser') {
@@ -528,8 +536,10 class VariantArtifactsPluginFunctionalTe
528 536 }
529 537
530 538 variantSources.layer('main') {
539 sourceSet {
531 540 declareOutputs('types', 'js')
532 541 }
542 }
533 543
534 544 variantArtifacts {
535 545 variant('browser') {
@@ -616,10 +626,12 class VariantArtifactsPluginFunctionalTe
616 626 }
617 627
618 628 variantSources.layer('main') {
629 sourceSet {
619 630 declareOutputs('types', 'js')
620 631 registerOutput('types', layout.projectDirectory.file('inputs/types.d.ts'))
621 632 registerOutput('js', layout.projectDirectory.file('inputs/index.js'))
622 633 }
634 }
623 635
624 636 variantArtifacts {
625 637 variant('browser') {
@@ -95,14 +95,18 class VariantSourcesPluginFunctionalTest
95 95 def events = []
96 96
97 97 variantSources {
98 configureEach {
99 events << "all:" + sourceSet.name
100 events << "context:" + sourceSet.name + ":" + variant.name + ":" + layer.name
101 }
98 102 variant('browser') {
99 events << "variant:" + name
103 events << "variant:" + sourceSet.name
100 104 }
101 105 layer('main') {
102 events << "layer:" + name
106 events << "layer:" + sourceSet.name
103 107 }
104 108 unit('browser', 'main') {
105 events << "unit:" + name
109 events << "unit:" + sourceSet.name
106 110 }
107 111 }
108 112
@@ -121,15 +125,17 class VariantSourcesPluginFunctionalTest
121 125 println("browserMain=" + bySourceSet[browserMain.name].collect { it.split(':', 2)[0] }.join(','))
122 126 println("browserTest=" + bySourceSet[browserTest.name].collect { it.split(':', 2)[0] }.join(','))
123 127 println("nodeMain=" + bySourceSet[nodeMain.name].collect { it.split(':', 2)[0] }.join(','))
128 println("context=" + events.find { it.startsWith("context:" + browserMain.name + ":") })
124 129 }
125 130 }
126 131 """);
127 132
128 133 BuildResult result = runner("help").build();
129 134
130 assertTrue(result.getOutput().contains("browserMain=variant,layer,unit"));
131 assertTrue(result.getOutput().contains("browserTest=variant"));
132 assertTrue(result.getOutput().contains("nodeMain=layer"));
135 assertTrue(result.getOutput().contains("browserMain=all,variant,layer,unit"));
136 assertTrue(result.getOutput().contains("browserTest=all,variant"));
137 assertTrue(result.getOutput().contains("nodeMain=all,layer"));
138 assertTrue(result.getOutput().contains("context=context:browserMain:browser:main"));
133 139 }
134 140
135 141 @Test
@@ -153,10 +159,12 class VariantSourcesPluginFunctionalTest
153 159
154 160 ctx.sourceSets.getSourceSet(unit).get()
155 161 variantSources.layer('main') {
162 sourceSet {
156 163 declareOutputs('late')
157 164 }
158 165 }
159 166 }
167 }
160 168 """);
161 169
162 170 assertBuildFails("Source sets for [layer=main] layer already materialized", "help");
@@ -187,11 +195,13 class VariantSourcesPluginFunctionalTest
187 195 def mainLayer = ctx.variants.layers.find { it.name == 'main' }
188 196 def unit = ctx.compileUnits.requireUnit(browser, mainLayer)
189 197
190 def sourceSet = ctx.sourceSets.getSourceSet(unit).get()
198 def unitSourceSet = ctx.sourceSets.getSourceSet(unit).get()
191 199 variantSources.layer('main') {
200 sourceSet {
192 201 declareOutputs('late')
193 202 }
194 sourceSet.output('late')
203 }
204 unitSourceSet.output('late')
195 205 println('lateAllowed=ok')
196 206 }
197 207 }
@@ -226,11 +236,13 class VariantSourcesPluginFunctionalTest
226 236 def mainLayer = ctx.variants.layers.find { it.name == 'main' }
227 237 def unit = ctx.compileUnits.requireUnit(browser, mainLayer)
228 238
229 def sourceSet = ctx.sourceSets.getSourceSet(unit).get()
239 def unitSourceSet = ctx.sourceSets.getSourceSet(unit).get()
230 240 variantSources.layer('main') {
241 sourceSet {
231 242 declareOutputs('late')
232 243 }
233 sourceSet.output('late')
244 }
245 unitSourceSet.output('late')
234 246 println('lateWarn=ok')
235 247 }
236 248 }
@@ -257,8 +269,10 class VariantSourcesPluginFunctionalTest
257 269
258 270 variantSources {
259 271 variant('browser') {
272 sourceSet {
260 273 declareOutputs('js')
261 274 }
275 }
262 276 lateConfigurationPolicy {
263 277 allowLateConfiguration()
264 278 }
@@ -351,9 +365,11 class VariantSourcesPluginFunctionalTest
351 365
352 366 variantSources {
353 367 variant('missing') {
368 sourceSet {
354 369 declareOutputs('js')
355 370 }
356 371 }
372 }
357 373 """);
358 374
359 375 assertBuildFails("Variant 'missing' isn't declared", "help");
@@ -375,9 +391,11 class VariantSourcesPluginFunctionalTest
375 391 variantSources.whenAvailable { ctx ->
376 392 def missing = objects.named(org.implab.gradle.variants.core.Variant, 'missing')
377 393 ctx.configureVariant(missing) {
394 sourceSet {
378 395 declareOutputs('js')
379 396 }
380 397 }
398 }
381 399 """);
382 400
383 401 assertBuildFails("The specified variant 'missing' isn't declared", "help");
@@ -398,9 +416,11 class VariantSourcesPluginFunctionalTest
398 416
399 417 variantSources {
400 418 layer('missing') {
419 sourceSet {
401 420 declareOutputs('js')
402 421 }
403 422 }
423 }
404 424 """);
405 425
406 426 assertBuildFails("Layer 'missing' isn't declared", "help");
@@ -422,9 +442,11 class VariantSourcesPluginFunctionalTest
422 442 variantSources.whenAvailable { ctx ->
423 443 def missing = objects.named(org.implab.gradle.variants.core.Layer, 'missing')
424 444 ctx.configureLayer(missing) {
445 sourceSet {
425 446 declareOutputs('js')
426 447 }
427 448 }
449 }
428 450 """);
429 451
430 452 assertBuildFails("The specified layer 'missing' isn't declared", "help");
@@ -446,9 +468,11 class VariantSourcesPluginFunctionalTest
446 468
447 469 variantSources {
448 470 unit('browser', 'test') {
471 sourceSet {
449 472 declareOutputs('js')
450 473 }
451 474 }
475 }
452 476 """);
453 477
454 478 assertBuildFails("The CompileUnit isn't declared for variant 'browser', layer 'test'", "help");
@@ -473,9 +497,11 class VariantSourcesPluginFunctionalTest
473 497 def testLayer = ctx.variants.layers.find { it.name == 'test' }
474 498 def unit = new org.implab.gradle.variants.sources.CompileUnit(browser, testLayer)
475 499 ctx.configureUnit(unit) {
500 sourceSet {
476 501 declareOutputs('js')
477 502 }
478 503 }
504 }
479 505 """);
480 506
481 507 assertBuildFails("Compile unit for variant 'browser' and layer 'test' not found", "help");
General Comments 0
You need to be logged in to leave comments. Login now