summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-05-07 17:42:51 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-05-09 11:52:33 +0530
commit00e0881e47fc1f9d7accb6a242417f7be636a9be (patch)
tree4011aa21bd207a95b098ab7a214b6891a119fee6
parent2ab47ca6ad3ade522f802b766b36df4733d7f404 (diff)
build: fix Crowdin plugin resolving variables eagerly
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
-rw-r--r--buildSrc/src/main/java/CrowdinDownloadPlugin.kt33
1 files changed, 18 insertions, 15 deletions
diff --git a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
index e8bf7b5b..05fbabb8 100644
--- a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
+++ b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
@@ -31,33 +31,36 @@ class CrowdinDownloadPlugin : Plugin<Project> {
throw GradleException(EXCEPTION_MESSAGE)
}
tasks.register("buildOnApi") {
- 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")
+ 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()
+ 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()
}
tasks.register<Download>("downloadCrowdin") {
- setDependsOn(setOf("buildOnApi"))
+ dependsOn("buildOnApi")
src("https://crowdin.com/backend/download/project/$projectName.zip")
dest("$buildDir/translations.zip")
overwrite(true)
}
tasks.register<Copy>("extractCrowdin") {
- setDependsOn(setOf("downloadCrowdin"))
+ dependsOn("downloadCrowdin")
doFirst { File(buildDir, "translations").deleteRecursively() }
from(zipTree("$buildDir/translations.zip"))
into("$buildDir/translations")
}
tasks.register<Copy>("extractStrings") {
- setDependsOn(setOf("extractCrowdin"))
+ dependsOn("extractCrowdin")
from("$buildDir/translations/")
into("${projectDir}/src/")
setFinalizedBy(setOf("removeIncompleteStrings"))
@@ -86,7 +89,7 @@ class CrowdinDownloadPlugin : Plugin<Project> {
}
}
tasks.register("crowdin") {
- setDependsOn(setOf("extractStrings"))
+ dependsOn("extractStrings")
if (!extension.skipCleanup) {
doLast {
File("$buildDir/translations").deleteRecursively()