| @@ -0,0 +1,33 | |||||
|
|
1 | package org.implab.gradle.common.sources; | |||
|
|
2 | ||||
|
|
3 | import org.implab.gradle.common.core.lang.Closures; | |||
|
|
4 | import org.gradle.api.Action; | |||
|
|
5 | import org.gradle.api.NamedDomainObjectProvider; | |||
|
|
6 | ||||
|
|
7 | import groovy.lang.Closure; | |||
|
|
8 | import groovy.lang.DelegatesTo; | |||
|
|
9 | ||||
|
|
10 | /** | |||
|
|
11 | * Immutable payload for a newly registered {@link GenericSourceSet}. | |||
|
|
12 | * | |||
|
|
13 | * <p>Used as callback payload for | |||
|
|
14 | * {@link VariantSourcesExtension#whenRegistered(org.gradle.api.Action)} and | |||
|
|
15 | * {@link BuildLayerBinding#whenRegistered(org.gradle.api.Action)}. | |||
|
|
16 | * | |||
|
|
17 | * @param layerName normalized layer name that owns the registration | |||
|
|
18 | * @param sourceSetName source-set name registered in the container | |||
|
|
19 | * @param sourceSet provider of the registered source set (realized later by Gradle on demand) | |||
|
|
20 | */ | |||
|
|
21 | public record SourceSetRegistration( | |||
|
|
22 | String layerName, | |||
|
|
23 | String sourceSetName, | |||
|
|
24 | NamedDomainObjectProvider<GenericSourceSet> sourceSet) { | |||
|
|
25 | public void configureSourceSet(Action<? super GenericSourceSet> action) { | |||
|
|
26 | sourceSet.configure(action); | |||
|
|
27 | } | |||
|
|
28 | ||||
|
|
29 | public void configureSourceSet( | |||
|
|
30 | @DelegatesTo(value = GenericSourceSet.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { | |||
|
|
31 | configureSourceSet(Closures.action(action)); | |||
|
|
32 | } | |||
|
|
33 | } | |||
| @@ -0,0 +1,37 | |||||
|
|
1 | package org.implab.gradle.common.sources; | |||
|
|
2 | ||||
|
|
3 | import org.implab.gradle.common.core.lang.Closures; | |||
|
|
4 | import org.gradle.api.Action; | |||
|
|
5 | import org.gradle.api.NamedDomainObjectProvider; | |||
|
|
6 | ||||
|
|
7 | import groovy.lang.Closure; | |||
|
|
8 | import groovy.lang.DelegatesTo; | |||
|
|
9 | ||||
|
|
10 | /** | |||
|
|
11 | * Immutable payload for a resolved variant/role/layer usage bound to a source set. | |||
|
|
12 | * | |||
|
|
13 | * <p>Used as callback payload for | |||
|
|
14 | * {@link VariantSourcesExtension#whenBound(org.gradle.api.Action)} and | |||
|
|
15 | * {@link BuildLayerBinding#whenBound(org.gradle.api.Action)}. | |||
|
|
16 | * | |||
|
|
17 | * @param variantName variant name from the build-variants model | |||
|
|
18 | * @param roleName role name inside the resolved variant | |||
|
|
19 | * @param layerName normalized layer name used to resolve the source set | |||
|
|
20 | * @param sourceSetName source-set name registered in the container | |||
|
|
21 | * @param sourceSet provider of the registered source set (realized later by Gradle on demand) | |||
|
|
22 | */ | |||
|
|
23 | public record SourceSetUsageBinding( | |||
|
|
24 | String variantName, | |||
|
|
25 | String roleName, | |||
|
|
26 | String layerName, | |||
|
|
27 | String sourceSetName, | |||
|
|
28 | NamedDomainObjectProvider<GenericSourceSet> sourceSet) { | |||
|
|
29 | public void configureSourceSet(Action<? super GenericSourceSet> action) { | |||
|
|
30 | sourceSet.configure(action); | |||
|
|
31 | } | |||
|
|
32 | ||||
|
|
33 | public void configureSourceSet( | |||
|
|
34 | @DelegatesTo(value = GenericSourceSet.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { | |||
|
|
35 | configureSourceSet(Closures.action(action)); | |||
|
|
36 | } | |||
|
|
37 | } | |||
| @@ -92,7 +92,8 outputs. Это уже "физический" уровень, к которому удобно привязывать задачи, | |||||
| 92 | - `BuildRole` — роль внутри варианта, содержит ссылки на layer names. |
|
92 | - `BuildRole` — роль внутри варианта, содержит ссылки на layer names. | |
| 93 | - `GenericSourceSet` — зарегистрированный набор исходников и outputs. |
|
93 | - `GenericSourceSet` — зарегистрированный набор исходников и outputs. | |
| 94 | - `BuildLayerBinding` — правила registration source set для конкретного layer. |
|
94 | - `BuildLayerBinding` — правила registration source set для конкретного layer. | |
| 95 | - `SourceSetContext` — контекст callback-событий registration. |
|
95 | - `SourceSetRegistration` — payload события регистрации source set. | |
|
|
96 | - `SourceSetUsageBinding` — payload события usage-binding. | |||
| 96 |
|
97 | |||
| 97 | ## EVENT CONTRACT |
|
98 | ## EVENT CONTRACT | |
| 98 |
|
99 | |||
| @@ -116,7 +117,8 Closure callbacks работают в delegate-first режиме (`@DelegatesTo`). Для | |||||
| 116 | - `VariantsSourcesPlugin` — применяет `variants` + `sources` и запускает адаптер. |
|
117 | - `VariantsSourcesPlugin` — применяет `variants` + `sources` и запускает адаптер. | |
| 117 | - `VariantSourcesExtension` — API bind/events registration. |
|
118 | - `VariantSourcesExtension` — API bind/events registration. | |
| 118 | - `BuildLayerBinding` — слой-конкретный DSL для имени и конфигурации source set. |
|
119 | - `BuildLayerBinding` — слой-конкретный DSL для имени и конфигурации source set. | |
| 119 | - `SourceSetContext` — payload событий и sugar `configureSourceSet(...)`. |
|
120 | - `SourceSetRegistration` — payload `whenRegistered(...)`. | |
|
|
121 | - `SourceSetUsageBinding` — payload `whenBound(...)`. | |||
| 120 |
|
122 | |||
| 121 | ## NOTES |
|
123 | ## NOTES | |
| 122 |
|
124 | |||
| @@ -25,11 +25,11 public abstract class BuildLayerBinding | |||||
| 25 | private final String name; |
|
25 | private final String name; | |
| 26 |
|
26 | |||
| 27 | private final List<Action<? super GenericSourceSet>> sourceSetConfigureActions = new ArrayList<>(); |
|
27 | private final List<Action<? super GenericSourceSet>> sourceSetConfigureActions = new ArrayList<>(); | |
| 28 |
private final List<Action<? super SourceSet |
|
28 | private final List<Action<? super SourceSetRegistration>> registeredActions = new ArrayList<>(); | |
| 29 |
private final List<Action<? super SourceSet |
|
29 | private final List<Action<? super SourceSetUsageBinding>> boundActions = new ArrayList<>(); | |
| 30 | private final List<NamedDomainObjectProvider<GenericSourceSet>> registeredSourceSets = new ArrayList<>(); |
|
30 | private final List<NamedDomainObjectProvider<GenericSourceSet>> registeredSourceSets = new ArrayList<>(); | |
| 31 |
private final List<SourceSet |
|
31 | private final List<SourceSetRegistration> registeredContexts = new ArrayList<>(); | |
| 32 |
private final List<SourceSet |
|
32 | private final List<SourceSetUsageBinding> boundContexts = new ArrayList<>(); | |
| 33 | private final Set<String> registeredSourceSetNames = new LinkedHashSet<>(); |
|
33 | private final Set<String> registeredSourceSetNames = new LinkedHashSet<>(); | |
| 34 |
|
34 | |||
| 35 | @Inject |
|
35 | @Inject | |
| @@ -62,59 +62,59 public abstract class BuildLayerBinding | |||||
| 62 |
|
62 | |||
| 63 | /** |
|
63 | /** | |
| 64 | * Layer-local callback fired after source-set registration. |
|
64 | * Layer-local callback fired after source-set registration. | |
| 65 |
* Already emitted |
|
65 | * Already emitted registrations are delivered immediately (replay). | |
| 66 | * For simple callbacks you can use delegate-only style |
|
66 | * For simple callbacks you can use delegate-only style | |
| 67 | * (for example {@code whenRegistered { sourceSetName() }}). |
|
67 | * (for example {@code whenRegistered { sourceSetName() }}). | |
| 68 | * For nested closures prefer explicit parameter |
|
68 | * For nested closures prefer explicit parameter | |
| 69 | * ({@code whenRegistered { ctx -> ... }}). |
|
69 | * ({@code whenRegistered { ctx -> ... }}). | |
| 70 | */ |
|
70 | */ | |
| 71 |
public void whenRegistered(Action<? super SourceSet |
|
71 | public void whenRegistered(Action<? super SourceSetRegistration> action) { | |
| 72 | registeredActions.add(action); |
|
72 | registeredActions.add(action); | |
| 73 | for (var context : registeredContexts) |
|
73 | for (var context : registeredContexts) | |
| 74 | action.execute(context); |
|
74 | action.execute(context); | |
| 75 | } |
|
75 | } | |
| 76 |
|
76 | |||
| 77 | public void whenRegistered( |
|
77 | public void whenRegistered( | |
| 78 |
@DelegatesTo(value = SourceSet |
|
78 | @DelegatesTo(value = SourceSetRegistration.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { | |
| 79 | whenRegistered(Closures.action(action)); |
|
79 | whenRegistered(Closures.action(action)); | |
| 80 | } |
|
80 | } | |
| 81 |
|
81 | |||
| 82 | /** |
|
82 | /** | |
| 83 | * Layer-local callback fired for every resolved variant/role/layer usage. |
|
83 | * Layer-local callback fired for every resolved variant/role/layer usage. | |
| 84 |
* Already emitted |
|
84 | * Already emitted usage bindings are delivered immediately (replay). | |
| 85 | * For simple callbacks you can use delegate-only style |
|
85 | * For simple callbacks you can use delegate-only style | |
| 86 | * (for example {@code whenBound { variantName() }}). |
|
86 | * (for example {@code whenBound { variantName() }}). | |
| 87 | * For nested closures prefer explicit parameter |
|
87 | * For nested closures prefer explicit parameter | |
| 88 | * ({@code whenBound { ctx -> ... }}). |
|
88 | * ({@code whenBound { ctx -> ... }}). | |
| 89 | */ |
|
89 | */ | |
| 90 |
public void whenBound(Action<? super SourceSet |
|
90 | public void whenBound(Action<? super SourceSetUsageBinding> action) { | |
| 91 | boundActions.add(action); |
|
91 | boundActions.add(action); | |
| 92 | for (var context : boundContexts) |
|
92 | for (var context : boundContexts) | |
| 93 | action.execute(context); |
|
93 | action.execute(context); | |
| 94 | } |
|
94 | } | |
| 95 |
|
95 | |||
| 96 | public void whenBound( |
|
96 | public void whenBound( | |
| 97 |
@DelegatesTo(value = SourceSet |
|
97 | @DelegatesTo(value = SourceSetUsageBinding.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { | |
| 98 | whenBound(Closures.action(action)); |
|
98 | whenBound(Closures.action(action)); | |
| 99 | } |
|
99 | } | |
| 100 |
|
100 | |||
| 101 |
void notifyRegistered(SourceSet |
|
101 | void notifyRegistered(SourceSetRegistration registration) { | |
| 102 |
if (registeredSourceSetNames.add( |
|
102 | if (registeredSourceSetNames.add(registration.sourceSetName())) { | |
| 103 |
var sourceSet = |
|
103 | var sourceSet = registration.sourceSet(); | |
| 104 | registeredSourceSets.add(sourceSet); |
|
104 | registeredSourceSets.add(sourceSet); | |
| 105 |
|
105 | |||
| 106 | for (var action : sourceSetConfigureActions) |
|
106 | for (var action : sourceSetConfigureActions) | |
| 107 | sourceSet.configure(action); |
|
107 | sourceSet.configure(action); | |
| 108 | } |
|
108 | } | |
| 109 |
|
109 | |||
| 110 |
registeredContexts.add( |
|
110 | registeredContexts.add(registration); | |
| 111 | for (var action : registeredActions) |
|
111 | for (var action : registeredActions) | |
| 112 |
action.execute( |
|
112 | action.execute(registration); | |
| 113 | } |
|
113 | } | |
| 114 |
|
114 | |||
| 115 |
void notifyBound(SourceSet |
|
115 | void notifyBound(SourceSetUsageBinding binding) { | |
| 116 |
boundContexts.add( |
|
116 | boundContexts.add(binding); | |
| 117 | for (var action : boundActions) |
|
117 | for (var action : boundActions) | |
| 118 |
action.execute( |
|
118 | action.execute(binding); | |
| 119 | } |
|
119 | } | |
| 120 | } |
|
120 | } | |
| @@ -35,10 +35,10 public abstract class VariantSourcesExte | |||||
| 35 | private static final Pattern SOURCE_SET_NAME_TOKEN = Pattern.compile("\\{([A-Za-z][A-Za-z0-9]*)\\}"); |
|
35 | private static final Pattern SOURCE_SET_NAME_TOKEN = Pattern.compile("\\{([A-Za-z][A-Za-z0-9]*)\\}"); | |
| 36 |
|
36 | |||
| 37 | private final NamedDomainObjectContainer<BuildLayerBinding> bindings; |
|
37 | private final NamedDomainObjectContainer<BuildLayerBinding> bindings; | |
| 38 |
private final List<Action<? super SourceSet |
|
38 | private final List<Action<? super SourceSetRegistration>> registeredActions = new ArrayList<>(); | |
| 39 |
private final List<Action<? super SourceSet |
|
39 | private final List<Action<? super SourceSetUsageBinding>> boundActions = new ArrayList<>(); | |
| 40 |
private final List<SourceSet |
|
40 | private final List<SourceSetRegistration> registeredContexts = new ArrayList<>(); | |
| 41 |
private final List<SourceSet |
|
41 | private final List<SourceSetUsageBinding> boundContexts = new ArrayList<>(); | |
| 42 | private final LinkedHashMap<String, NamedDomainObjectProvider<GenericSourceSet>> sourceSetsByName = new LinkedHashMap<>(); |
|
42 | private final LinkedHashMap<String, NamedDomainObjectProvider<GenericSourceSet>> sourceSetsByName = new LinkedHashMap<>(); | |
| 43 | private final LinkedHashMap<String, String> sourceSetLayersByName = new LinkedHashMap<>(); |
|
43 | private final LinkedHashMap<String, String> sourceSetLayersByName = new LinkedHashMap<>(); | |
| 44 | private boolean sourceSetsRegistered; |
|
44 | private boolean sourceSetsRegistered; | |
| @@ -80,60 +80,50 public abstract class VariantSourcesExte | |||||
| 80 | } |
|
80 | } | |
| 81 |
|
81 | |||
| 82 | /** |
|
82 | /** | |
| 83 |
* Global callback fired for each registered source |
|
83 | * Global callback fired for each registered source set. | |
| 84 |
* Already emitted |
|
84 | * Already emitted registrations are delivered immediately (replay). | |
| 85 | * For simple callbacks you can use delegate-only style |
|
85 | * For simple callbacks you can use delegate-only style | |
| 86 | * (for example {@code whenRegistered { sourceSetName() }}). |
|
86 | * (for example {@code whenRegistered { sourceSetName() }}). | |
| 87 | * For nested closures prefer explicit parameter |
|
87 | * For nested closures prefer explicit parameter | |
| 88 | * ({@code whenRegistered { ctx -> ... }}). |
|
88 | * ({@code whenRegistered { ctx -> ... }}). | |
| 89 | */ |
|
89 | */ | |
| 90 |
public void whenRegistered(Action<? super SourceSet |
|
90 | public void whenRegistered(Action<? super SourceSetRegistration> action) { | |
| 91 | registeredActions.add(action); |
|
91 | registeredActions.add(action); | |
| 92 | for (var context : registeredContexts) |
|
92 | for (var context : registeredContexts) | |
| 93 | action.execute(context); |
|
93 | action.execute(context); | |
| 94 | } |
|
94 | } | |
| 95 |
|
95 | |||
| 96 | public void whenRegistered( |
|
96 | public void whenRegistered( | |
| 97 |
@DelegatesTo(value = SourceSet |
|
97 | @DelegatesTo(value = SourceSetRegistration.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { | |
| 98 | whenRegistered(Closures.action(action)); |
|
98 | whenRegistered(Closures.action(action)); | |
| 99 | } |
|
99 | } | |
| 100 |
|
100 | |||
| 101 | public void whenRegistered(String variantName, Action<? super SourceSetContext> action) { |
|
|||
| 102 | var normalizedVariantName = normalize(variantName, "variantName must not be null or blank"); |
|
|||
| 103 | whenRegistered(filterByVariant(normalizedVariantName, action)); |
|
|||
| 104 | } |
|
|||
| 105 |
|
||||
| 106 | public void whenRegistered(String variantName, |
|
|||
| 107 | @DelegatesTo(value = SourceSetContext.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { |
|
|||
| 108 | whenRegistered(variantName, Closures.action(action)); |
|
|||
| 109 | } |
|
|||
| 110 |
|
||||
| 111 | /** |
|
101 | /** | |
| 112 | * Global callback fired for every resolved variant/role/layer usage. |
|
102 | * Global callback fired for every resolved variant/role/layer usage. | |
| 113 |
* Already emitted |
|
103 | * Already emitted usage bindings are delivered immediately (replay). | |
| 114 | * For simple callbacks you can use delegate-only style |
|
104 | * For simple callbacks you can use delegate-only style | |
| 115 | * (for example {@code whenBound { variantName() }}). |
|
105 | * (for example {@code whenBound { variantName() }}). | |
| 116 | * For nested closures prefer explicit parameter |
|
106 | * For nested closures prefer explicit parameter | |
| 117 | * ({@code whenBound { ctx -> ... }}). |
|
107 | * ({@code whenBound { ctx -> ... }}). | |
| 118 | */ |
|
108 | */ | |
| 119 |
public void whenBound(Action<? super SourceSet |
|
109 | public void whenBound(Action<? super SourceSetUsageBinding> action) { | |
| 120 | boundActions.add(action); |
|
110 | boundActions.add(action); | |
| 121 | for (var context : boundContexts) |
|
111 | for (var context : boundContexts) | |
| 122 | action.execute(context); |
|
112 | action.execute(context); | |
| 123 | } |
|
113 | } | |
| 124 |
|
114 | |||
| 125 | public void whenBound( |
|
115 | public void whenBound( | |
| 126 |
@DelegatesTo(value = SourceSet |
|
116 | @DelegatesTo(value = SourceSetUsageBinding.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { | |
| 127 | whenBound(Closures.action(action)); |
|
117 | whenBound(Closures.action(action)); | |
| 128 | } |
|
118 | } | |
| 129 |
|
119 | |||
| 130 |
public void whenBound(String variantName, Action<? super SourceSet |
|
120 | public void whenBound(String variantName, Action<? super SourceSetUsageBinding> action) { | |
| 131 | var normalizedVariantName = normalize(variantName, "variantName must not be null or blank"); |
|
121 | var normalizedVariantName = normalize(variantName, "variantName must not be null or blank"); | |
| 132 | whenBound(filterByVariant(normalizedVariantName, action)); |
|
122 | whenBound(filterByVariant(normalizedVariantName, action)); | |
| 133 | } |
|
123 | } | |
| 134 |
|
124 | |||
| 135 | public void whenBound(String variantName, |
|
125 | public void whenBound(String variantName, | |
| 136 |
@DelegatesTo(value = SourceSet |
|
126 | @DelegatesTo(value = SourceSetUsageBinding.class, strategy = Closure.DELEGATE_FIRST) Closure<?> action) { | |
| 137 | whenBound(variantName, Closures.action(action)); |
|
127 | whenBound(variantName, Closures.action(action)); | |
| 138 | } |
|
128 | } | |
| 139 |
|
129 | |||
| @@ -188,7 +178,7 public abstract class VariantSourcesExte | |||||
| 188 | var sourceSet = sourceSetsByName.computeIfAbsent(sourceSetName, |
|
178 | var sourceSet = sourceSetsByName.computeIfAbsent(sourceSetName, | |
| 189 | name -> sources.register(name)); |
|
179 | name -> sources.register(name)); | |
| 190 |
|
180 | |||
| 191 |
var |
|
181 | var binding = new SourceSetUsageBinding( | |
| 192 | usage.variantName(), |
|
182 | usage.variantName(), | |
| 193 | usage.roleName(), |
|
183 | usage.roleName(), | |
| 194 | usage.layerName(), |
|
184 | usage.layerName(), | |
| @@ -196,31 +186,35 public abstract class VariantSourcesExte | |||||
| 196 | sourceSet); |
|
186 | sourceSet); | |
| 197 |
|
187 | |||
| 198 | if (isNewSourceSet) { |
|
188 | if (isNewSourceSet) { | |
| 199 | resolvedBinding.notifyRegistered(context); |
|
189 | var registration = new SourceSetRegistration( | |
| 200 | notifyRegistered(context); |
|
190 | usage.layerName(), | |
|
|
191 | sourceSetName, | |||
|
|
192 | sourceSet); | |||
|
|
193 | resolvedBinding.notifyRegistered(registration); | |||
|
|
194 | notifyRegistered(registration); | |||
| 201 | } |
|
195 | } | |
| 202 |
|
196 | |||
| 203 |
resolvedBinding.notifyBound( |
|
197 | resolvedBinding.notifyBound(binding); | |
| 204 |
notifyBound( |
|
198 | notifyBound(binding); | |
| 205 | } |
|
199 | } | |
| 206 |
|
200 | |||
| 207 |
private void notifyRegistered(SourceSet |
|
201 | private void notifyRegistered(SourceSetRegistration registration) { | |
| 208 |
registeredContexts.add( |
|
202 | registeredContexts.add(registration); | |
| 209 | for (var action : registeredActions) |
|
203 | for (var action : registeredActions) | |
| 210 |
action.execute( |
|
204 | action.execute(registration); | |
| 211 | } |
|
205 | } | |
| 212 |
|
206 | |||
| 213 |
private void notifyBound(SourceSet |
|
207 | private void notifyBound(SourceSetUsageBinding binding) { | |
| 214 |
boundContexts.add( |
|
208 | boundContexts.add(binding); | |
| 215 | for (var action : boundActions) |
|
209 | for (var action : boundActions) | |
| 216 |
action.execute( |
|
210 | action.execute(binding); | |
| 217 | } |
|
211 | } | |
| 218 |
|
212 | |||
| 219 |
private static Action<? super SourceSet |
|
213 | private static Action<? super SourceSetUsageBinding> filterByVariant(String variantName, | |
| 220 |
Action<? super SourceSet |
|
214 | Action<? super SourceSetUsageBinding> action) { | |
| 221 |
return |
|
215 | return binding -> { | |
| 222 |
if (variantName.equals( |
|
216 | if (variantName.equals(binding.variantName())) | |
| 223 |
action.execute( |
|
217 | action.execute(binding); | |
| 224 | }; |
|
218 | }; | |
| 225 | } |
|
219 | } | |
| 226 |
|
220 | |||
| @@ -61,10 +61,10 class VariantsSourcesPluginFunctionalTes | |||||
| 61 | } |
|
61 | } | |
| 62 | } |
|
62 | } | |
| 63 | bind('mainAmd').whenRegistered { ctx -> |
|
63 | bind('mainAmd').whenRegistered { ctx -> | |
| 64 |
localEvents << " |
|
64 | localEvents << "${ctx.layerName()}:${ctx.sourceSetName()}" | |
| 65 | } |
|
65 | } | |
| 66 | whenRegistered { ctx -> |
|
66 | whenRegistered { ctx -> | |
| 67 |
events << " |
|
67 | events << "${ctx.layerName()}:${ctx.sourceSetName()}" | |
| 68 | } |
|
68 | } | |
| 69 | } |
|
69 | } | |
| 70 |
|
70 | |||
| @@ -90,9 +90,8 class VariantsSourcesPluginFunctionalTes | |||||
| 90 | BuildResult result = runner("probe").build(); |
|
90 | BuildResult result = runner("probe").build(); | |
| 91 |
|
91 | |||
| 92 | assertTrue(result.getOutput().contains("sources=browserMainAmd,browserMainBase,nodeMainBase")); |
|
92 | assertTrue(result.getOutput().contains("sources=browserMainAmd,browserMainBase,nodeMainBase")); | |
| 93 | assertTrue(result.getOutput().contains( |
|
93 | assertTrue(result.getOutput().contains("events=mainAmd:browserMainAmd|mainBase:browserMainBase|mainBase:nodeMainBase")); | |
| 94 | "events=browser:main:mainAmd:browserMainAmd|browser:main:mainBase:browserMainBase|node:main:mainBase:nodeMainBase")); |
|
94 | assertTrue(result.getOutput().contains("local=mainAmd:browserMainAmd")); | |
| 95 | assertTrue(result.getOutput().contains("local=browser:main:mainAmd:browserMainAmd")); |
|
|||
| 96 | assertTrue(result.getOutput().contains("outputs=ok")); |
|
95 | assertTrue(result.getOutput().contains("outputs=ok")); | |
| 97 | assertTrue(result.task(":probe").getOutcome() == TaskOutcome.SUCCESS); |
|
96 | assertTrue(result.task(":probe").getOutcome() == TaskOutcome.SUCCESS); | |
| 98 | } |
|
97 | } | |
| @@ -158,7 +157,7 class VariantsSourcesPluginFunctionalTes | |||||
| 158 | } |
|
157 | } | |
| 159 |
|
158 | |||
| 160 | @Test |
|
159 | @Test | |
| 161 |
void exposesProviderInSourceSetRegist |
|
160 | void exposesProviderInSourceSetRegistration() throws Exception { | |
| 162 | writeFile(SETTINGS_FILE, ROOT_NAME); |
|
161 | writeFile(SETTINGS_FILE, ROOT_NAME); | |
| 163 | writeFile(BUILD_FILE, """ |
|
162 | writeFile(BUILD_FILE, """ | |
| 164 | plugins { |
|
163 | plugins { | |
| @@ -264,9 +263,9 class VariantsSourcesPluginFunctionalTes | |||||
| 264 | } |
|
263 | } | |
| 265 |
|
264 | |||
| 266 | def registeredEvents = [] |
|
265 | def registeredEvents = [] | |
| 267 | def browserRegisteredEvents = [] |
|
|||
| 268 | def boundEvents = [] |
|
266 | def boundEvents = [] | |
| 269 | def browserBoundEvents = [] |
|
267 | def browserBoundEvents = [] | |
|
|
268 | def localRegisteredEvents = [] | |||
| 270 | def localBoundEvents = [] |
|
269 | def localBoundEvents = [] | |
| 271 |
|
270 | |||
| 272 | variantSources { |
|
271 | variantSources { | |
| @@ -279,17 +278,19 class VariantsSourcesPluginFunctionalTes | |||||
| 279 | } |
|
278 | } | |
| 280 |
|
279 | |||
| 281 | bind('main') { |
|
280 | bind('main') { | |
|
|
281 | whenRegistered { | |||
|
|
282 | localRegisteredEvents << "${layerName()}:${sourceSetName()}" | |||
|
|
283 | } | |||
|
|
284 | } | |||
|
|
285 | ||||
|
|
286 | bind('main') { | |||
| 282 | whenBound { |
|
287 | whenBound { | |
| 283 | localBoundEvents << "${variantName()}:${roleName()}:${layerName()}:${sourceSetName()}" |
|
288 | localBoundEvents << "${variantName()}:${roleName()}:${layerName()}:${sourceSetName()}" | |
| 284 | } |
|
289 | } | |
| 285 | } |
|
290 | } | |
| 286 |
|
291 | |||
| 287 | whenRegistered { ctx -> |
|
292 | whenRegistered { ctx -> | |
| 288 |
registeredEvents << " |
|
293 | registeredEvents << "${ctx.layerName()}:${ctx.sourceSetName()}" | |
| 289 | } |
|
|||
| 290 |
|
||||
| 291 | whenRegistered('browser') { ctx -> |
|
|||
| 292 | browserRegisteredEvents << "${ctx.variantName()}:${ctx.roleName()}:${ctx.layerName()}:${ctx.sourceSetName()}" |
|
|||
| 293 | } |
|
294 | } | |
| 294 |
|
295 | |||
| 295 | whenBound { ctx -> |
|
296 | whenBound { ctx -> | |
| @@ -309,7 +310,7 class VariantsSourcesPluginFunctionalTes | |||||
| 309 | main.output('compiled') |
|
310 | main.output('compiled') | |
| 310 |
|
311 | |||
| 311 | println("registered=" + registeredEvents.sort().join('|')) |
|
312 | println("registered=" + registeredEvents.sort().join('|')) | |
| 312 |
println(" |
|
313 | println("localRegistered=" + localRegisteredEvents.sort().join('|')) | |
| 313 | println("bound=" + boundEvents.sort().join('|')) |
|
314 | println("bound=" + boundEvents.sort().join('|')) | |
| 314 | println("browserBound=" + browserBoundEvents.sort().join('|')) |
|
315 | println("browserBound=" + browserBoundEvents.sort().join('|')) | |
| 315 | println("localBound=" + localBoundEvents.sort().join('|')) |
|
316 | println("localBound=" + localBoundEvents.sort().join('|')) | |
| @@ -320,8 +321,8 class VariantsSourcesPluginFunctionalTes | |||||
| 320 |
|
321 | |||
| 321 | BuildResult result = runner("probe").build(); |
|
322 | BuildResult result = runner("probe").build(); | |
| 322 | assertTrue(result.getOutput().contains("sources=main")); |
|
323 | assertTrue(result.getOutput().contains("sources=main")); | |
| 323 |
assertTrue(result.getOutput().contains("registered= |
|
324 | assertTrue(result.getOutput().contains("registered=main:main")); | |
| 324 |
assertTrue(result.getOutput().contains(" |
|
325 | assertTrue(result.getOutput().contains("localRegistered=main:main")); | |
| 325 | assertTrue(result.getOutput().contains("bound=browser:main:main:main|node:main:main:main")); |
|
326 | assertTrue(result.getOutput().contains("bound=browser:main:main:main|node:main:main:main")); | |
| 326 | assertTrue(result.getOutput().contains("browserBound=browser:main:main:main")); |
|
327 | assertTrue(result.getOutput().contains("browserBound=browser:main:main:main")); | |
| 327 | assertTrue(result.getOutput().contains("localBound=browser:main:main:main|node:main:main:main")); |
|
328 | assertTrue(result.getOutput().contains("localBound=browser:main:main:main|node:main:main:main")); | |
| @@ -97,14 +97,22 Tokens: | |||||
| 97 |
|
97 | |||
| 98 | ### variant filter |
|
98 | ### variant filter | |
| 99 |
|
99 | |||
| 100 | Глобальные callbacks поддерживают фильтр по варианту: |
|
100 | Фильтр по варианту поддерживает только usage-binding: | |
| 101 |
|
101 | |||
| 102 | - `whenRegistered(String variantName, ...)` |
|
|||
| 103 | - `whenBound(String variantName, ...)` |
|
102 | - `whenBound(String variantName, ...)` | |
| 104 |
|
103 | |||
| 105 | ## SOURCE SET CONTEXT |
|
104 | ## PAYLOAD TYPES | |
|
|
105 | ||||
|
|
106 | `SourceSetRegistration` содержит: | |||
| 106 |
|
107 | |||
| 107 | `SourceSetContext` содержит: |
|
108 | - `layerName`, `sourceSetName`; | |
|
|
109 | - `sourceSet` (`NamedDomainObjectProvider<GenericSourceSet>`). | |||
|
|
110 | ||||
|
|
111 | Sugar: | |||
|
|
112 | ||||
|
|
113 | - `configureSourceSet(Action|Closure)`. | |||
|
|
114 | ||||
|
|
115 | `SourceSetUsageBinding` содержит: | |||
| 108 |
|
116 | |||
| 109 | - `variantName`, `roleName`, `layerName`, `sourceSetName`; |
|
117 | - `variantName`, `roleName`, `layerName`, `sourceSetName`; | |
| 110 | - `sourceSet` (`NamedDomainObjectProvider<GenericSourceSet>`). |
|
118 | - `sourceSet` (`NamedDomainObjectProvider<GenericSourceSet>`). | |
| @@ -122,6 +130,7 Sugar: | |||||
| 122 | - `bindings(Action|Closure)` — контейнерная конфигурация bindings. |
|
130 | - `bindings(Action|Closure)` — контейнерная конфигурация bindings. | |
| 123 | - `whenRegistered(...)` — глобальные callbacks регистрации source set. |
|
131 | - `whenRegistered(...)` — глобальные callbacks регистрации source set. | |
| 124 | - `whenBound(...)` — глобальные callbacks usage-binding. |
|
132 | - `whenBound(...)` — глобальные callbacks usage-binding. | |
|
|
133 | - `whenBound(String variantName, ...)` — usage-binding callbacks с variant-filter. | |||
| 125 |
|
134 | |||
| 126 | ### BuildLayerBinding |
|
135 | ### BuildLayerBinding | |
| 127 |
|
136 | |||
| @@ -135,7 +144,8 Sugar: | |||||
| 135 | - `VariantsSourcesPlugin` — точка входа plugin adapter. |
|
144 | - `VariantsSourcesPlugin` — точка входа plugin adapter. | |
| 136 | - `VariantSourcesExtension` — глобальный DSL bind/events. |
|
145 | - `VariantSourcesExtension` — глобальный DSL bind/events. | |
| 137 | - `BuildLayerBinding` — layer-local policy и callbacks. |
|
146 | - `BuildLayerBinding` — layer-local policy и callbacks. | |
| 138 | - `SourceSetContext` — payload callbacks и sugar-конфигурирование. |
|
147 | - `SourceSetRegistration` — payload регистрации source set. | |
|
|
148 | - `SourceSetUsageBinding` — payload usage-binding. | |||
| 139 |
|
149 | |||
| 140 | ## NOTES |
|
150 | ## NOTES | |
| 141 |
|
151 | |||
| 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
