Repository: beworker/autoplay Branch: master Commit: 30c2c8ee730a Files: 26 Total size: 62.0 KB Directory structure: gitextract_hxc8ykf7/ ├── .github/ │ └── stale.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── autoplay/ │ ├── build.gradle.kts │ └── src/ │ ├── main/ │ │ └── kotlin/ │ │ └── de/ │ │ └── halfbit/ │ │ └── tools/ │ │ └── autoplay/ │ │ ├── AutoplayPublisherExtension.kt │ │ ├── AutoplayPublisherPlugin.kt │ │ ├── PublishTask.kt │ │ └── publisher/ │ │ ├── GooglePlayPublisher.kt │ │ ├── common/ │ │ │ └── FileExt.kt │ │ └── v3/ │ │ └── V3GooglePlayPublisher.kt │ └── test/ │ ├── kotlin/ │ │ └── de/ │ │ └── halfbit/ │ │ └── tools/ │ │ └── autoplay/ │ │ ├── PlayPublisherPluginTest.kt │ │ └── publisher/ │ │ └── common/ │ │ └── FileExtTest.kt │ └── resources/ │ ├── LinesFileReader/ │ │ ├── release-notes-long.txt │ │ └── release-notes-short.txt │ └── sample-app/ │ └── app/ │ ├── build/ │ │ └── outputs/ │ │ ├── apk/ │ │ │ └── release/ │ │ │ └── sample-app-release-unsigned.apk │ │ └── bundle/ │ │ └── release/ │ │ └── sample-app.aab │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── autoplay/ │ └── release-notes/ │ └── internal/ │ └── en-US.txt ├── build.gradle.kts ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/stale.yml ================================================ # Number of days of inactivity before an issue becomes stale daysUntilStale: 30 # Number of days of inactivity before a stale issue is closed daysUntilClose: 7 # Issues with these labels will never be considered stale exemptLabels: - bug - enhancement - help wanted # Label to use when marking an issue as stale staleLabel: wontfix # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false ================================================ FILE: .gitignore ================================================ build/ !autoplay/src/test/resources/sample-app/app/build/ captures/ out/ userHome/ .idea/ .gradle/ .navigation/ *.iml .DS_Store local.properties ================================================ FILE: .travis.yml ================================================ language: android install: true jdk: - oraclejdk8 android: components: - tools - platform-tools - build-tools-27.0.3 - android-27 - extra-android-m2repository before_install: - yes | sdkmanager "platforms;android-27" before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ cache: directories: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ script: - ./gradlew clean build --stacktrace ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2018 Sergej Shafarenka, www.halfbit.de Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ [![Build Status](https://travis-ci.org/beworker/autoplay.svg?branch=master)](https://travis-ci.org/beworker/autoplay) [![Maven Central](http://img.shields.io/maven-central/v/de.halfbit/autoplay.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22de.halfbit%22%20a%3A%22autoplay%22) [![Gradle](https://img.shields.io/badge/gradle-5.0-blue.svg)](https://gradle.org/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) Archived in favor of https://github.com/Triple-T/gradle-play-publisher autoplay # Autoplay Gradle plugin for publishing Android artifacts to Google Play. # Features - Autoplay is optimized for CI/CD usage: - it does **not** trigger assembly task automatically - you can reuse build artifacts from previous build steps; - it accepts JSON key as **base64-encoded string** from external secure variables. - Autoplay is developer friendly: - it does **not** require storing any dummy keys in source control; - it has a single publish task for uploading artifacts (apk or app bundle) and release notes. - Autoplay is reliable and future-proof: - it has clean and concise implementation, which is easy to understand, extend and fix; - it's covered by unit tests; - it's built using latest tools and API's. # Usage In the main `build.gradle` ```gradle buildscript { repositories { google() mavenCentral() } dependencies { classpath "de.halfbit:autoplay:" } } ``` Latest published version can be found at [![Maven central](http://img.shields.io/maven-central/v/de.halfbit/autoplay.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22de.halfbit%22%20a%3A%22autoplay%22) ## Gradle compatibility Autoplay Version | Gradle Version | AGP Version -----------|-----------|--------------- | 1.3.x | 4.8.x | | | 2.3.x | 4.10.x | | | 3.0.x | 5.x, 6.x, 7.x | 3.x | | 4.0.x | 6.x | 4.0.x, 4.1.x | ## Publishing apk In the application module's `build.gradle` ```gradle apply plugin: 'com.android.application' apply plugin: 'android-autoplay' autoplay { track "internal" secretJsonBase64 project.hasProperty('SECRET_JSON') ? project.property('SECRET_JSON') : '' } ``` Execute `./gradlew tasks` and you will see a new publishing task `publishApk` in the list. Autoplay adds this task for each build variant of `release` type. For a project without custom build flavors the task is named `publishApkRelease`. ## Publishing app bundle In the application module's `build.gradle` ```gradle apply plugin: 'com.android.application' apply plugin: 'android-autoplay' autoplay { track "internal" artifactType "bundle" secretJsonBase64 project.hasProperty('SECRET_JSON') ? project.property('SECRET_JSON') : '' } ``` Execute `./gradlew tasks` and you will see a new publishing task `publishBundle` in the list. Autoplay adds this task for each build variant of `release` type. For a project without custom build flavors the task is named `publishBundleRelease`. ## Central build Now you can call this task from a central build script. Here is an example of how to use it with Gitlab CI. ```yml stages: - assemble - release assemble: stage: assemble only: - master script: - ./gradlew clean bundleRelease -PSTORE_PASS=${STORE_PASS} -PKEY_PASS=${KEY_PASS} artifacts: paths: - app/build/outputs/ release: stage: release dependencies: - assemble only: - master script: - ./gradlew publishBundleRelease -PSECRET_JSON=${SECRET_JSON} ``` You can encode JSON key file into base64 string using following shell command (linux, mac) ```shell base64 -i secret.json -o - ``` and provide the value to the build script using a [protected variable](https://docs.gitlab.com/ee/ci/variables/#variables). ## Publishing Release Notes Autoplay takes apk and obfuscation mapping files (or app bundle file, if `artifactType "bundle"` is set) for uploading from the default build output directories. Release notes are to be stored under `src/main/autoplay/release-notes` directory in accordance to the structure shown down below. ``` src +- main +- java +- autoplay +- release-notes +- e.g. internal +- .txt e.g. en-US.txt ``` ## Properties Autoplay supports following `gradle.properties` Name | Default | Description -----|---------|----- | `autoplay.connectTimeout` | 120000ms | Connection establishment timeout in milliseconds. | | `autoplay.readTimeout` | 120000ms | Connection reading timeout in milliseconds. | Happy continuous integration! # License ``` Copyright 2018-2021 Sergej Shafarenka, www.halfbit.de Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` ================================================ FILE: autoplay/build.gradle.kts ================================================ plugins { `kotlin-dsl` `maven-publish` id("org.gradle.signing") id("org.jetbrains.dokka") version "0.9.17" kotlin("jvm").version(embeddedKotlinVersion).apply(false) } dependencies { compileOnly("com.android.tools.build:gradle:4.1.3") { exclude(group = "org.jetbrains.kotlin") } implementation("com.google.apis:google-api-services-androidpublisher:v3-rev142-1.25.0") testImplementation("junit:junit:4.12") testImplementation("com.google.truth:truth:0.40") testImplementation("com.android.tools.build:gradle:4.1.3") { exclude(group = "org.jetbrains.kotlin") } } gradlePlugin { isAutomatedPublishing = false plugins { create("android-autoplay") { id = "android-autoplay" implementationClass = "de.halfbit.tools.autoplay.PlayPublisherPlugin" } } } group = "de.halfbit" version = "4.0.0" publishing { repositories { maven { name = "local" url = uri("$buildDir/repository") } maven { name = "central" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") credentials { username = project.getPropertyOrEmptyString("NEXUS_USERNAME") password = project.getPropertyOrEmptyString("NEXUS_PASSWORD") } } } val dokka by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class) { outputFormat = "javadoc" outputDirectory = "$buildDir/javadoc" } val sourcesJar by tasks.creating(Jar::class) { classifier = "sources" from(sourceSets["main"].allSource) } val javadocJar by tasks.creating(Jar::class) { classifier = "javadoc" from(dokka) } publications { create("Autoplay", MavenPublication::class) { from(components["java"]) artifact(sourcesJar) artifact(javadocJar) pom { name.set("Gradle plugin for publishing Android artifacts to Google Play.") description.set("Gradle plugin for publishing Android artifacts to Google Play.") url.set("http://www.halfbit.de") licenses { license { name.set("The Apache License, Version 2.0") url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") } } developers { developer { id.set("beworker") name.set("Sergej Shafarenka") email.set("info@halfbit.de") } } scm { connection.set("scm:git:git@github.com:beworker/autoplay.git") developerConnection.set("scm:git:ssh://github.com:beworker/autoplay.git") url.set("http://www.halfbit.de") } } } } } if (project.hasProperty("signing.keyId")) { signing { sign(publishing.publications["Autoplay"]) } } fun Project.getPropertyOrEmptyString(name: String): String = if (hasProperty(name)) property(name) as String? ?: "" else "" tasks.withType { addTestListener(object : TestListener { override fun beforeSuite(suite: TestDescriptor) {} override fun afterSuite(suite: TestDescriptor, result: TestResult) {} override fun beforeTest(testDescriptor: TestDescriptor) {} override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) { if (result.resultType == TestResult.ResultType.FAILURE) { result.exception?.printStackTrace() } } }) } ================================================ FILE: autoplay/src/main/kotlin/de/halfbit/tools/autoplay/AutoplayPublisherExtension.kt ================================================ /* * Copyright (C) 2018-2019 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay import de.halfbit.tools.autoplay.publisher.ArtifactType import de.halfbit.tools.autoplay.publisher.ReleaseStatus internal const val RELEASE_NOTES_PATH = "src/main/autoplay/release-notes" internal const val UNINITIALIZED = "" open class AutoplayPublisherExtension { var track: String = UNINITIALIZED var userFraction: Double = 1.0 var status: String = ReleaseStatus.Completed.name var secretJsonBase64: String? = null var secretJsonPath: String? = null var releaseNotesPath: String = RELEASE_NOTES_PATH var artifactType = ArtifactType.Apk.name } ================================================ FILE: autoplay/src/main/kotlin/de/halfbit/tools/autoplay/AutoplayPublisherPlugin.kt ================================================ /* * Copyright (C) 2018-2021 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay import com.android.Version import com.android.build.gradle.AppExtension import com.android.build.gradle.api.ApkVariantOutput import com.android.build.gradle.api.ApplicationVariant import de.halfbit.tools.autoplay.publisher.ArtifactType import de.halfbit.tools.autoplay.publisher.Credentials import de.halfbit.tools.autoplay.publisher.ReleaseNotes import de.halfbit.tools.autoplay.publisher.ReleaseStatus import de.halfbit.tools.autoplay.publisher.ReleaseTrack import de.halfbit.tools.autoplay.publisher.TRACK_ROLLOUT import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.invoke import org.gradle.kotlin.dsl.register import java.io.File import java.util.* internal const val TASK_GROUP = "Publishing" internal const val PLUGIN_ID = "android-autoplay" internal const val EXTENSION_NAME = "autoplay" internal class PlayPublisherPlugin : Plugin { override fun apply(project: Project) { val extension = project.extensions .create(EXTENSION_NAME, AutoplayPublisherExtension::class.java) val androidAppExtension = project.requireAndroidAppExtension() androidAppExtension.applicationVariants.whenObjectAdded { if (buildType.isDebuggable) return@whenObjectAdded val appVariant = this val variantName = appVariant.name.capitalize() when (extension.artifactType) { ArtifactType.Apk.name -> { project.tasks { register("publishApk$variantName") { description = "Publish $variantName apk, mapping and release-notes to Google Play." group = TASK_GROUP applicationId = appVariant.applicationId artifactType = ArtifactType.Apk artifacts = appVariant.collectArtifacts(ArtifactType.Apk, project) obfuscationMappingFile = appVariant.getObfuscationMappingFile() releaseTrack = extension.getReleaseTrack() releaseStatus = extension.getReleaseStatus() releaseNotes = extension.getReleaseNotes(project.projectDir) credentials = extension.getCredentials() } } } ArtifactType.Bundle.name -> { project.tasks { register("publishBundle$variantName") { description = "Publish $variantName bundle and release-notes to Google Play." group = TASK_GROUP applicationId = appVariant.applicationId artifactType = ArtifactType.Bundle artifacts = appVariant.collectArtifacts(ArtifactType.Bundle, project) releaseTrack = extension.getReleaseTrack() releaseStatus = extension.getReleaseStatus() releaseNotes = extension.getReleaseNotes(project.projectDir) credentials = extension.getCredentials() } } } } } } companion object { private const val MINIMAL_ANDROID_PLUGIN_VERSION = "3.0.1" private fun ApplicationVariant.collectArtifacts( artifactType: ArtifactType, project: Project ): List { return when (artifactType) { ArtifactType.Apk -> this.outputs .filterIsInstance() .map { it.outputFile } ArtifactType.Bundle -> { val archivesBaseName = project.properties["archivesBaseName"] as String listOf(File(project.buildDir, "outputs/bundle/$name/$archivesBaseName.aab")) } } } private fun ApplicationVariant.getObfuscationMappingFile(): File? { val mapping = mappingFile if (mapping == null || mapping.length() == 0L) { return null } return mapping } private fun AutoplayPublisherExtension.getReleaseTrack(): ReleaseTrack { return when (track) { UNINITIALIZED -> error("$EXTENSION_NAME { track } property is required.") ReleaseTrack.Internal.name -> ReleaseTrack.Internal ReleaseTrack.Alpha.name -> ReleaseTrack.Alpha ReleaseTrack.Beta.name -> ReleaseTrack.Beta TRACK_ROLLOUT -> ReleaseTrack.Rollout(userFraction) ReleaseTrack.Production.name -> ReleaseTrack.Production else -> error("Unsupported track: $track") } } private fun AutoplayPublisherExtension.getReleaseStatus(): ReleaseStatus { return when (status) { ReleaseStatus.Completed.name -> ReleaseStatus.Completed ReleaseStatus.Draft.name -> ReleaseStatus.Draft ReleaseStatus.Halted.name -> ReleaseStatus.Halted ReleaseStatus.InProgress.name -> ReleaseStatus.InProgress else -> error("Unsupported status: $status") } } private fun AutoplayPublisherExtension.getReleaseNotes(rootDir: File): List { val trackDirectory = File(rootDir, "$releaseNotesPath/$track") if (!trackDirectory.exists()) return emptyList() val directoryFiles = trackDirectory.listFiles() ?: return emptyList() return directoryFiles .filter { it.isFile } .mapNotNull { localizedFile -> if (localizedFile.exists()) localizedFile else null } .map { releaseNoteFile -> ReleaseNotes( releaseNoteFile.getLocale(), releaseNoteFile ) } } private fun AutoplayPublisherExtension.getCredentials(): Credentials { val secretJson = if (secretJsonBase64 != null) { Base64.getDecoder().decode(secretJsonBase64).toString(Charsets.UTF_8) } else { null } return Credentials(secretJson, secretJsonPath) } private fun Project.requireAndroidAppExtension(): AppExtension { val current = Version.ANDROID_GRADLE_PLUGIN_VERSION val expected = MINIMAL_ANDROID_PLUGIN_VERSION if (current < expected) { error( "Plugin '$PLUGIN_ID' requires 'com.android.application' plugin version $expected or higher," + " while yours is $current. Update android gradle plugin and try again." ) } return project.extensions.findByType(AppExtension::class.java) ?: error("Required 'com.android.application' plugin must be added prior '$PLUGIN_ID' plugin.") } private fun File.getLocale(): String { if (name.length < 5 || name.substring(2, 3) != "-") { error( "Release notes must be named using the following format:" + " -.txt, e.g. en-US.txt. Found name: $this" ) } return name.substring(0, 5) } } } ================================================ FILE: autoplay/src/main/kotlin/de/halfbit/tools/autoplay/PublishTask.kt ================================================ /* * Copyright (C) 2018-2021 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay import de.halfbit.tools.autoplay.publisher.ArtifactType import de.halfbit.tools.autoplay.publisher.Configuration import de.halfbit.tools.autoplay.publisher.Credentials import de.halfbit.tools.autoplay.publisher.ReleaseArtifact import de.halfbit.tools.autoplay.publisher.ReleaseData import de.halfbit.tools.autoplay.publisher.ReleaseNotes import de.halfbit.tools.autoplay.publisher.ReleaseStatus import de.halfbit.tools.autoplay.publisher.ReleaseTrack import de.halfbit.tools.autoplay.publisher.v3.V3GooglePlayPublisher import org.gradle.api.DefaultTask import org.gradle.api.Project import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.Optional import org.gradle.api.tasks.PathSensitive import org.gradle.api.tasks.PathSensitivity import org.gradle.api.tasks.TaskAction import org.gradle.work.InputChanges import java.io.File internal open class PublishTask : DefaultTask() { @get:Input lateinit var artifactType: ArtifactType @get:InputFiles @get:PathSensitive(PathSensitivity.ABSOLUTE) lateinit var artifacts: List @get:Optional @get:InputFile var obfuscationMappingFile: File? = null @get:Input lateinit var releaseNotes: List @get:Input lateinit var applicationId: String @get:Input lateinit var credentials: Credentials @get:Input lateinit var releaseTrack: ReleaseTrack @get:Input var releaseStatus: ReleaseStatus = ReleaseStatus.Completed @TaskAction @Suppress("UNUSED_PARAMETER", "unused") fun execute(inputChanges: InputChanges) { credentials.validate() val configuration = Configuration( readTimeout = project.getIntProperty("readTimeout", 120_000), connectTimeout = project.getIntProperty("connectTimeout", 120_000) ) V3GooglePlayPublisher .getGooglePlayPublisher(credentials, applicationId, configuration) .publish( ReleaseData( applicationId, artifacts.map { it.toReleaseArtifact(artifactType) }, obfuscationMappingFile, releaseNotes, releaseStatus, releaseTrack ) ) } } private fun Project.getIntProperty(propertyName: String, default: Int): Int = (project.properties["autoplay.$propertyName"] as? String)?.toInt() ?: default private fun File.toReleaseArtifact(artifactType: ArtifactType): ReleaseArtifact = when (artifactType) { ArtifactType.Apk -> ReleaseArtifact.Apk(this) ArtifactType.Bundle -> ReleaseArtifact.Bundle(this) } private fun Credentials.validate() { if (!secretJson.isNullOrEmpty() && !secretJsonPath.isNullOrEmpty()) { error( "Either $EXTENSION_NAME { secretJsonBase64 } or" + " $EXTENSION_NAME { secretJsonPath } must be specified, never both." ) } } ================================================ FILE: autoplay/src/main/kotlin/de/halfbit/tools/autoplay/publisher/GooglePlayPublisher.kt ================================================ /* * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay.publisher import java.io.File import java.io.Serializable internal const val TRACK_ROLLOUT = "rollout" internal interface GooglePlayPublisher { fun publish(data: ReleaseData) } internal class ReleaseData( val applicationId: String, val artifacts: List, val obfuscationMappingFile: File?, val releaseNotes: List, val releaseStatus: ReleaseStatus, val releaseTrack: ReleaseTrack ) internal class ReleaseNotes( val locale: String, val file: File ) : Serializable internal sealed class ReleaseTrack(val name: String) : Serializable { object Internal : ReleaseTrack("internal") object Alpha : ReleaseTrack("alpha") object Beta : ReleaseTrack("beta") class Rollout(val userFraction: Double) : ReleaseTrack(TRACK_ROLLOUT) object Production : ReleaseTrack("production") } internal sealed class ReleaseArtifact(val file: File) { class Apk(file: File) : ReleaseArtifact(file) class Bundle(file: File) : ReleaseArtifact(file) } internal sealed class ArtifactType(val name: String) : Serializable { object Apk : ArtifactType("apk") object Bundle : ArtifactType("bundle") } internal sealed class ReleaseStatus(val name: String) : Serializable { object Completed : ReleaseStatus("completed") object Draft : ReleaseStatus("draft") object Halted : ReleaseStatus("halted") object InProgress : ReleaseStatus("inProgress") } internal class Credentials( val secretJson: String?, val secretJsonPath: String? ) : Serializable internal class Configuration( val readTimeout: Int, val connectTimeout: Int ) ================================================ FILE: autoplay/src/main/kotlin/de/halfbit/tools/autoplay/publisher/common/FileExt.kt ================================================ /* * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay.publisher.common import java.io.File internal fun File.readTextLines(maxLength: Long): String { if (!exists()) error("File must exist: $this") if (length() == 0L) error("File must not be empty: $this") var complete = false val text = StringBuilder() forEachLine { line -> if (complete) return@forEachLine if (text.length + line.length < maxLength) { text.append(line.trim()).append("\n") } else { complete = true } } return text.toString() } ================================================ FILE: autoplay/src/main/kotlin/de/halfbit/tools/autoplay/publisher/v3/V3GooglePlayPublisher.kt ================================================ /* * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay.publisher.v3 import com.google.api.client.googleapis.auth.oauth2.GoogleCredential import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport import com.google.api.client.http.FileContent import com.google.api.client.json.jackson2.JacksonFactory import com.google.api.services.androidpublisher.AndroidPublisher import com.google.api.services.androidpublisher.AndroidPublisherScopes import com.google.api.services.androidpublisher.model.AppEdit import com.google.api.services.androidpublisher.model.LocalizedText import com.google.api.services.androidpublisher.model.Track import com.google.api.services.androidpublisher.model.TrackRelease import de.halfbit.tools.autoplay.EXTENSION_NAME import de.halfbit.tools.autoplay.publisher.* import de.halfbit.tools.autoplay.publisher.common.readTextLines import java.io.File internal const val MIME_TYPE_APK = "application/vnd.android.package-archive" internal const val MIME_TYPE_STREAM = "application/octet-stream" internal const val TYPE_PROGUARD = "proguard" internal class V3GooglePlayPublisher( private val androidPublisher: AndroidPublisher ) : GooglePlayPublisher { override fun publish(data: ReleaseData) { data.validate() val edits = androidPublisher.edits() val appEdit = edits.insert(data.applicationId, null).execute() val artifactVersionCodes = data.artifacts.map { val artifactVersionCode = when (it) { is ReleaseArtifact.Apk -> it.uploadApk(edits, data, appEdit) is ReleaseArtifact.Bundle -> it.uploadBundle(edits, data, appEdit) } artifactVersionCode.toLong() } edits.tracks() .update( data.applicationId, appEdit.id, data.releaseTrack.name, data.createTrackUpdate(artifactVersionCodes) ) .execute() edits.commit(data.applicationId, appEdit.id).execute() } companion object { private val jsonFactory = JacksonFactory.getDefaultInstance() private val httpTransport = GoogleNetHttpTransport.newTrustedTransport() private var publisher: GooglePlayPublisher? = null private fun createAndroidPublisher( secretJson: String, applicationName: String, configuration: Configuration ): AndroidPublisher { val credentials = GoogleCredential .fromStream(secretJson.byteInputStream(), httpTransport, jsonFactory) .createScoped(listOf(AndroidPublisherScopes.ANDROIDPUBLISHER)) return AndroidPublisher .Builder(httpTransport, jsonFactory) { httpRequest -> credentials.initialize( httpRequest.apply { readTimeout = configuration.readTimeout connectTimeout = configuration.connectTimeout } ) } .setApplicationName(applicationName) .build() } private fun ReleaseData.createTrackUpdate(apkVersionCodes: List): Track { return Track().apply { releases = listOf( TrackRelease().apply { versionCodes = apkVersionCodes status = releaseStatus.name if (releaseTrack is ReleaseTrack.Rollout) { userFraction = releaseTrack.userFraction } releaseNotes = this@createTrackUpdate.releaseNotes.map { releaseNotes -> LocalizedText().apply { language = releaseNotes.locale text = releaseNotes.file.readTextLines(maxLength = 500) } } } ) } } private fun ReleaseData.validate() { if (artifacts.isEmpty()) { error("No artifacts found for publishing.") } artifacts.forEach { if (!it.file.exists()) error("Artifact does not exist: ${it.file}") if (it.file.length() == 0L) error("Artifact must not be empty: ${it.file}") } } fun getGooglePlayPublisher( credentials: Credentials, applicationName: String, configuration: Configuration ): GooglePlayPublisher { var instance = publisher if (instance == null) { val androidPublisher = createAndroidPublisher( credentials.getSecretJson(), applicationName, configuration ) instance = V3GooglePlayPublisher(androidPublisher) publisher = instance } return instance } private fun Credentials.getSecretJson(): String { if (secretJson != null) { if (secretJson.isEmpty()) { error("$EXTENSION_NAME { secretJsonBase64 } must not be empty.") } return secretJson } if (secretJsonPath == null) { error("Either $EXTENSION_NAME { secretJsonBase64 } or $EXTENSION_NAME { secretJsonPath } must be specified.") } val file = File(secretJsonPath) if (!file.exists()) { error("SecretJson file cannot be found: $file") } if (file.length() == 0L) { error("SecretJson file must not be empty: $file") } return file.readText() } } } private fun ReleaseArtifact.Apk.uploadApk( edits: AndroidPublisher.Edits, data: ReleaseData, appEdit: AppEdit ): Int { val apkVersionCode = edits.apks() .upload( data.applicationId, appEdit.id, FileContent(MIME_TYPE_APK, file) ) .execute() .versionCode data.obfuscationMappingFile?.let { obfuscationMappingFile -> edits.deobfuscationfiles() .upload( data.applicationId, appEdit.id, apkVersionCode, TYPE_PROGUARD, FileContent(MIME_TYPE_STREAM, obfuscationMappingFile) ) .execute() } return apkVersionCode } private fun ReleaseArtifact.Bundle.uploadBundle( edits: AndroidPublisher.Edits, data: ReleaseData, appEdit: AppEdit ): Int { return edits.bundles() .upload( data.applicationId, appEdit.id, FileContent(MIME_TYPE_STREAM, file) ) .execute() .versionCode } ================================================ FILE: autoplay/src/test/kotlin/de/halfbit/tools/autoplay/PlayPublisherPluginTest.kt ================================================ /* * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay import com.google.common.truth.Truth.assertThat import de.halfbit.tools.autoplay.publisher.ReleaseStatus import de.halfbit.tools.autoplay.publisher.ReleaseTrack import org.gradle.api.GradleException import org.gradle.api.Project import org.gradle.kotlin.dsl.withGroovyBuilder import org.gradle.testfixtures.ProjectBuilder import org.hamcrest.core.IsEqual.equalTo import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage import org.junit.rules.ExpectedException import java.io.File private const val EXPECTED_EXTENSION_NAME = "autoplay" @Suppress("RemoveSingleExpressionStringTemplate") internal class PlayPublisherPluginTest { @Rule @JvmField var thrown: ExpectedException = ExpectedException.none() private lateinit var project: Project @Before fun before() { project = ProjectBuilder.builder() .withName("sample-app") .withProjectDir(File("src/test/resources/sample-app/app")) .build() project.pluginManager.apply("com.android.application") project.pluginManager.apply(PlayPublisherPlugin::class.java) } @Test fun `PlayPublisherPlugin, valid Apk configuration`() { project.withGroovyBuilder { "android" { "compileSdkVersion"(27) } "$EXPECTED_EXTENSION_NAME" { "track"("internal") "status"("inProgress") "userFraction"(0.5) "secretJsonBase64"("c2VjcmV0") } "evaluate"() } val tasks = project.getTasksByName("publishApkRelease", false) assertThat(tasks).hasSize(1) val task = tasks.first() assertThat(task).isNotNull() assertThat(task).isInstanceOf(PublishTask::class.java) val publishApkRelease = task as PublishTask assertThat(publishApkRelease.artifacts).hasSize(1) val artifact = publishApkRelease.artifacts.first() assertThat(artifact).isNotNull() assertThat(artifact.path).endsWith("sample-app-release-unsigned.apk") assertThat(File(artifact.path).exists()).isTrue() assertThat(publishApkRelease.releaseNotes).hasSize(1) val releaseNotes = publishApkRelease.releaseNotes.first() assertThat(releaseNotes).isNotNull() assertThat(releaseNotes.locale).isEqualTo("en-US") assertThat(releaseNotes.file.path).endsWith("release-notes/internal/en-US.txt") assertThat(publishApkRelease.credentials).isNotNull() assertThat(publishApkRelease.credentials.secretJson).isEqualTo("secret") assertThat(publishApkRelease.credentials.secretJsonPath).isNull() assertThat(publishApkRelease.obfuscationMappingFile).isNull() assertThat(publishApkRelease.applicationId).isEqualTo("de.halfbit.tools.autoplay.sample") assertThat(publishApkRelease.releaseTrack).isEqualTo(ReleaseTrack.Internal) assertThat(publishApkRelease.releaseStatus).isEqualTo(ReleaseStatus.InProgress) } @Test fun `PlayPublisherPlugin, valid Bundle configuration`() { project.withGroovyBuilder { "android" { "compileSdkVersion"(27) } "$EXPECTED_EXTENSION_NAME" { "track"("internal") "status"("inProgress") "userFraction"(0.5) "artifactType"("bundle") "secretJsonBase64"("c2VjcmV0") } "evaluate"() } val tasks = project.getTasksByName("publishBundleRelease", false) assertThat(tasks).hasSize(1) val task = tasks.first() assertThat(task).isNotNull() assertThat(task).isInstanceOf(PublishTask::class.java) val publishApkRelease = task as PublishTask assertThat(publishApkRelease.artifacts).hasSize(1) val artifact = publishApkRelease.artifacts.first() assertThat(artifact).isNotNull() assertThat(artifact.path).endsWith("sample-app.aab") assertThat(File(artifact.path).exists()).isTrue() assertThat(publishApkRelease.releaseNotes).hasSize(1) val releaseNotes = publishApkRelease.releaseNotes.first() assertThat(releaseNotes).isNotNull() assertThat(releaseNotes.locale).isEqualTo("en-US") assertThat(releaseNotes.file.path).endsWith("release-notes/internal/en-US.txt") assertThat(publishApkRelease.credentials).isNotNull() assertThat(publishApkRelease.credentials.secretJson).isEqualTo("secret") assertThat(publishApkRelease.credentials.secretJsonPath).isNull() assertThat(publishApkRelease.obfuscationMappingFile).isNull() assertThat(publishApkRelease.applicationId).isEqualTo("de.halfbit.tools.autoplay.sample") assertThat(publishApkRelease.releaseTrack).isEqualTo(ReleaseTrack.Internal) assertThat(publishApkRelease.releaseStatus).isEqualTo(ReleaseStatus.InProgress) } @Test fun `PublishApkTask, missing 'track'`() { thrown.expect(GradleException::class.java) thrown.expectCause(hasMessage(equalTo("$EXPECTED_EXTENSION_NAME { track } property is required."))) project.withGroovyBuilder { "android" { "compileSdkVersion"(27) } "autoplay" { } "evaluate"() } project.getTasksByName("publishApkRelease", false) } @Test fun `PublishBundleTask, missing 'track'`() { thrown.expect(GradleException::class.java) thrown.expectCause(hasMessage(equalTo("$EXPECTED_EXTENSION_NAME { track } property is required."))) project.withGroovyBuilder { "android" { "compileSdkVersion"(27) } "autoplay" { "artifactType"("bundle") } "evaluate"() } project.getTasksByName("publishBundleRelease", false) } } ================================================ FILE: autoplay/src/test/kotlin/de/halfbit/tools/autoplay/publisher/common/FileExtTest.kt ================================================ /* * Copyright (C) 2018 Sergej Shafarenka, www.halfbit.de * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.halfbit.tools.autoplay.publisher.common import com.google.common.truth.Truth.assertThat import org.junit.Test import java.io.File class FileExtTest { @Test fun testReadingShortFile() { val file = getResourceFile("release-notes-short.txt") val text = file.readTextLines(maxLength = 500) assertThat(text).startsWith("v 2.15.0") assertThat(text).hasLength(206) assertThat(text).endsWith("* New: feature three\n") } @Test fun testReadingLongFile() { val file = getResourceFile("release-notes-long.txt") val text = file.readTextLines(maxLength = 500) assertThat(text).startsWith("v 2.15.0") assertThat(text.length).isAtMost(500) assertThat(text).endsWith("v 2.7.0\n") } companion object { fun getResourceFile(name: String): File { val path = FileExtTest::class.java.getResource( File.separator + "LinesFileReader" + File.separator + name).file return File(path) } } } ================================================ FILE: autoplay/src/test/resources/LinesFileReader/release-notes-long.txt ================================================ v 2.15.0 * New: feature one * New: feature two * New: feature three v 2.13.0 * New: feature one * New: feature two * New: feature three v 2.12.0 * New: feature one * New: feature two * New: feature three v 2.11.0 * New: feature one * New: feature two * New: feature three v 2.10.0 * New: feature one * New: feature two * New: feature three v 2.9.0 * New: feature one * New: feature two * New: feature three v 2.8.0 * New: feature one * New: feature two * New: feature three v 2.7.0 * New: feature one * New: feature two * New: feature three v 2.6.0 * New: feature one * New: feature two * New: feature three v 2.5.0 * New: feature one * New: feature two * New: feature three ================================================ FILE: autoplay/src/test/resources/LinesFileReader/release-notes-short.txt ================================================ v 2.15.0 * New: feature one * New: feature two * New: feature three v 2.13.0 * New: feature one * New: feature two * New: feature three v 2.12.0 * New: feature one * New: feature two * New: feature three ================================================ FILE: autoplay/src/test/resources/sample-app/app/build/outputs/apk/release/sample-app-release-unsigned.apk ================================================ sample apk ================================================ FILE: autoplay/src/test/resources/sample-app/app/build/outputs/bundle/release/sample-app.aab ================================================ sample apk ================================================ FILE: autoplay/src/test/resources/sample-app/app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: autoplay/src/test/resources/sample-app/app/src/main/autoplay/release-notes/internal/en-US.txt ================================================ * New awesome feature added ================================================ FILE: build.gradle.kts ================================================ buildscript { repositories { google() mavenCentral() jcenter() } } tasks.withType().configureEach { distributionType = Wrapper.DistributionType.ALL } allprojects { repositories { google() jcenter() } configurations { all { resolutionStrategy { force("com.google.guava:guava:28.1-jre") } } } } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists ================================================ FILE: gradlew ================================================ #!/usr/bin/env sh ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn () { echo "$*" } die () { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } APP_ARGS=$(save "$@") # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi exec "$JAVACMD" "$@" ================================================ FILE: gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle.kts ================================================ include(":autoplay")