@@ -76,6 +76,11 @@ private void scratchSystemImagesDirectories(String... pathFragments) throws Exce
76
76
}
77
77
78
78
private void scratchBuildToolsDirectories (String ... versions ) throws Exception {
79
+ if (versions .length == 0 ) {
80
+ // Use a large version number here so that we don't have to update this test as
81
+ // AndroidSdkRepositoryFunction.MIN_BUILD_TOOLS_REVISION increases.
82
+ versions = new String [] {"400.0.0" };
83
+ }
79
84
for (String version : versions ) {
80
85
scratch .dir ("/sdk/build-tools/" + version );
81
86
}
@@ -103,7 +108,7 @@ private void scratchExtrasLibrary(
103
108
@ Test
104
109
public void testGeneratedAarImport () throws Exception {
105
110
scratchPlatformsDirectories (25 );
106
- scratchBuildToolsDirectories ("26.0.1" );
111
+ scratchBuildToolsDirectories ();
107
112
scratchExtrasLibrary ("extras/google/m2repository" , "com.google.android" , "foo" , "1.0.0" , "aar" );
108
113
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
109
114
FileSystemUtils .appendIsoLatin1 (
@@ -125,7 +130,7 @@ public void testGeneratedAarImport() throws Exception {
125
130
@ Test
126
131
public void testExportsExtrasLibraryArtifacts () throws Exception {
127
132
scratchPlatformsDirectories (25 );
128
- scratchBuildToolsDirectories ("26.0.1" );
133
+ scratchBuildToolsDirectories ();
129
134
scratchExtrasLibrary ("extras/google/m2repository" , "com.google.android" , "foo" , "1.0.0" , "aar" );
130
135
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
131
136
FileSystemUtils .appendIsoLatin1 (
@@ -145,7 +150,7 @@ public void testExportsExtrasLibraryArtifacts() throws Exception {
145
150
@ Test
146
151
public void testKnownSdkMavenRepositories () throws Exception {
147
152
scratchPlatformsDirectories (25 );
148
- scratchBuildToolsDirectories ("26.0.1" );
153
+ scratchBuildToolsDirectories ();
149
154
scratchExtrasLibrary ("extras/google/m2repository" , "com.google.android" , "a" , "1.0.0" , "jar" );
150
155
scratchExtrasLibrary ("extras/android/m2repository" , "com.android.support" , "b" , "1.0.0" , "aar" );
151
156
scratchExtrasLibrary ("extras/m2repository" , "com.android.support" , "c" , "1.0.1" , "aar" );
@@ -176,7 +181,7 @@ public void testKnownSdkMavenRepositories() throws Exception {
176
181
@ Test
177
182
public void testSystemImageDirectoriesAreFound () throws Exception {
178
183
scratchPlatformsDirectories (25 );
179
- scratchBuildToolsDirectories ("26.0.1" );
184
+ scratchBuildToolsDirectories ();
180
185
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
181
186
FileSystemUtils .appendIsoLatin1 (
182
187
scratch .resolve ("WORKSPACE" ),
@@ -211,7 +216,7 @@ public void testSystemImageDirectoriesAreFound() throws Exception {
211
216
@ Test
212
217
public void testMalformedSystemImageDirectories () throws Exception {
213
218
scratchPlatformsDirectories (25 , 26 );
214
- scratchBuildToolsDirectories ("26.0.1" );
219
+ scratchBuildToolsDirectories ();
215
220
scratchSystemImagesDirectories ("android-25/default/armeabi-v7a" , "android-O/google_apis/x86" );
216
221
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
217
222
FileSystemUtils .appendIsoLatin1 (
@@ -225,10 +230,35 @@ public void testMalformedSystemImageDirectories() throws Exception {
225
230
assertThat (getConfiguredTarget ("@androidsdk//:emulator_images_android_25_arm" )).isNotNull ();
226
231
}
227
232
233
+ @ Test
234
+ public void testBuildToolsVersion () throws Exception {
235
+ scratchPlatformsDirectories (25 );
236
+ // Use large version numbers here so that we don't have to update this test as
237
+ // AndroidSdkRepositoryFunction.MIN_BUILD_TOOLS_REVISION increases.
238
+ scratchBuildToolsDirectories ("400.0.1" , "400.0.2" , "400.0.3" );
239
+ String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
240
+ FileSystemUtils .appendIsoLatin1 (
241
+ scratch .resolve ("WORKSPACE" ),
242
+ "local_repository(name = 'bazel_tools', path = '" + bazelToolsWorkspace + "')" ,
243
+ "android_sdk_repository(" ,
244
+ " name = 'androidsdk'," ,
245
+ " path = '/sdk'," ,
246
+ " build_tools_version = '400.0.2'," ,
247
+ ")" );
248
+ invalidatePackages ();
249
+
250
+ ConfiguredTarget androidSdk = getConfiguredTarget ("@androidsdk//:sdk" );
251
+ assertThat (androidSdk ).isNotNull ();
252
+ assertThat (androidSdk .get (AndroidSdkProvider .PROVIDER ).getBuildToolsVersion ())
253
+ .isEqualTo ("400.0.2" );
254
+ }
255
+
228
256
@ Test
229
257
public void testBuildToolsHighestVersionDetection () throws Exception {
230
258
scratchPlatformsDirectories (25 );
231
- scratchBuildToolsDirectories ("26.0.1" , "26.0.2" );
259
+ // Use large version numbers here so that we don't have to update this test as
260
+ // AndroidSdkRepositoryFunction.MIN_BUILD_TOOLS_REVISION increases.
261
+ scratchBuildToolsDirectories ("400.0.1" , "400.0.2" );
232
262
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
233
263
FileSystemUtils .appendIsoLatin1 (
234
264
scratch .resolve ("WORKSPACE" ),
@@ -243,21 +273,20 @@ public void testBuildToolsHighestVersionDetection() throws Exception {
243
273
ConfiguredTarget androidSdk = getConfiguredTarget ("@androidsdk//:sdk" );
244
274
assertThat (androidSdk ).isNotNull ();
245
275
assertThat (androidSdk .get (AndroidSdkProvider .PROVIDER ).getBuildToolsVersion ())
246
- .isEqualTo ("26 .0.2" );
276
+ .isEqualTo ("400 .0.2" );
247
277
}
248
278
249
279
@ Test
250
280
public void testApiLevelHighestVersionDetection () throws Exception {
251
281
scratchPlatformsDirectories (24 , 25 , 23 );
252
- scratchBuildToolsDirectories ("26.0.1" );
282
+ scratchBuildToolsDirectories ();
253
283
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
254
284
FileSystemUtils .appendIsoLatin1 (
255
285
scratch .resolve ("WORKSPACE" ),
256
286
"local_repository(name = 'bazel_tools', path = '" + bazelToolsWorkspace + "')" ,
257
287
"android_sdk_repository(" ,
258
288
" name = 'androidsdk'," ,
259
289
" path = '/sdk'," ,
260
- " build_tools_version = '26.0.1'," ,
261
290
")" );
262
291
invalidatePackages ();
263
292
@@ -271,7 +300,7 @@ public void testApiLevelHighestVersionDetection() throws Exception {
271
300
public void testMultipleAndroidSdkApiLevels () throws Exception {
272
301
int [] apiLevels = {23 , 24 , 25 };
273
302
scratchPlatformsDirectories (apiLevels );
274
- scratchBuildToolsDirectories ("26.0.1" );
303
+ scratchBuildToolsDirectories ();
275
304
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
276
305
FileSystemUtils .appendIsoLatin1 (
277
306
scratch .resolve ("WORKSPACE" ),
@@ -280,7 +309,6 @@ public void testMultipleAndroidSdkApiLevels() throws Exception {
280
309
" name = 'androidsdk'," ,
281
310
" path = '/sdk'," ,
282
311
" api_level = 24," ,
283
- " build_tools_version = '26.0.1'," ,
284
312
")" );
285
313
invalidatePackages ();
286
314
@@ -296,7 +324,7 @@ public void testMultipleAndroidSdkApiLevels() throws Exception {
296
324
@ Test
297
325
public void testMissingApiLevel () throws Exception {
298
326
scratchPlatformsDirectories (24 );
299
- scratchBuildToolsDirectories ("26.0.1" );
327
+ scratchBuildToolsDirectories ();
300
328
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
301
329
FileSystemUtils .appendIsoLatin1 (
302
330
scratch .resolve ("WORKSPACE" ),
@@ -305,7 +333,6 @@ public void testMissingApiLevel() throws Exception {
305
333
" name = 'androidsdk'," ,
306
334
" path = '/sdk'," ,
307
335
" api_level = 25," ,
308
- " build_tools_version = '26.0.1'," ,
309
336
")" );
310
337
invalidatePackages ();
311
338
reporter .removeHandler (failFastHandler );
@@ -326,7 +353,7 @@ public void testMissingApiLevel() throws Exception {
326
353
@ Test
327
354
public void testFilesInSystemImagesDirectories () throws Exception {
328
355
scratchPlatformsDirectories (24 );
329
- scratchBuildToolsDirectories ("26.0.1" );
356
+ scratchBuildToolsDirectories ();
330
357
scratch .file ("/sdk/system-images/.DS_Store" );
331
358
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
332
359
FileSystemUtils .appendIsoLatin1 (
@@ -343,7 +370,7 @@ public void testFilesInSystemImagesDirectories() throws Exception {
343
370
344
371
@ Test
345
372
public void testMissingPlatformsDirectory () throws Exception {
346
- scratchBuildToolsDirectories ("26.0.1" );
373
+ scratchBuildToolsDirectories ();
347
374
String bazelToolsWorkspace = scratch .dir ("bazel_tools_workspace" ).getPathString ();
348
375
FileSystemUtils .appendIsoLatin1 (
349
376
scratch .resolve ("WORKSPACE" ),
0 commit comments