Dragapult is a Gradle plugin that simplifies managing and generating string resources for your multi-platform projects from a single source of truth.
Apply the Dragapult plugin to your project's /build.gradle
file:
plugins {
id "io.github.diareuse.dragapult" version "x.y.z" apply false
}
Apply the Dragapult plugin to your app project's /app/build.gradle
file:
plugins {
id "io.github.diareuse.dragapult" version "x.y.z"
}
Dragapult can fetch your localization files from both local and remote sources.
ℹ️ Local configurations are useful primarily in cases where the file is committed to this repository.
dragapult {
// For local files
local("local-file") {
file = project.file("input.json")
inputFileType = "json"
}
}
ℹ️ Remote configurations can be fetched in an optimized manner from a remote server. This allows easily integrating changes without changing the repository, though it might produce irreproducible builds. Use with caution.
dragapult {
// For remote files
remote("my-host-file") {
inputFileType = "json"
url "http://my.host/input.json"
headers {
header "X-Foo", "bar"
}
authorization {
bearer "i-am-token"
}
}
}
Dragapult creates a corresponding Gradle task for each configured source. The task name is generated based on the source name.
For example, for the local-file
source, you can run the following command to generate the resources:
# generateDragapult<Variant><Configuration Name><Strings>
# ex. for Variant=Debug, Configuration Name=local-file
./gradlew generateDragapultDebugLocalFileStrings
./dragapult -h
ℹ️ Consume resources already present in your project. Once consumed, edit the generated file and then use
generate
.
⚠️ Avoid editing generated files at all costs.
./dragapult consume -h
./dragapult consume\
-i/--input-directory res/values\
-o/--output-file translations.json\
-t/--input-type android\
-r/--output-type json
ℹ️ Generate produces predictable, up-to-spec files which can be readily compiled in your projects.
⚠️ Prefer not committing these files to source control.
./dragapult generate -h
./dragapult generate\
-i/--input-file translations.json\
-o/--output-directory res/values\
-t/--output-type android\
-s/--input-type json\
-b/--allow-blank-values
dependencies {
implementation "io.github.diareuse:dragapult-lib:x.y.z"
}