build: fix Crowdin plugin resolving variables eagerly
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
2ab47ca6ad
commit
00e0881e47
1 changed files with 18 additions and 15 deletions
|
@ -31,8 +31,10 @@ class CrowdinDownloadPlugin : Plugin<Project> {
|
|||
throw GradleException(EXCEPTION_MESSAGE)
|
||||
}
|
||||
tasks.register("buildOnApi") {
|
||||
doLast {
|
||||
val login = providers.environmentVariable("CROWDIN_LOGIN").forUseAtConfigurationTime()
|
||||
val key = providers.environmentVariable("CROWDIN_PROJECT_KEY").forUseAtConfigurationTime()
|
||||
val key =
|
||||
providers.environmentVariable("CROWDIN_PROJECT_KEY").forUseAtConfigurationTime()
|
||||
if (!login.isPresent) {
|
||||
throw GradleException("CROWDIN_LOGIN environment variable must be set")
|
||||
}
|
||||
|
@ -44,20 +46,21 @@ class CrowdinDownloadPlugin : Plugin<Project> {
|
|||
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()
|
||||
|
|
Loading…
Reference in a new issue