我需要使用gradle从github获取文件。我找到了this plugin。以下示例适用于我:
task downloadZipFile(type: Download) {
src 'https://github.com/michel-kraemer/gradle-download-task/archive/1.0.zip'
dest new File(buildDir, '1.0.zip')
}
但是当我用我需要的URL替换URL时:(https://github.com/broadinstitute/cromwell/releases/download/0.19/cromwell-0.19.jar)我收到以下错误:
8:00:37 AM: Executing external task 'downloadZipFile'...
:downloadZipFile
Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Fri, 13 Jun 2036 12:00:38 -0000; secure; HttpOnly". Invalid 'expires' attribute: Fri, 13 Jun 2036 12:00:38 -0000
:downloadZipFileFAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':downloadZipFile'.
> javax.net.ssl.SSLPeerUnverifiedException: Host name 'github-cloud.s3.amazonaws.com' does not match the certificate subject provided by the peer (CN=*.s3.amazonaws.com, O=Amazon.com Inc., L=Seattle, ST=Washington, C=US)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.91 secs
Host name 'github-cloud.s3.amazonaws.com' does not match the certificate subject provided by the peer (CN=*.s3.amazonaws.com, O=Amazon.com Inc., L=Seattle, ST=Washington, C=US)
8:00:39 AM: External task execution finished 'downloadZipFile'.
什么可能是错的,我只是用另一个github URL替换github URL。
答案 0 :(得分:2)
按this comment,将以下内容添加到build.gradle
脚本的开头:
// Temporary workaround, see
// https://github.com/michel-kraemer/gradle-download-task/issues/56
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'de.undercouch:gradle-download-task:3.1.1'
classpath 'org.apache.httpcomponents:httpclient:4.5.2'
}
}
这对我有用。