Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c5e2bf5c
Unverified
Commit
c5e2bf5c
authored
Sep 11, 2019
by
Christopher Fujino
Committed by
GitHub
Sep 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
catch errors during gradle update (#37526)
parent
2c94f2b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
1 deletion
+115
-1
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+11
-1
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+104
-0
No files found.
packages/flutter_tools/lib/src/android/gradle.dart
View file @
c5e2bf5c
...
...
@@ -12,6 +12,7 @@ import '../artifacts.dart';
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
...
...
@@ -310,7 +311,16 @@ Future<String> _initializeGradle(FlutterProject project) async {
printTrace
(
'Using gradle from
$gradle
.'
);
// Validates the Gradle executable by asking for its version.
// Makes Gradle Wrapper download and install Gradle distribution, if needed.
await
runCheckedAsync
(<
String
>[
gradle
,
'-v'
],
environment:
_gradleEnv
);
try
{
await
runCheckedAsync
(<
String
>[
gradle
,
'-v'
],
environment:
_gradleEnv
);
}
catch
(
e
)
{
if
(
e
is
ProcessException
&&
e
.
toString
().
contains
(
'java.io.FileNotFoundException: https://downloads.gradle.org'
)
||
e
.
toString
().
contains
(
'java.io.IOException: Unable to tunnel through proxy'
))
{
throwToolExit
(
'
$gradle
threw an error while trying to update itself.
\n
$e
'
);
}
rethrow
;
}
status
.
stop
();
return
gradle
;
}
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
c5e2bf5c
...
...
@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/artifacts.dart';
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/ios/xcodeproj.dart'
;
...
...
@@ -849,6 +850,109 @@ flutter:
});
});
group
(
'Gradle HTTP failures'
,
()
{
MemoryFileSystem
fs
;
Directory
tempDir
;
Directory
gradleWrapperDirectory
;
MockProcessManager
mockProcessManager
;
String
gradleBinary
;
setUp
(()
{
fs
=
MemoryFileSystem
();
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'artifacts_test.'
);
gradleBinary
=
platform
.
isWindows
?
'gradlew.bat'
:
'gradlew'
;
gradleWrapperDirectory
=
fs
.
directory
(
fs
.
path
.
join
(
tempDir
.
path
,
'bin'
,
'cache'
,
'artifacts'
,
'gradle_wrapper'
));
gradleWrapperDirectory
.
createSync
(
recursive:
true
);
gradleWrapperDirectory
.
childFile
(
gradleBinary
)
.
writeAsStringSync
(
'irrelevant'
);
gradleWrapperDirectory
.
childDirectory
(
'gradle'
)
.
childDirectory
(
'wrapper'
)
.
createSync
(
recursive:
true
);
gradleWrapperDirectory
.
childDirectory
(
'gradle'
)
.
childDirectory
(
'wrapper'
)
.
childFile
(
'gradle-wrapper.jar'
)
.
writeAsStringSync
(
'irrelevant'
);
mockProcessManager
=
MockProcessManager
();
});
testUsingContext
(
'throws toolExit if gradle fails while downloading'
,
()
async
{
final
List
<
String
>
cmd
=
<
String
>[
fs
.
path
.
join
(
fs
.
currentDirectory
.
path
,
'android'
,
gradleBinary
),
'-v'
,
];
const
String
errorMessage
=
'''
Exception in thread "main" java.io.FileNotFoundException: https://downloads.gradle.org/distributions/gradle-4.1.1-all.zip
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1872)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install
\$
1.call(Install.java:61)
at org.gradle.wrapper.Install
\$
1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)'''
;
final
ProcessException
exception
=
ProcessException
(
gradleBinary
,
<
String
>[
'-v'
],
errorMessage
,
1
,
);
when
(
mockProcessManager
.
run
(
cmd
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
)))
.
thenThrow
(
exception
);
await
expectLater
(()
async
{
await
checkGradleDependencies
();
},
throwsToolExit
(
message:
errorMessage
));
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
Cache
(
rootOverride:
tempDir
),
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'throw toolExit if gradle fails downloading with proxy error'
,
()
async
{
final
List
<
String
>
cmd
=
<
String
>[
fs
.
path
.
join
(
fs
.
currentDirectory
.
path
,
'android'
,
gradleBinary
),
'-v'
,
];
const
String
errorMessage
=
'''
Exception in thread "main" java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Request"
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2124)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1546)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install
\$
1.call(Install.java:61)
at org.gradle.wrapper.Install
\$
1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)'''
;
final
ProcessException
exception
=
ProcessException
(
gradleBinary
,
<
String
>[
'-v'
],
errorMessage
,
1
,
);
when
(
mockProcessManager
.
run
(
cmd
,
environment:
anyNamed
(
'environment'
),
workingDirectory:
null
))
.
thenThrow
(
exception
);
await
expectLater
(()
async
{
await
checkGradleDependencies
();
},
throwsToolExit
(
message:
errorMessage
));
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
Cache
(
rootOverride:
tempDir
),
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
});
});
group
(
'injectGradleWrapperIfNeeded'
,
()
{
MemoryFileSystem
memoryFileSystem
;
Directory
tempDir
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment