Increase timeouts for Crowdin API build task (#1602)
This commit is contained in:
parent
b93f404890
commit
75cc49d51f
1 changed files with 24 additions and 16 deletions
|
@ -7,6 +7,7 @@ package crowdin
|
||||||
|
|
||||||
import de.undercouch.gradle.tasks.download.Download
|
import de.undercouch.gradle.tasks.download.Download
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.xml.parsers.DocumentBuilderFactory
|
import javax.xml.parsers.DocumentBuilderFactory
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
@ -34,6 +35,7 @@ class CrowdinDownloadPlugin : Plugin<Project> {
|
||||||
if (projectName.isEmpty()) {
|
if (projectName.isEmpty()) {
|
||||||
throw GradleException(EXCEPTION_MESSAGE)
|
throw GradleException(EXCEPTION_MESSAGE)
|
||||||
}
|
}
|
||||||
|
val buildOnApi =
|
||||||
tasks.register("buildOnApi") {
|
tasks.register("buildOnApi") {
|
||||||
doLast {
|
doLast {
|
||||||
val login = providers.environmentVariable("CROWDIN_LOGIN").forUseAtConfigurationTime()
|
val login = providers.environmentVariable("CROWDIN_LOGIN").forUseAtConfigurationTime()
|
||||||
|
@ -45,7 +47,13 @@ class CrowdinDownloadPlugin : Plugin<Project> {
|
||||||
if (!key.isPresent) {
|
if (!key.isPresent) {
|
||||||
throw GradleException("CROWDIN_PROJECT_KEY environment variable must be set")
|
throw GradleException("CROWDIN_PROJECT_KEY environment variable must be set")
|
||||||
}
|
}
|
||||||
val client = OkHttpClient()
|
val client =
|
||||||
|
OkHttpClient.Builder()
|
||||||
|
.connectTimeout(5, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(5, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(5, TimeUnit.SECONDS)
|
||||||
|
.callTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.build()
|
||||||
val url = CROWDIN_BUILD_API_URL.format(projectName, login.get(), key.get())
|
val url = CROWDIN_BUILD_API_URL.format(projectName, login.get(), key.get())
|
||||||
val request = Request.Builder().url(url).get().build()
|
val request = Request.Builder().url(url).get().build()
|
||||||
client.newCall(request).execute()
|
client.newCall(request).execute()
|
||||||
|
@ -53,7 +61,7 @@ class CrowdinDownloadPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
val downloadCrowdin =
|
val downloadCrowdin =
|
||||||
tasks.register<Download>("downloadCrowdin") {
|
tasks.register<Download>("downloadCrowdin") {
|
||||||
dependsOn("buildOnApi")
|
dependsOn(buildOnApi)
|
||||||
src("https://crowdin.com/backend/download/project/$projectName.zip")
|
src("https://crowdin.com/backend/download/project/$projectName.zip")
|
||||||
dest("$buildDirectory/translations.zip")
|
dest("$buildDirectory/translations.zip")
|
||||||
overwrite(true)
|
overwrite(true)
|
||||||
|
|
Loading…
Reference in a new issue