@@ -37,7 +37,7 @@ class ConfigurationFilterDependencyExtractorTest extends BaseExtractorTest {
37
37
38
38
def " can filter projects to extract dependencies" () {
39
39
given :
40
- settingsFile << " include 'a', 'b'"
40
+ settingsFile << " include 'a', 'b', 'c' "
41
41
42
42
buildFile << """
43
43
project(':a') {
@@ -52,18 +52,45 @@ class ConfigurationFilterDependencyExtractorTest extends BaseExtractorTest {
52
52
api 'org.test:bar:1.0'
53
53
}
54
54
}
55
+ project(':c') {
56
+ apply plugin: 'java-library'
57
+ dependencies {
58
+ api 'org.test:baz:1.0'
59
+ }
60
+ }
55
61
"""
56
62
57
63
when :
58
64
executer. withArgument(" -DDEPENDENCY_GRAPH_INCLUDE_PROJECTS=:b" )
59
65
run()
60
66
61
67
then :
62
- def manifest = gitHubManifest()
63
- manifest. sourceFile == " settings.gradle"
64
- manifest. assertResolved([
65
- " org.test:bar:1.0" : [package_url : purlFor(bar)]
66
- ])
68
+ gitHubManifest(). assertResolved([" org.test:bar:1.0" ])
69
+
70
+ when :
71
+ resetArguments()
72
+ executer. withArgument(" -DDEPENDENCY_GRAPH_INCLUDE_PROJECTS=:[ab]" )
73
+ run()
74
+
75
+ then :
76
+ gitHubManifest(). assertResolved([" org.test:foo:1.0" , " org.test:bar:1.0" ])
77
+
78
+ when :
79
+ resetArguments()
80
+ executer. withArgument(" -DDEPENDENCY_GRAPH_EXCLUDE_PROJECTS=:[bc]" )
81
+ run()
82
+
83
+ then :
84
+ gitHubManifest(). assertResolved([" org.test:foo:1.0" ])
85
+
86
+ when :
87
+ resetArguments()
88
+ executer. withArgument(" -DDEPENDENCY_GRAPH_INCLUDE_PROJECTS=:[ab]" )
89
+ executer. withArgument(" -DDEPENDENCY_GRAPH_EXCLUDE_PROJECTS=:b" )
90
+ run()
91
+
92
+ then :
93
+ gitHubManifest(). assertResolved([" org.test:foo:1.0" ])
67
94
}
68
95
69
96
def " can filter configurations to extract dependencies" () {
@@ -92,12 +119,15 @@ class ConfigurationFilterDependencyExtractorTest extends BaseExtractorTest {
92
119
run()
93
120
94
121
then :
95
- def manifest = gitHubManifest()
96
- manifest. sourceFile == " settings.gradle"
97
- manifest. assertResolved([
98
- " org.test:foo:1.0" : [package_url : purlFor(foo)],
99
- " org.test:bar:1.0" : [package_url : purlFor(bar)]
100
- ])
122
+ gitHubManifest(). assertResolved([" org.test:foo:1.0" , " org.test:bar:1.0" ])
123
+
124
+ when :
125
+ resetArguments()
126
+ executer. withArgument(" -DDEPENDENCY_GRAPH_EXCLUDE_CONFIGURATIONS=test(Compile|Runtime)Classpath" )
127
+ run()
128
+
129
+ then :
130
+ gitHubManifest(). assertResolved([" org.test:foo:1.0" , " org.test:bar:1.0" ])
101
131
}
102
132
103
133
def " can filter runtime projects to determine scope" () {
@@ -120,50 +150,36 @@ class ConfigurationFilterDependencyExtractorTest extends BaseExtractorTest {
120
150
"""
121
151
122
152
when :
123
- executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_PROJECTS =:a" )
153
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_INCLUDE_PROJECTS =:a" )
124
154
run()
125
155
126
156
then :
127
- def manifest = gitHubManifest()
128
- manifest. sourceFile == " settings.gradle"
129
- manifest. assertResolved([
130
- " org.test:foo:1.0" : [package_url : purlFor(foo), scope : " runtime" ],
131
- " org.test:bar:1.0" : [package_url : purlFor(bar), scope : " development" ],
157
+ gitHubManifest(). assertResolved([
158
+ " org.test:foo:1.0" : [scope : " runtime" ],
159
+ " org.test:bar:1.0" : [scope : " development" ]
132
160
])
133
- }
134
161
135
- def " can filter runtime configurations to determine scope" () {
136
- given :
137
- settingsFile << " include 'a', 'b'"
162
+ when :
163
+ resetArguments()
164
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_EXCLUDE_PROJECTS=:b" )
165
+ run()
138
166
139
- buildFile << """
140
- project(':a') {
141
- apply plugin: 'java-library'
142
- dependencies {
143
- api 'org.test:foo:1.0'
144
- testImplementation 'org.test:baz:1.0'
145
- }
146
- }
147
- project(':b') {
148
- apply plugin: 'java-library'
149
- dependencies {
150
- implementation 'org.test:bar:1.0'
151
- testImplementation 'org.test:baz:1.0'
152
- }
153
- }
154
- """
167
+ then :
168
+ gitHubManifest(). assertResolved([
169
+ " org.test:foo:1.0" : [scope : " runtime" ],
170
+ " org.test:bar:1.0" : [scope : " development" ]
171
+ ])
155
172
156
173
when :
157
- executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_CONFIGURATIONS=compileClasspath" )
174
+ resetArguments()
175
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_INCLUDE_PROJECTS=:[ab]" )
176
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_EXCLUDE_PROJECTS=:b" )
158
177
run()
159
178
160
179
then :
161
- def manifest = gitHubManifest()
162
- manifest. sourceFile == " settings.gradle"
163
- manifest. assertResolved([
164
- " org.test:foo:1.0" : [package_url : purlFor(foo), scope : " runtime" ],
165
- " org.test:bar:1.0" : [package_url : purlFor(bar), scope : " runtime" ],
166
- " org.test:baz:1.0" : [package_url : purlFor(baz), scope : " development" , dependencies : [" org.test:bar:1.0" ]]
180
+ gitHubManifest(). assertResolved([
181
+ " org.test:foo:1.0" : [scope : " runtime" ],
182
+ " org.test:bar:1.0" : [scope : " development" ]
167
183
])
168
184
}
169
185
@@ -189,22 +205,45 @@ class ConfigurationFilterDependencyExtractorTest extends BaseExtractorTest {
189
205
"""
190
206
191
207
when :
192
- executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_CONFIGURATIONS=compileClasspath" )
208
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_INCLUDE_CONFIGURATIONS=compileClasspath" )
209
+ run()
210
+
211
+ then :
212
+ gitHubManifest(). assertResolved([
213
+ " org.test:foo:1.0" : [scope : " runtime" ],
214
+ " org.test:bar:1.0" : [scope : " runtime" ],
215
+ " org.test:baz:1.0" : [scope : " development" , dependencies : [" org.test:bar:1.0" ]]
216
+ ])
217
+
218
+ when :
219
+ resetArguments()
220
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_INCLUDE_CONFIGURATIONS=.*Classpath" )
193
221
run()
194
222
195
223
then :
196
- def manifest = gitHubManifest()
197
- manifest. sourceFile == " settings.gradle"
198
- manifest. assertResolved([
199
- " org.test:foo:1.0" : [package_url : purlFor(foo), scope : " runtime" ],
200
- " org.test:bar:1.0" : [package_url : purlFor(bar), scope : " runtime" ],
201
- " org.test:baz:1.0" : [package_url : purlFor(baz), scope : " development" , dependencies : [" org.test:bar:1.0" ]]
224
+ gitHubManifest(). assertResolved([
225
+ " org.test:foo:1.0" : [scope : " runtime" ],
226
+ " org.test:bar:1.0" : [scope : " runtime" ],
227
+ " org.test:baz:1.0" : [scope : " runtime" , dependencies : [" org.test:bar:1.0" ]]
228
+ ])
229
+
230
+ when :
231
+ resetArguments()
232
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_INCLUDE_CONFIGURATIONS=.*Classpath" )
233
+ executer. withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_EXCLUDE_CONFIGURATIONS=test(Compile|Runtime)Classpath" )
234
+ run()
235
+
236
+ then :
237
+ gitHubManifest(). assertResolved([
238
+ " org.test:foo:1.0" : [scope : " runtime" ],
239
+ " org.test:bar:1.0" : [scope : " runtime" ],
240
+ " org.test:baz:1.0" : [scope : " development" , dependencies : [" org.test:bar:1.0" ]]
202
241
])
203
242
}
204
243
205
244
def " can filter runtime projects and configurations to determine scope" () {
206
245
given :
207
- settingsFile << " include 'a', 'b'"
246
+ settingsFile << " include 'a', 'b', 'c' "
208
247
209
248
buildFile << """
210
249
project(':a') {
@@ -221,21 +260,27 @@ class ConfigurationFilterDependencyExtractorTest extends BaseExtractorTest {
221
260
testImplementation 'org.test:baz:1.0'
222
261
}
223
262
}
263
+ project(':b') {
264
+ apply plugin: 'java-library'
265
+ dependencies {
266
+ api 'org.test:baz:1.0'
267
+ }
268
+ }
224
269
"""
225
270
226
271
when :
227
272
executer
228
- .withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_CONFIGURATIONS=compileClasspath" )
229
- .withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_PROJECTS=:a" )
273
+ .withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_INCLUDE_PROJECTS=:[ab]" )
274
+ .withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_INCLUDE_CONFIGURATIONS=.*Classpath" )
275
+ .withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_EXCLUDE_PROJECTS=:b" )
276
+ .withArgument(" -DDEPENDENCY_GRAPH_RUNTIME_EXCLUDE_CONFIGURATIONS=test(Compile|Runtime)Classpath" )
230
277
run()
231
278
232
279
then :
233
- def manifest = gitHubManifest()
234
- manifest. sourceFile == " settings.gradle"
235
- manifest. assertResolved([
236
- " org.test:foo:1.0" : [package_url : purlFor(foo), scope : " runtime" ],
237
- " org.test:bar:1.0" : [package_url : purlFor(bar), scope : " development" ],
238
- " org.test:baz:1.0" : [package_url : purlFor(baz), scope : " development" , dependencies : [" org.test:bar:1.0" ]]
280
+ gitHubManifest(). assertResolved([
281
+ " org.test:foo:1.0" : [scope : " runtime" ],
282
+ " org.test:bar:1.0" : [scope : " development" ],
283
+ " org.test:baz:1.0" : [scope : " development" , dependencies : [" org.test:bar:1.0" ]]
239
284
])
240
285
}
241
286
0 commit comments