Build scripts: redownload jdk and jbre if previous download was

interrupted
This commit is contained in:
Alexander Zolotov
2017-09-14 14:21:07 +02:00
parent b5dd348425
commit 5ebc436808
3 changed files with 45 additions and 4 deletions

View File

@@ -1,3 +1,5 @@
import de.undercouch.gradle.tasks.download.DownloadAction
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
@@ -50,6 +52,47 @@ catch (UnknownHostException e) {
project.ext.inJetBrainsNetwork = false
}
class DownloadActionWrapper extends DownloadAction {
DownloadActionWrapper(Project project) {
super(project)
}
@Override
void execute() throws IOException {
def destFile = getDest()
if (destFile == null || !destFile.exists()) {
def tempFile = new File(destFile.absolutePath + ".part")
dest(tempFile)
overwrite(true)
onlyIfNewer(false)
super.execute()
dest(destFile)
tempFile.renameTo(destFile)
}
}
}
class DownloadWrapperExtension implements Configurable<DownloadWrapperExtension> {
Project project
DownloadWrapperExtension(Project project) {
this.project = project
}
@Override
DownloadWrapperExtension configure(Closure cl) {
DownloadActionWrapper da = ConfigureUtil.configure(cl, new DownloadActionWrapper(project))
try {
da.execute()
}
catch (IOException e) {
throw new IllegalStateException("Could not download file", e)
}
return this
}
}
project.extensions.create('downloadWrapper', DownloadWrapperExtension.class, project)
apply from: 'setupJdk.gradle'
apply from: 'setupJbre.gradle'
apply from: 'setupKotlin.gradle'

View File

@@ -17,10 +17,9 @@ jrePlatformsToDownload(targetOs).each { platform ->
outputs.file(outputFile)
doLast {
logger.info("Downloading $jbrexArtifactName to $outputFile")
download {
downloadWrapper {
src "$jdkRepo/${jbrexArtifactName}.tar.gz"
dest outputFile
onlyIfNewer true
}
}
}

View File

@@ -34,10 +34,9 @@ task downloadJdk18 {
outputs.file(outputFile)
doLast {
logger.info("Downloading up JDK 1.8 to compile (using $jdkRepo repo)")
download {
downloadWrapper {
src "$jdkRepo/intellij-jdk/${artifactName}"
dest outputFile
onlyIfNewer true
}
}
}