From b610e30065460d4427f714af13b5e9b06319a592 Mon Sep 17 00:00:00 2001 From: tobilarscheid Date: Fri, 4 May 2018 13:04:27 +0200 Subject: [PATCH] use jruby for android --- README.md | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 421aaa6..fac1506 100644 --- a/README.md +++ b/README.md @@ -174,14 +174,33 @@ Now, whenever you build your application, Xcode will automatically invoke Twine ### Android Studio/Gradle -Add the following task at the top level in app/build.gradle: +Add the following code at the top level in app/build.gradle: ``` -task generateLocalizations { - String script = 'if hash twine 2>/dev/null; then twine generate-localization-file twine.txt ./src/main/res/values/generated_strings.xml; fi' - exec { - executable "sh" - args '-c', script - } +buildscript { + repositories { jcenter() } + + dependencies { + /* check jruby-gradle.org for the latest release */ + classpath "com.github.jruby-gradle:jruby-gradle-plugin:1.5.0" + } +} + +apply plugin: 'com.github.jruby-gradle.base' + +dependencies { + jrubyExec 'rubygems:twine:1.0.3' +} + + +task generateLocalizations (type: JRubyExec) { + dependsOn jrubyPrepare + jrubyArgs '-S' + script "twine" + scriptArgs 'generate-localization-file', 'twine.txt', './src/main/res/values/generated_strings.xml' +} + +preBuild { + dependsOn generateLocalizations } ``` @@ -224,4 +243,4 @@ Many thanks to all of the contributors to the Twine project, including: [djangopo]: https://docs.djangoproject.com/en/dev/topics/i18n/translation/ [tizen]: https://developer.tizen.org/documentation/articles/localization [flash]: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/resources/IResourceManager.html#getString() -[printf]: https://en.wikipedia.org/wiki/Printf_format_string \ No newline at end of file +[printf]: https://en.wikipedia.org/wiki/Printf_format_string