├── test-consumer ├── settings.gradle.kts ├── .gitignore ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradle-example.properties ├── README.md ├── build.gradle.kts ├── gradlew.bat └── gradlew ├── localization-plugin ├── settings.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ └── main │ │ └── kotlin │ │ └── co │ │ └── thebeat │ │ └── localization │ │ ├── DownloadLocalizationsPlugin.kt │ │ ├── extensions │ │ └── TransifexLocalizationExtension.kt │ │ └── tasks │ │ └── DownloadLocalizationsTask.kt ├── build.gradle.kts ├── gradlew.bat └── gradlew ├── .github ├── ISSUE_TEMPLATE │ └── issue_template.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── gradle-wrapper-validation.yml │ └── ci.yml ├── ACKNOWLEDGEMENTS.md ├── .gitignore ├── CONTRIBUTING.md ├── README.md ├── CODE_OF_CONDUCT.md └── LICENSE /test-consumer/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | includeBuild("../localization-plugin") 2 | -------------------------------------------------------------------------------- /localization-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "localization-plugin" 2 | 3 | -------------------------------------------------------------------------------- /test-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | gradle.properties 2 | 3 | # Ignore files generated by testing the plugin 4 | src/main/res/* 5 | -------------------------------------------------------------------------------- /test-consumer/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beatlabs/gradle-localization-plugin/HEAD/test-consumer/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /localization-plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beatlabs/gradle-localization-plugin/HEAD/localization-plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /test-consumer/gradle-example.properties: -------------------------------------------------------------------------------- 1 | # Rename this file to "gradle.properties" and replace the values 2 | # below with your own Transifex configuration. 3 | transifexAPIToken=api-token 4 | transifexResourceSlug=resource-slug 5 | transifexProjectSlug=project-slug 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Generic Issue 3 | about: Suggest an idea for this project or submit a bug 4 | 5 | --- 6 | 7 | * **I'm submitting a ...** 8 | - [ ] bug report 9 | - [ ] feature request 10 | 11 | Description 12 | --- 13 | -------------------------------------------------------------------------------- /test-consumer/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /localization-plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | | Related Links | 2 | | :--- | 3 | | [Helpful Link](https://google.com) | 4 | 5 | # Description 6 | _Provide an overview of the changes to be found in this PR_ 7 | 8 | ## Checklist 9 | _e.g. tests pass_ 10 | - [ ] Item #1 11 | - [x] Item #2 12 | -------------------------------------------------------------------------------- /ACKNOWLEDGEMENTS.md: -------------------------------------------------------------------------------- 1 | # Acknowledgments 2 | 3 | The plugin makes primarily use of the following OSS projects: 4 | 5 | - [Kotlin](https://github.com/JetBrains/kotlin) 6 | - [Gradle plugin publish](https://plugins.gradle.org/plugin/com.gradle.plugin-publish) 7 | - [JUnit](https://junit.org/junit5/) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | out/ 4 | 5 | # Ignore Gradle GUI config 6 | gradle-app.setting 7 | 8 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 9 | !gradle-wrapper.jar 10 | 11 | local.properties 12 | 13 | .idea/ 14 | *.iml 15 | 16 | *.DS_Store 17 | 18 | # Ignore Gradle build output directory 19 | build 20 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: 3 | push: 4 | branches: [ master, develop ] 5 | pull_request: 6 | branches: [ master, develop ] 7 | 8 | jobs: 9 | validation: 10 | name: "Validation" 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: gradle/wrapper-validation-action@v1 15 | -------------------------------------------------------------------------------- /test-consumer/README.md: -------------------------------------------------------------------------------- 1 | # Consumer project 2 | 3 | This gradle project has the purpose of performing 4 | manual tests while developing the localization plugin. 5 | 6 | It's a composite build that includes **localization-plugin** in 7 | its _settings.gradle.kts_ file. 8 | 9 | To run it put your api settings as instructed in `gradle-example.properties` file, 10 | and at the command line execute: 11 | ``` 12 | $> cd 13 | $> ./gradlew fetchLocalization 14 | 15 | ``` -------------------------------------------------------------------------------- /test-consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("co.thebeat.localization") version "0.4.1" 3 | } 4 | 5 | val transifexAPIToken: String? by project 6 | val transifexResourceSlug: String? by project 7 | val transifexProjectSlug: String? by project 8 | 9 | configure { 10 | apiToken.set(transifexAPIToken ?: "") 11 | resourceSlug.set(transifexResourceSlug ?: "") 12 | projectSlug.set(transifexProjectSlug ?: "") 13 | localesMap.set( 14 | mapOf( 15 | "main/res/localization_en" to "en", 16 | "main/res/localization_gr" to "el_GR" 17 | ) 18 | ) 19 | srcDir.set("$projectDir/src") 20 | } 21 | -------------------------------------------------------------------------------- /localization-plugin/src/main/kotlin/co/thebeat/localization/DownloadLocalizationsPlugin.kt: -------------------------------------------------------------------------------- 1 | package co.thebeat.localization 2 | 3 | import co.thebeat.localization.extensions.TransifexLocalizationExtension 4 | import co.thebeat.localization.tasks.DownloadLocalizationsTask 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | import org.gradle.kotlin.dsl.create 8 | 9 | /** 10 | * Created by Chris Margonis on 17/07/2018. 11 | */ 12 | open class DownloadLocalizationsPlugin : Plugin { 13 | 14 | override fun apply(project: Project) { 15 | val transifexExt = project 16 | .extensions 17 | .create(TransifexLocalizationExtension.NAME) 18 | project.tasks.register(DownloadLocalizationsTask.NAME, DownloadLocalizationsTask::class.java, transifexExt) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: "Continuous Integration" 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - uses: actions/checkout@v2 10 | - name: Set up JDK 1.8 11 | uses: actions/setup-java@v1 12 | with: 13 | java-version: 1.8 14 | - name: Grant execute permission for plugin gradlew 15 | run: chmod +x ./localization-plugin/gradlew 16 | - name: Grant execute permission for consumer gradlew 17 | run: chmod +x ./test-consumer/gradlew 18 | - name: Build Localization Plugin 19 | run: ./localization-plugin/gradlew build jar -b ./localization-plugin/build.gradle.kts 20 | - name: Build Consumer 21 | run: ./test-consumer/gradlew build -b ./test-consumer/build.gradle.kts 22 | - name: Upload artifacts 23 | uses: actions/upload-artifact@v1 24 | with: 25 | name: Localization Plugin Jar Artifacts 26 | path: ./localization-plugin/build/libs/ 27 | -------------------------------------------------------------------------------- /localization-plugin/src/main/kotlin/co/thebeat/localization/extensions/TransifexLocalizationExtension.kt: -------------------------------------------------------------------------------- 1 | package co.thebeat.localization.extensions 2 | 3 | import org.gradle.api.model.ObjectFactory 4 | import org.gradle.api.provider.MapProperty 5 | import org.gradle.api.provider.Property 6 | import org.gradle.api.tasks.Input 7 | import org.gradle.api.tasks.Internal 8 | 9 | @Suppress("UnstableApiUsage") 10 | open class TransifexLocalizationExtension @JvmOverloads constructor( 11 | // Needed for Gradle 12 | @get:Internal 13 | internal val name: String = "default", 14 | objects: ObjectFactory 15 | ) { 16 | 17 | companion object { 18 | const val NAME = "transifexLocalization" 19 | } 20 | 21 | @get:Input 22 | val apiToken: Property = objects.property(String::class.java) 23 | 24 | @get:Input 25 | val resourceSlug: Property = objects.property(String::class.java) 26 | 27 | @get:Input 28 | val localesMap: MapProperty = objects.mapProperty(String::class.java, String::class.java) 29 | 30 | @get:Input 31 | val srcDir: Property = objects.property(String::class.java) 32 | 33 | @get:Input 34 | val projectSlug: Property = objects.property(String::class.java) 35 | } 36 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to Contribute 2 | 3 | 1. **Contributor**: A person that wishes to contribute to the project should open an issue regarding 4 | the proposed contribution. Using the specified template a proper description should outline the objective. 5 | Example contributions could be: bug fixing, new feature, documentation corrections/additions etc. 6 | 2. **Curators and Others**: Engage in the discussion about the proposed change. 7 | 3. **Curators**: After the discussion mentioned above, it will be determined if the proposed change 8 | should proceed or not (adding appropriate labels if necessary). 9 | 4. **Contributor**: 10 | - assigns the issue to themselves 11 | - creates a fork 12 | - git clone the fork on their machine 13 | - opens a PR. use WIP label to mark unfinished work 14 | - after development has finished remove the _WIP_ label and add _READY FOR REVIEW_ 15 | 5. **Curators**: The curators will conduct a code review 16 | 6. **Curators**: After at least 2 curators have approved the PR, it will be merged to master 17 | 7. **Curators**: A release will follow after that at some point 18 | 19 | PR's should have the following requirements: 20 | 21 | - Tests (where applicable) 22 | - Formatting using the official [Kotlin style guide](https://kotlinlang.org/docs/reference/coding-conventions.html) 23 | -------------------------------------------------------------------------------- /localization-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | val kotlinVersion: String by extra { "1.3.61" } 2 | val junitVersion: String by extra { "5.5.1" } 3 | 4 | plugins { 5 | `kotlin-dsl` 6 | id("com.gradle.plugin-publish") version "0.11.0" 7 | kotlin("jvm") version "1.3.61" 8 | } 9 | 10 | repositories { 11 | google() 12 | mavenCentral() 13 | jcenter() 14 | } 15 | 16 | group = "co.thebeat.localization" 17 | version = "0.4.1" 18 | 19 | dependencies { 20 | implementation(gradleApi()) 21 | implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") 22 | 23 | testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion") 24 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion") 25 | } 26 | 27 | gradlePlugin { 28 | plugins { 29 | create("downloadLocalizationsPlugin") { 30 | id = "co.thebeat.localization" 31 | displayName = "Download localization files plugin" 32 | description = "Interact with localization providers (such as Transifex) and automate downloading " + 33 | "localized files (such as string.xml for android applications)." 34 | implementationClass = "co.thebeat.localization.DownloadLocalizationsPlugin" 35 | } 36 | } 37 | } 38 | 39 | pluginBundle { 40 | website = "https://github.com/beatlabs/gradle-localization-plugin" 41 | vcsUrl = "https://github.com/beatlabs/gradle-localization-plugin" 42 | tags = listOf("localization", "transifex", "android") 43 | } 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## gradle-localization-plugin 2 | ![Continuous Integration](https://github.com/beatlabs/gradle-localization-plugin/workflows/Continuous%20Integration/badge.svg?branch=develop) 3 | 4 | Gradle plugin for automation regarding string downloading in Android apps. 5 | The plugin in its current state has been integrated with Transifex and uses [Transifex API v2](https://docs.transifex.com/api/introduction). 6 | 7 | ## Instructions 8 | 9 | ### Apply the plugin 10 | 11 | Using [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block) 12 | ``` 13 | plugins { 14 | id "co.thebeat.localization" version "" 15 | } 16 | 17 | ``` 18 | 19 | Using [legacy plugin application](https://docs.gradle.org/current/userguide/plugins.html#sec:old_plugin_application) 20 | ``` 21 | buildscript { 22 | repositories { 23 | maven { 24 | url "https://plugins.gradle.org/m2/" 25 | } 26 | } 27 | dependencies { 28 | classpath "gradle.plugin.co.thebeat.localization:localization-plugin:" 29 | } 30 | } 31 | 32 | apply plugin: "co.thebeat.localization" 33 | ``` 34 | 35 | ### Configuring the plugin 36 | 37 | Add this configuration in your `app` `build.gradle` file (does not need to be inside another closure) 38 | 39 | **groovy**: 40 | 41 | ```groovy 42 | transifexLocalization { 43 | apiToken = 'your-api-key' 44 | resourceSlug = 'your-resource-path-here' 45 | projectSlug = 'your-project-name-here' 46 | localesMap = [:] 47 | // example localization matchings 48 | localesMap['main/res/values'] = 'en' 49 | localesMap['greece/res/values'] = 'el_GR' 50 | localesMap['colombia/res/values'] = 'es_CO' 51 | localesMap['chile/res/values'] = 'es_CL' 52 | srcDir = "${projectDir}/src" 53 | } 54 | ``` 55 | 56 | **gradle kotlin dsl**: 57 | 58 | ```kotlin 59 | configure { 60 | apiToken = "your-api-key" 61 | resourceSlug = "your-resource-path-here" 62 | projectSlug = "your-project-name-here" 63 | localesMap = HashMap().apply { 64 | // example localization matchings 65 | this["main/res/values"] = "en" 66 | this["greece/res/values"] = "el_GR" 67 | this["colombia/res/values"] = "es_CO" 68 | this["chile/res/values"] = "es_CL" 69 | } 70 | srcDir = "${projectDir}/src" 71 | } 72 | ``` 73 | - Execute `./gradlew fetchLocalization` 74 | 75 | ## Contributing 76 | 77 | Please consult the [Contribution guidelines](CONTRIBUTING.md). 78 | -------------------------------------------------------------------------------- /test-consumer/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Our Pledge 2 | --- 3 | 4 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 5 | 6 | Our Standards 7 | --- 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | - Using welcoming and inclusive language 12 | - Being respectful of differing viewpoints and experiences 13 | - Gracefully accepting constructive criticism 14 | - Focusing on what is best for the community 15 | - Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | - The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | - Trolling, insulting/derogatory comments, and personal or political attacks 21 | - Public or private harassment 22 | - Publishing others’ private information, such as a physical or electronic address, without explicit permission 23 | - Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | Our Responsibilities 26 | --- 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and 28 | are expected to take appropriate and fair corrective action in response to any instances of 29 | unacceptable behavior. 30 | 31 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, 32 | code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, 33 | or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, 34 | threatening, offensive, or harmful. 35 | 36 | Scope 37 | --- 38 | This Code of Conduct applies within all project spaces, and it also applies when an individual is 39 | representing the project or its community in public spaces. Examples of representing a project or 40 | community include using an official project e-mail address, posting via an official social media account, 41 | or acting as an appointed representative at an online or offline event. Representation of a project 42 | may be further defined and clarified by project maintainers. 43 | 44 | Enforcement 45 | --- 46 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting 47 | the project team at chris.margonis@gmail.com. All complaints will be reviewed and investigated and 48 | will result in a response that is deemed necessary and appropriate to the circumstances. 49 | The project team is obligated to maintain confidentiality with regard to the reporter of an incident. 50 | Further details of specific enforcement policies may be posted separately. 51 | 52 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project’s leadership. 53 | 54 | Attribution 55 | --- 56 | This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available 57 | at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 58 | 59 | For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq -------------------------------------------------------------------------------- /localization-plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /localization-plugin/src/main/kotlin/co/thebeat/localization/tasks/DownloadLocalizationsTask.kt: -------------------------------------------------------------------------------- 1 | package co.thebeat.localization.tasks 2 | 3 | import co.thebeat.localization.extensions.TransifexLocalizationExtension 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.GradleException 6 | import org.gradle.api.logging.Logger 7 | import org.gradle.api.logging.Logging 8 | import org.gradle.api.provider.MapProperty 9 | import org.gradle.api.provider.Property 10 | import org.gradle.api.tasks.TaskAction 11 | import org.gradle.kotlin.dsl.support.serviceOf 12 | import org.gradle.workers.WorkAction 13 | import org.gradle.workers.WorkParameters 14 | import org.gradle.workers.WorkerExecutor 15 | import java.io.File 16 | import java.util.concurrent.TimeUnit 17 | import javax.inject.Inject 18 | 19 | @Suppress("UnstableApiUsage") 20 | internal abstract class DownloadLocalizationsTask @Inject constructor( 21 | private val extension: TransifexLocalizationExtension 22 | ) : DefaultTask() { 23 | 24 | companion object { 25 | const val NAME = "fetchLocalization" 26 | } 27 | 28 | @TaskAction 29 | fun downloadLocalizations() { 30 | require(!extension.apiToken.get().isBlank()) { 31 | """ 32 | An Auth token needs to be configured in order to use this plugin. 33 | ``` 34 | transifexLocalization { 35 | authToken = "my-auth-token" 36 | } 37 | ``` 38 | """.trimIndent() 39 | } 40 | 41 | project.serviceOf() 42 | .noIsolation() 43 | .submit(DownloadTranslationsWorkAction::class.java) { 44 | apiToken.set(extension.apiToken.get()) 45 | parentFolder.set(extension.srcDir.get()) 46 | projectSlug.set(extension.projectSlug.get()) 47 | resourceSlug.set(extension.resourceSlug.get()) 48 | localeMap.set(extension.localesMap.get()) 49 | } 50 | } 51 | 52 | @Suppress("UnstableApiUsage") 53 | interface DownloadTranslationWorkParameters : WorkParameters { 54 | val apiToken: Property 55 | val parentFolder: Property 56 | val projectSlug: Property 57 | val resourceSlug: Property 58 | val localeMap: MapProperty 59 | } 60 | 61 | @Suppress("UnstableApiUsage") 62 | abstract class DownloadTranslationsWorkAction : WorkAction { 63 | 64 | private val logger: Logger = Logging.getLogger( 65 | "TheBEAT:GradleLocalizationPlugin:${DownloadLocalizationsTask::class.java.simpleName}" 66 | ) 67 | 68 | override fun execute() { 69 | val apiToken = "api:${parameters.apiToken.get()}" 70 | val localesMap = parameters.localeMap.get() 71 | val filesMap = mutableMapOf() 72 | 73 | localesMap.forEach { (folder, locale) -> 74 | logger.debug("Will download pair of: $folder - $locale") 75 | 76 | val localeRequestUrl = buildTranslationRequestUrl(currentLocale = locale) 77 | 78 | logger.debug("Built request url: $localeRequestUrl") 79 | 80 | val process = ProcessBuilder( 81 | "curl", 82 | "-L", 83 | "--user", 84 | apiToken, 85 | "-X", 86 | "GET", 87 | localeRequestUrl 88 | ).start() 89 | 90 | logger.debug("Process has started") 91 | 92 | process.inputStream.reader(Charsets.UTF_8).use { 93 | val text = it.readText().trim() 94 | // We need to use the 4-space indentation because the file is usually changed by humans 95 | // That makes the git diff inspection easier 96 | val content = text.replace( 97 | """\n(\s+)(()|)""".toRegex(), 98 | "\n \$2" 99 | ) 100 | filesMap[folder] = content 101 | } 102 | process.waitFor(10L, TimeUnit.SECONDS) 103 | } 104 | 105 | if (filesMap.size == localesMap.size) { 106 | localesMap.forEach { (folder, _) -> 107 | val stringsFile = File("${parameters.parentFolder.get()}/$folder/strings.xml") 108 | stringsFile.writeText(filesMap[folder].toString()) 109 | } 110 | 111 | logger.debug("All translations downloaded") 112 | } else { 113 | throw GradleException("Error downloading strings.xml") 114 | } 115 | } 116 | 117 | private fun buildTranslationRequestUrl(currentLocale: String): String = "https://www.transifex.com/api/2/" + 118 | "project/" + 119 | "${parameters.projectSlug.get()}/" + 120 | "resource/" + 121 | "${parameters.resourceSlug.get()}/" + 122 | "translation/" + 123 | "$currentLocale?mode=default&file=xml" 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /test-consumer/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /localization-plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------