mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 13:27:46 +00:00
build: fix Crowdin plugin resolving variables eagerly
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
2ab47ca6ad
commit
00e0881e47
@ -31,33 +31,36 @@ class CrowdinDownloadPlugin : Plugin<Project> {
|
|||||||
throw GradleException(EXCEPTION_MESSAGE)
|
throw GradleException(EXCEPTION_MESSAGE)
|
||||||
}
|
}
|
||||||
tasks.register("buildOnApi") {
|
tasks.register("buildOnApi") {
|
||||||
val login = providers.environmentVariable("CROWDIN_LOGIN").forUseAtConfigurationTime()
|
doLast {
|
||||||
val key = providers.environmentVariable("CROWDIN_PROJECT_KEY").forUseAtConfigurationTime()
|
val login = providers.environmentVariable("CROWDIN_LOGIN").forUseAtConfigurationTime()
|
||||||
if (!login.isPresent) {
|
val key =
|
||||||
throw GradleException("CROWDIN_LOGIN environment variable must be set")
|
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()
|
||||||
}
|
}
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
tasks.register<Download>("downloadCrowdin") {
|
tasks.register<Download>("downloadCrowdin") {
|
||||||
setDependsOn(setOf("buildOnApi"))
|
dependsOn("buildOnApi")
|
||||||
src("https://crowdin.com/backend/download/project/$projectName.zip")
|
src("https://crowdin.com/backend/download/project/$projectName.zip")
|
||||||
dest("$buildDir/translations.zip")
|
dest("$buildDir/translations.zip")
|
||||||
overwrite(true)
|
overwrite(true)
|
||||||
}
|
}
|
||||||
tasks.register<Copy>("extractCrowdin") {
|
tasks.register<Copy>("extractCrowdin") {
|
||||||
setDependsOn(setOf("downloadCrowdin"))
|
dependsOn("downloadCrowdin")
|
||||||
doFirst { File(buildDir, "translations").deleteRecursively() }
|
doFirst { File(buildDir, "translations").deleteRecursively() }
|
||||||
from(zipTree("$buildDir/translations.zip"))
|
from(zipTree("$buildDir/translations.zip"))
|
||||||
into("$buildDir/translations")
|
into("$buildDir/translations")
|
||||||
}
|
}
|
||||||
tasks.register<Copy>("extractStrings") {
|
tasks.register<Copy>("extractStrings") {
|
||||||
setDependsOn(setOf("extractCrowdin"))
|
dependsOn("extractCrowdin")
|
||||||
from("$buildDir/translations/")
|
from("$buildDir/translations/")
|
||||||
into("${projectDir}/src/")
|
into("${projectDir}/src/")
|
||||||
setFinalizedBy(setOf("removeIncompleteStrings"))
|
setFinalizedBy(setOf("removeIncompleteStrings"))
|
||||||
@ -86,7 +89,7 @@ class CrowdinDownloadPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks.register("crowdin") {
|
tasks.register("crowdin") {
|
||||||
setDependsOn(setOf("extractStrings"))
|
dependsOn("extractStrings")
|
||||||
if (!extension.skipCleanup) {
|
if (!extension.skipCleanup) {
|
||||||
doLast {
|
doLast {
|
||||||
File("$buildDir/translations").deleteRecursively()
|
File("$buildDir/translations").deleteRecursively()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user