aboutsummaryrefslogtreecommitdiff
path: root/build-logic/automation-plugins
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-12-23 12:45:29 +0530
committerGitHub <noreply@github.com>2021-12-23 07:15:29 +0000
commit75cc49d51f3aa4e64a80b81a2b230a5e7563db6e (patch)
tree8ac321b7ceed002a3cf26b6351d545b7b0b417ad /build-logic/automation-plugins
parentb93f4048902b832c27f5e14c9bfc32fa0133f0ce (diff)
Increase timeouts for Crowdin API build task (#1602)
Diffstat (limited to 'build-logic/automation-plugins')
-rw-r--r--build-logic/automation-plugins/src/main/kotlin/crowdin/CrowdinPlugin.kt40
1 files changed, 24 insertions, 16 deletions
diff --git a/build-logic/automation-plugins/src/main/kotlin/crowdin/CrowdinPlugin.kt b/build-logic/automation-plugins/src/main/kotlin/crowdin/CrowdinPlugin.kt
index 580fc939..c6542725 100644
--- a/build-logic/automation-plugins/src/main/kotlin/crowdin/CrowdinPlugin.kt
+++ b/build-logic/automation-plugins/src/main/kotlin/crowdin/CrowdinPlugin.kt
@@ -7,6 +7,7 @@ package crowdin
import de.undercouch.gradle.tasks.download.Download
import java.io.File
+import java.util.concurrent.TimeUnit
import javax.xml.parsers.DocumentBuilderFactory
import okhttp3.OkHttpClient
import okhttp3.Request
@@ -34,26 +35,33 @@ class CrowdinDownloadPlugin : Plugin<Project> {
if (projectName.isEmpty()) {
throw GradleException(EXCEPTION_MESSAGE)
}
- tasks.register("buildOnApi") {
- doLast {
- val login = providers.environmentVariable("CROWDIN_LOGIN").forUseAtConfigurationTime()
- val key =
- providers.environmentVariable("CROWDIN_PROJECT_KEY").forUseAtConfigurationTime()
- if (!login.isPresent) {
- throw GradleException("CROWDIN_LOGIN environment variable must be set")
- }
- if (!key.isPresent) {
- throw GradleException("CROWDIN_PROJECT_KEY environment variable must be set")
+ val buildOnApi =
+ tasks.register("buildOnApi") {
+ doLast {
+ val login = providers.environmentVariable("CROWDIN_LOGIN").forUseAtConfigurationTime()
+ val key =
+ providers.environmentVariable("CROWDIN_PROJECT_KEY").forUseAtConfigurationTime()
+ if (!login.isPresent) {
+ throw GradleException("CROWDIN_LOGIN environment variable must be set")
+ }
+ if (!key.isPresent) {
+ throw GradleException("CROWDIN_PROJECT_KEY environment variable must be set")
+ }
+ 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 request = Request.Builder().url(url).get().build()
+ client.newCall(request).execute()
}
- val client = OkHttpClient()
- val url = CROWDIN_BUILD_API_URL.format(projectName, login.get(), key.get())
- val request = Request.Builder().url(url).get().build()
- client.newCall(request).execute()
}
- }
val downloadCrowdin =
tasks.register<Download>("downloadCrowdin") {
- dependsOn("buildOnApi")
+ dependsOn(buildOnApi)
src("https://crowdin.com/backend/download/project/$projectName.zip")
dest("$buildDirectory/translations.zip")
overwrite(true)