├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── android-checklist ├── build.gradle ├── detekt.yml ├── functional-test.gradle ├── integration-test.gradle ├── publishing.gradle ├── src │ ├── main │ │ └── kotlin │ │ │ └── com │ │ │ └── commencis │ │ │ └── checklist │ │ │ ├── ChecklistBasePlugin.kt │ │ │ ├── ChecklistPlugin.kt │ │ │ ├── ChecklistPluginExtension.kt │ │ │ ├── extensions │ │ │ └── PluginAwareExtensions.kt │ │ │ ├── task │ │ │ ├── ChecklistTask.kt │ │ │ ├── ChecklistTaskDependencyProvider.kt │ │ │ ├── ChecklistTaskDependencyProviderImpl.kt │ │ │ ├── ChecklistTaskResult.kt │ │ │ ├── apk │ │ │ │ └── APK2Task.kt │ │ │ ├── build │ │ │ │ ├── B10Task.kt │ │ │ │ ├── B1Task.kt │ │ │ │ ├── B4Task.kt │ │ │ │ ├── B5Task.kt │ │ │ │ ├── B6Task.kt │ │ │ │ ├── B7Task.kt │ │ │ │ ├── B8Task.kt │ │ │ │ └── B9Task.kt │ │ │ ├── constants │ │ │ │ ├── ChecklistTaskContainer.kt │ │ │ │ ├── ChecklistTaskStatus.kt │ │ │ │ ├── ChecklistTaskType.kt │ │ │ │ ├── InstallLocationValue.kt │ │ │ │ └── OutputSize.kt │ │ │ ├── distribution │ │ │ │ └── DIST2Task.kt │ │ │ ├── general │ │ │ │ ├── GEN1Task.kt │ │ │ │ ├── GEN2Task.kt │ │ │ │ ├── GEN3Task.kt │ │ │ │ ├── GEN4Task.kt │ │ │ │ └── GEN5Task.kt │ │ │ ├── manifest │ │ │ │ ├── MAN1Task.kt │ │ │ │ ├── MAN2Task.kt │ │ │ │ ├── MAN3Task.kt │ │ │ │ ├── MAN5Task.kt │ │ │ │ └── MAN6Task.kt │ │ │ ├── permissions │ │ │ │ ├── PERM2Task.kt │ │ │ │ └── PERM3Task.kt │ │ │ ├── proguard │ │ │ │ ├── PRG1Task.kt │ │ │ │ ├── PRG3Task.kt │ │ │ │ └── PRG6Task.kt │ │ │ ├── report │ │ │ │ ├── ChecklistFinalTask.kt │ │ │ │ ├── ChecklistReportGenerator.kt │ │ │ │ ├── container │ │ │ │ │ ├── ChecklistReportContainer.kt │ │ │ │ │ └── ChecklistReportContainerImpl.kt │ │ │ │ ├── strategy │ │ │ │ │ ├── ChecklistHTMLReportStrategy.kt │ │ │ │ │ ├── ChecklistReportStrategy.kt │ │ │ │ │ └── ChecklistXMLReportStrategy.kt │ │ │ │ └── writer │ │ │ │ │ ├── ChecklistHtmlWriter.kt │ │ │ │ │ ├── ChecklistReportWriter.kt │ │ │ │ │ └── ChecklistXmlWriter.kt │ │ │ └── signing │ │ │ │ ├── SIGN1Task.kt │ │ │ │ ├── SIGN3Task.kt │ │ │ │ └── SIGN4Task.kt │ │ │ └── util │ │ │ ├── ChecklistData.kt │ │ │ ├── command │ │ │ ├── AaptHelper.kt │ │ │ ├── ApkAnalyzerHelper.kt │ │ │ ├── CommandExecutor.kt │ │ │ ├── GitHelper.kt │ │ │ └── GradleHelper.kt │ │ │ ├── file │ │ │ ├── ChecklistFileHelper.kt │ │ │ ├── XmlParser.kt │ │ │ └── XmlParserImpl.kt │ │ │ ├── plugin │ │ │ └── android │ │ │ │ ├── AndroidBuildType.kt │ │ │ │ ├── AndroidPluginHelperImpl.kt │ │ │ │ ├── AndroidPluginOwner.kt │ │ │ │ ├── BuildTypeProviderImpl.kt │ │ │ │ ├── IAndroidPluginHelper.kt │ │ │ │ └── IBuildTypeProvider.kt │ │ │ └── project │ │ │ ├── ProjectInfo.kt │ │ │ ├── ProjectUtil.kt │ │ │ ├── resolver │ │ │ ├── IProjectResolverProvider.kt │ │ │ ├── ProjectResolver.kt │ │ │ └── ProjectResolverProviderImpl.kt │ │ │ └── type │ │ │ ├── IProjectTypeProvider.kt │ │ │ ├── ProjectType.kt │ │ │ └── ProjectTypeProviderImpl.kt │ └── test │ │ └── kotlin │ │ └── com │ │ └── commencis │ │ ├── checklist │ │ └── ChecklistBasePluginTest.kt │ │ └── testUtils │ │ └── ActionUtil.kt └── testing.gradle ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ 2 | out/ 3 | 4 | # Crashlytics plugin (for Android Studio and IntelliJ) 5 | com_crashlytics_export_strings.xml 6 | crashlytics.properties 7 | crashlytics-build.properties 8 | fabric.properties 9 | 10 | # Editor-based Rest Client 11 | **/.idea 12 | *.iml 13 | local.properties 14 | 15 | ### Java template 16 | # Compiled class file 17 | *.class 18 | 19 | # Log file 20 | *.log 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | #Build file 26 | **/build/ 27 | !android-checklist/src/main/kotlin/com/commencis/checklist/task/build/ 28 | **/.gradle -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Fork, then clone the repo: 4 | ```shell script 5 | git clone //TODO 6 | ``` 7 | 8 | Make sure the project is working 9 | ```shell script 10 | ./gradlew clean build test check 11 | ``` 12 | 13 | Make your changes and be sure that everything works fine. 14 | ```shell script 15 | ./gradlew clean build test check 16 | ``` 17 | 18 | Push to your fork and submit a pull request. 19 | 20 | ### How to test your changes 21 | First way to test the changes you made is writing unit, functional and/or integration tests. We encourage you to write 22 | tests for the code you wrote. To run the tests on the project run: 23 | ```shell script 24 | ./gradlew test 25 | ``` 26 | For manual testing you can use any android project and add the plugin to your project as described on the [README.md](README.md). 27 | After adding the plugin to your project you need to point its location to your local directory. To do this add: 28 | ```groovy 29 | includeBuild('path/to/Android-Checklist-Plugin/checklist'){ 30 | dependencySubstitution { 31 | substitute module('com.commencis.checklist:checklist') with project(':') 32 | } 33 | } 34 | ``` 35 | to your settings.gradle file. After that you can make your changes and run the checklist task on your android project. 36 | 37 | ### Adding a new task 38 | If you want to add a new task, there are some steps that need to be done: 39 | 1) Create your task class inside the related subpackage of `com.commencis.checklist.task` 40 | 2) Extend `ChecklistTask` class 41 | 3) Make your class open so that gradle can create that task 42 | 4) Override `taskCode`, `taskDescription` and `taskAction` fields of the `ChecklistTask` 43 | 5) Optionally override `taskType` if your task should not work on both application and library projects 44 | 6) Add your task's name to the `ChecklistData` class 45 | 7) Add your task with its name to `ChecklistTaskContainer` class 46 | 8) Make sure that [your changes work](#How to test your changes) as expected and didn't affect the existing functionality -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Checklist Gradle Plugin 2 | 3 | ## What is Checklist Plugin? 4 | Checklist Plugin is a Gradle plugin for Android projects to verify output(apk, aar, etc.) before release. 5 | It checks several items that are common for most android projects and generates an HTML report with the 6 | results of these tasks. 7 | 8 | ## Features 9 | Checklist Plugin currently has the following tasks: 10 | 11 | | Task | Description | 12 | | --- | --- | 13 | | checklistAPK2| verifies apk size 14 | | checklistB1| checks whether res configs include only the necessary resources 15 | | checklistB4| checks whether appId starts with some given convention 16 | | checklistB5| checks whether minSDK <= some given version number(defaults to 16) 17 | | checklistB6| checks whether targetSDK >= some given version number(defaults to 29) 18 | | checklistB7| checks whether compileSDK >= some given version number(defaults to 29) 19 | | checklistB8| checks whether the dependencies have specific version numbers instead of -SNAPSHOT and + 20 | | checklistB9| checks whether apk/aar is debuggable 21 | | checklistB10| checks whether Google play services api is included as separate dependencies 22 | | checklistDIST2| verifies aar size 23 | | checklistGEN1| checks whether git branch name has the given prefix 24 | | checklistGEN2| reminds to make sure that basic functionality of the app is fully working 25 | | checklistGEN3| reminds to make sure that the app doesn't crash and works as expected 26 | | checklistGEN4| verifies permissions, locales and densities 27 | | checklistGEN5| checks that unit tests ran and did not fail 28 | | checklistMAN1| shows current version code to check whether it is incremented 29 | | checklistMAN2| shows version name to check if it is updated 30 | | checklistMAN3| checks if the version name follows ... convention 31 | | checklistMAN5| verifies installLocation attribute on manifest 32 | | checklistMAN6| checks if the version name follows .. convention 33 | | checklistPERM2| shows permissions to check that if an unnecessary permission is used 34 | | checklistPERM3| checks whether android:required set false in the manifest. 35 | | checklistPRG1| checks whether apk contains any logging classes 36 | | checklistPRG3| checks whether proguard files are set through proguardFiles property 37 | | checklistPRG6| checks whether minifyEnabled and shrinkResources are set true 38 | | checklistSIGN1| checks whether keystore file is in project folder 39 | | checklistSIGN3| checks whether the apk contains release keystore 40 | | checklistSIGN4| checks whether storePassword, keyAlias, keyPassword are set in the build.gradle file 41 | | checklist| Main task that generates HTML report 42 | 43 | In addition to the predefined tasks, one can add custom tasks to the list. Refer to [Adding Custom Task](#Adding Custom Task) 44 | 45 | ## Setup 46 | 1. Add `classpath 'com.commencis.checklist:checklist:$checklistVersion'` to your project level `build.gradle` file. 47 | 2. Add `apply plugin: 'com.commencis.checklist.plugin'` to your module level `build.gradle` file. 48 | 3. If you have product flavors, you need to set the flavor you want to run checklist inside the checklist extension block. 49 | ````groovy 50 | checklist{ 51 | flavorName = "myFlavor" 52 | } 53 | ```` 54 | - Don't forget to consider dimensions as well. For example, if you have 55 | ```groovy 56 | flavorDimensions "dim1", "dim2" 57 | productFlavors { 58 | flavor1 { 59 | dimension "dim1" 60 | } 61 | flavor2{ 62 | dimension "dim2" 63 | } 64 | } 65 | ``` 66 | on your build.gradle file, then you need to set `flavorName` parameter as 67 | ````groovy 68 | checklist{ 69 | flavorName = "flavor1Flavor2" 70 | } 71 | ```` 72 | 73 | ## Basic Usage 74 | To use Checklist Plugin you can simply run 75 | ```shell script 76 | ./gradlew checklist 77 | ``` 78 | It will automatically generate an HTML report to `/build/checklist/report.html` file. 79 | 80 | ## Customization 81 | ### Adding Custom Task 82 | To add a custom task for your project, you should: 83 | 1. Create a task of type `com.commencis.checklist.task.ChecklistTask` 84 | 2. Override `taskCode`, `taskDescription`, `taskType`(optionally) and `taskAction` 85 | 3. Don't forget to return `com.commencis.checklist.task.ChecklistTaskResult` instance at the end of `taskAction` 86 | 87 | ##### Example 88 | 89 | ```groovy 90 | task example(type: ChecklistTask){ 91 | taskCode = "Example" 92 | taskDescription = "Description" 93 | 94 | taskAction { 95 | println("Some action!") 96 | new ChecklistTaskResult(taskCode, ChecklistTaskStatus.SUCCESS, taskDescription) 97 | } 98 | } 99 | ``` 100 | 101 | ### Configuration 102 | You can change the values of many tasks. To do this you should create a block for ChecklistPluginExtension 103 | on your `build.gradle` file. 104 | 105 | ##### Example 106 | 107 | ```groovy 108 | checklist{ 109 | minSDKVersion = 21 110 | applicationIdConvention = "com.mycompany.myapp" 111 | } 112 | ``` 113 | 114 | ##### Configurable Variables 115 | 116 | | Variable | Type | Description | Default Value 117 | |---|---|---|---| 118 | | minSDKVersion | Integer | Indicates the minimum sdk version of the project | 16 | 119 | | targetSDKVersion | Integer | Indicates the target sdk version of the project | 29 | 120 | | compileSDKVersion | Integer | Indicates the compile sdk version of the project | 29 | 121 | | applicationIdConvention | String | Indicates the applicationId prefix of the project | "" | 122 | | resConfigs | List | Indicates the resource configs used in the project | ["en", "tr"] | 123 | | branchPrefix | String | Indicates the git branch prefix | "version/" | 124 | | allowedInstallLocations | List | Indicates the allowed android:installLocation values | [InstallLocationValue.AUTO, InstallLocationValue.INTERNAL_ONLY] | 125 | 126 | 127 | ### Skipping Tasks 128 | You can skip default tasks you don't want to execute. They will be present on the generated HTML report 129 | as skipped. 130 | 131 | To skip tasks, you should set `skippedTasks : List` variable of the `ChecklistPluginExtension`. 132 | 133 | ##### Example 134 | ```groovy 135 | checklist{ 136 | skippedTasks = ["checklistB5", "checklistB6"] 137 | } 138 | ``` 139 | 140 | ## Requirements 141 | To use Checklist Plugin you need at least: 142 | - Android Gradle Plugin 3.3.0 143 | - Gradle Wrapper 4.10.1 144 | 145 | ## Releases 146 | 147 | ## Contributing 148 | Refer to [CONTRIBUTING.md](CONTRIBUTING.md) 149 | -------------------------------------------------------------------------------- /android-checklist/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | id "com.gradle.plugin-publish" version "0.10.1" 19 | id "org.jetbrains.kotlin.jvm" version "1.3.21" 20 | id "java-gradle-plugin" 21 | id "io.gitlab.arturbosch.detekt" version "1.1.1" 22 | } 23 | 24 | apply from: "publishing.gradle" 25 | apply from: "testing.gradle" 26 | 27 | repositories { 28 | jcenter() 29 | google() 30 | maven { 31 | url "https://plugins.gradle.org/m2/" 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation gradleApi() 37 | implementation "com.android.tools.build:gradle:3.3.0" 38 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 39 | implementation 'digital.wup:android-maven-publish:3.6.2' 40 | functionalTestRuntime "com.android.tools.build:gradle:3.3.0" 41 | functionalTestRuntime gradleApi() 42 | } 43 | 44 | detekt { 45 | config = files("detekt.yml") 46 | buildUponDefaultConfig = true 47 | } -------------------------------------------------------------------------------- /android-checklist/detekt.yml: -------------------------------------------------------------------------------- 1 | performance: 2 | SpreadOperator: 3 | active: false 4 | 5 | style: 6 | MagicNumber: 7 | ignorePropertyDeclaration: true 8 | NewLineAtEndOfFile: 9 | active: false -------------------------------------------------------------------------------- /android-checklist/functional-test.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | sourceSets { 18 | functionalTest { 19 | kotlin.srcDir file('src/functionalTest/kotlin') 20 | resources.srcDir file('src/functionalTest/resources') 21 | compileClasspath += sourceSets.main.output + configurations.testRuntime 22 | runtimeClasspath += output + compileClasspath 23 | } 24 | } 25 | 26 | configurations { 27 | functionalTestImplementation.extendsFrom testImplementation 28 | functionalTestRuntime.extendsFrom testRuntime 29 | functionalTestRuntimeOnly.extendsFrom testRuntimeOnly 30 | } 31 | 32 | task createClasspathManifest { 33 | def outputDir = file("$buildDir/$name") 34 | 35 | inputs.files sourceSets.main.runtimeClasspath 36 | outputs.dir outputDir 37 | 38 | doLast { 39 | outputDir.mkdirs() 40 | def collection = sourceSets.main.runtimeClasspath + sourceSets.main.compileClasspath 41 | file("$outputDir/plugin-classpath.txt").text = collection.join("\n") 42 | } 43 | } 44 | 45 | // Add the classpath file to the test runtime classpath 46 | dependencies { 47 | testRuntimeOnly files(createClasspathManifest) 48 | functionalTestRuntimeOnly files(createClasspathManifest) 49 | } 50 | 51 | task functionalTest(type: Test) { 52 | dependsOn("createClasspathManifest") 53 | description = 'Runs the functional tests.' 54 | group = 'verification' 55 | testClassesDirs = sourceSets.functionalTest.output.classesDirs 56 | classpath = sourceSets.functionalTest.runtimeClasspath 57 | mustRunAfter test, integrationTest 58 | } 59 | 60 | check.dependsOn functionalTest 61 | 62 | gradlePlugin { 63 | testSourceSets sourceSets.functionalTest 64 | } 65 | 66 | functionalTest { 67 | useJUnitPlatform() 68 | failFast = false 69 | } 70 | -------------------------------------------------------------------------------- /android-checklist/integration-test.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | sourceSets { 18 | integrationTest { 19 | kotlin.srcDir file('src/integrationTest/kotlin') 20 | resources.srcDir file('src/integrationTest/resources') 21 | compileClasspath += sourceSets.main.output + configurations.testRuntime 22 | runtimeClasspath += output + compileClasspath 23 | } 24 | } 25 | 26 | configurations { 27 | integrationTestImplementation.extendsFrom testImplementation 28 | integrationTestRuntime.extendsFrom testRuntime 29 | integrationTestRuntimeOnly.extendsFrom testRuntimeOnly 30 | } 31 | 32 | task integrationTest(type: Test) { 33 | description = 'Runs the integration tests.' 34 | group = 'verification' 35 | testClassesDirs = sourceSets.integrationTest.output.classesDirs 36 | classpath = sourceSets.integrationTest.runtimeClasspath 37 | mustRunAfter test 38 | } 39 | 40 | check.dependsOn integrationTest 41 | 42 | gradlePlugin { 43 | testSourceSets sourceSets.integrationTest 44 | } 45 | 46 | integrationTest { 47 | useJUnitPlatform() 48 | failFast = true 49 | } 50 | -------------------------------------------------------------------------------- /android-checklist/publishing.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | group = "com.commencis" 18 | version = "0.8.0" + "-SNAPSHOT" 19 | 20 | 21 | gradlePlugin { 22 | plugins { 23 | androidChecklistPlugin { 24 | id = 'com.commencis.android-checklist' 25 | implementationClass = 'com.commencis.checklist.ChecklistBasePlugin' 26 | } 27 | } 28 | } 29 | 30 | pluginBundle { 31 | website = 'https://github.com/Commencis/Android-Checklist-Plugin' 32 | vcsUrl = 'https://github.com/Commencis/Android-Checklist-Plugin.git' 33 | description = 'Gradle plugin for Android projects to automate final checks before publish your app.' 34 | 35 | plugins { 36 | androidChecklistPlugin { 37 | displayName = 'Android Checklist Plugin' 38 | tags = ['android', 'checklist', 'release', 'production'] 39 | } 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/ChecklistBasePlugin.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist 18 | 19 | import com.commencis.checklist.extensions.applyPlugin 20 | import com.commencis.checklist.util.project.type.IProjectTypeProvider 21 | import com.commencis.checklist.util.project.type.ProjectType 22 | import com.commencis.checklist.util.project.type.ProjectTypeProviderImpl 23 | import org.gradle.api.Plugin 24 | import org.gradle.api.Project 25 | import org.gradle.internal.impldep.com.google.api.client.repackaged.com.google.common.annotations.VisibleForTesting 26 | import javax.inject.Inject 27 | 28 | open class ChecklistBasePlugin : Plugin { 29 | 30 | protected val projectTypeProvider: IProjectTypeProvider 31 | 32 | @Inject 33 | constructor() : this( 34 | ProjectTypeProviderImpl() 35 | ) 36 | 37 | @VisibleForTesting 38 | constructor(projectTypeProvider: IProjectTypeProvider) { 39 | this.projectTypeProvider = projectTypeProvider 40 | } 41 | 42 | override fun apply(project: Project) { 43 | when (projectTypeProvider.getProjectType(project)) { 44 | ProjectType.APPLICATION -> project.applyPlugin(ApplicationChecklistPlugin::class.java) 45 | ProjectType.LIBRARY -> project.applyPlugin(LibraryChecklistPlugin::class.java) 46 | ProjectType.FEATURE -> project.applyPlugin(FeatureChecklistPlugin::class.java) 47 | } 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/ChecklistPlugin.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist 18 | 19 | import com.android.build.gradle.AppExtension 20 | import com.android.build.gradle.FeatureExtension 21 | import com.android.build.gradle.LibraryExtension 22 | import com.android.build.gradle.internal.tasks.factory.registerTask 23 | import com.commencis.checklist.task.ChecklistTask 24 | import com.commencis.checklist.task.constants.ChecklistTaskContainer 25 | import com.commencis.checklist.task.constants.ChecklistTaskType 26 | import com.commencis.checklist.task.report.ChecklistFinalTask 27 | import com.commencis.checklist.util.ChecklistData 28 | import com.commencis.checklist.util.plugin.android.AndroidBuildType 29 | import com.commencis.checklist.util.plugin.android.AndroidPluginHelperImpl 30 | import com.commencis.checklist.util.plugin.android.AndroidPluginOwner 31 | import com.commencis.checklist.util.plugin.android.IAndroidPluginHelper 32 | import com.commencis.checklist.util.project.type.ProjectType 33 | import org.gradle.api.Project 34 | import java.io.File 35 | 36 | /** 37 | * Plugin to perform apk validation checks 38 | */ 39 | sealed class ChecklistPlugin : ChecklistBasePlugin(), AndroidPluginOwner { 40 | 41 | override val androidPluginHelper: IAndroidPluginHelper 42 | get() = AndroidPluginHelperImpl() 43 | 44 | private lateinit var checklistPluginExtension: ChecklistPluginExtension 45 | 46 | override fun apply(project: Project) { 47 | this.checklistPluginExtension = project.extensions.create( 48 | ChecklistData.CHECKLIST_EXTENSION_NAME, 49 | ChecklistPluginExtension::class.java 50 | ) 51 | 52 | var apkPath = "" 53 | var assembleTask = "" 54 | getVariants(project).all { variant -> 55 | if (variant.buildType.name.toLowerCase() == AndroidBuildType.RELEASE.buildTypeName && 56 | variant.flavorName == checklistPluginExtension.flavorName) { 57 | variant.outputs.all { 58 | assembleTask = variant.assembleProvider.name 59 | apkPath = it.outputFile.absolutePath 60 | } 61 | } 62 | } 63 | 64 | val projectTaskType = getTaskType(project) 65 | 66 | if (checklistPluginExtension.reportPath.isBlank()) { 67 | checklistPluginExtension.reportPath = 68 | "${project.buildDir}${File.separator}checklist${File.separator}" + 69 | ChecklistData.CHECKLIST_REPORT_NAME 70 | } 71 | 72 | project.afterEvaluate { 73 | if (apkPath.isBlank()) { 74 | project.logger.error("Checklist couldn't find the apk/aar! " + 75 | "Please be sure that you have set the correct product flavor.") 76 | } 77 | // Register predefined tasks 78 | ChecklistTaskContainer.tasks.forEach { task -> 79 | project.tasks.registerTask(ChecklistData.CHECKLIST_TASK_PREFIX + task.key, task.value) 80 | } 81 | 82 | // Configure all tasks(predefined and custom) 83 | project.tasks.withType(ChecklistTask::class.java).forEach { 84 | it.apkPath = apkPath 85 | if (it.name in checklistPluginExtension.skippedTasks || // If skipped by host app 86 | projectTaskType !in it.taskType) { // If type of the task is not compatible with project type 87 | it.skipTask() 88 | } 89 | if (assembleTask.isNotBlank()) { 90 | it.mustRunAfter(assembleTask) 91 | } 92 | } 93 | 94 | project.tasks.register(ChecklistData.CHECKLIST_TASK_REPORT, ChecklistFinalTask::class.java) { 95 | if (checklistPluginExtension.reportPath.isNotBlank()) { 96 | it.reportPath = checklistPluginExtension.reportPath 97 | } 98 | 99 | if (assembleTask.isNotBlank()) { 100 | it.dependsOn(assembleTask) 101 | } 102 | } 103 | } 104 | } 105 | 106 | private fun getTaskType(project: Project): ChecklistTaskType = when (projectTypeProvider.getProjectType(project)) { 107 | ProjectType.APPLICATION -> ChecklistTaskType.APPLICATION 108 | ProjectType.LIBRARY -> ChecklistTaskType.LIBRARY 109 | ProjectType.FEATURE -> ChecklistTaskType.APPLICATION 110 | } 111 | } 112 | 113 | class LibraryChecklistPlugin : ChecklistPlugin() { 114 | override fun getAndroidExtension(project: Project) = super.getAndroidExtension(project) as LibraryExtension 115 | override fun getVariants(project: Project) = getAndroidExtension(project).libraryVariants!! 116 | } 117 | 118 | class FeatureChecklistPlugin : ChecklistPlugin() { 119 | override fun getAndroidExtension(project: Project) = super.getAndroidExtension(project) as FeatureExtension 120 | override fun getVariants(project: Project) = getAndroidExtension(project).featureVariants!! 121 | } 122 | 123 | class ApplicationChecklistPlugin : ChecklistPlugin() { 124 | override fun getAndroidExtension(project: Project) = super.getAndroidExtension(project) as AppExtension 125 | override fun getVariants(project: Project) = getAndroidExtension(project).applicationVariants!! 126 | } 127 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/ChecklistPluginExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist 18 | 19 | import com.commencis.checklist.task.constants.InstallLocationValue 20 | 21 | /** 22 | * Contains configurations for checklist tasks. 23 | */ 24 | open class ChecklistPluginExtension { 25 | 26 | /** 27 | * Names of the tasks to be skipped 28 | */ 29 | var skippedTasks = mutableListOf() 30 | 31 | /** 32 | * Resource configs to be checked 33 | */ 34 | var resConfigs = listOf("en", "tr") 35 | 36 | /** 37 | * Git branch name 38 | */ 39 | var branchPrefix = "version/" 40 | 41 | /** 42 | * Desired minimum sdk version 43 | */ 44 | var minSDKVersion = 16 45 | 46 | /** 47 | * Desired target sdk version 48 | */ 49 | var targetSDKVersion = 29 50 | 51 | /** 52 | * Desired compile sdk version 53 | */ 54 | var compileSDKVersion = 29 55 | 56 | /** 57 | * Application id prefix 58 | */ 59 | var applicationIdConvention = "" 60 | 61 | /** 62 | * Allowed install location values 63 | */ 64 | var allowedInstallLocations: MutableList = 65 | mutableListOf(InstallLocationValue.AUTO, InstallLocationValue.INTERNAL_ONLY) 66 | 67 | /** 68 | * Maximum output file size 69 | */ 70 | var maxOutputSize = 0 71 | 72 | /** 73 | * Name of the apk flavor 74 | */ 75 | var flavorName = "" 76 | 77 | /** 78 | * Path of the checklist report 79 | */ 80 | var reportPath = "" 81 | } 82 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/extensions/PluginAwareExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.extensions 18 | 19 | import org.gradle.api.Plugin 20 | import org.gradle.api.plugins.PluginAware 21 | 22 | /** 23 | * Applies the given plugin with class name. 24 | * 25 | * @param clazz a class to apply. Must implement [Plugin] 26 | * @see [PluginAware.apply] 27 | */ 28 | fun > PluginAware.applyPlugin(clazz: Class) { 29 | this.apply { configurationAction -> configurationAction.plugin(clazz) } 30 | } 31 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/ChecklistTask.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task 18 | 19 | import com.commencis.checklist.ChecklistPluginExtension 20 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 21 | import com.commencis.checklist.task.constants.ChecklistTaskType 22 | import com.commencis.checklist.util.ChecklistData 23 | import com.commencis.checklist.util.command.AaptHelper 24 | import com.commencis.checklist.util.command.ApkAnalyzerHelper 25 | import com.commencis.checklist.util.command.GitHelper 26 | import com.commencis.checklist.util.command.GradleHelper 27 | import com.commencis.checklist.util.file.XmlParser 28 | import org.gradle.api.DefaultTask 29 | import org.gradle.api.tasks.TaskAction 30 | import javax.inject.Inject 31 | 32 | /** 33 | * Base class for checklist tasks 34 | */ 35 | open class ChecklistTask(provider: ChecklistTaskDependencyProvider) : DefaultTask() { 36 | open var taskCode: String = "DefaultTaskCode" 37 | open var taskDescription: String = "You probably forgot to override task fields!" 38 | open var taskType: MutableList = 39 | mutableListOf(ChecklistTaskType.APPLICATION, ChecklistTaskType.LIBRARY) 40 | open var taskAction: () -> (ChecklistTaskResult) = { 41 | ChecklistTaskResult(taskCode, status, taskDescription) 42 | } 43 | 44 | lateinit var result: ChecklistTaskResult 45 | lateinit var apkPath: String 46 | 47 | protected var status = ChecklistTaskStatus.FAIL 48 | 49 | protected val apkAnalyzerHelper: ApkAnalyzerHelper = provider.apkAnalyzerHelper 50 | protected val aaptHelper: AaptHelper = provider.aaptHelper 51 | protected val gradleHelper: GradleHelper = provider.gradleHelper 52 | protected val gitHelper: GitHelper = provider.gitHelper 53 | protected val xmlParser: XmlParser = provider.xmlParser 54 | protected val buildTypeProvider = provider.buildTypeProvider 55 | 56 | protected val checklistPluginExtension: ChecklistPluginExtension = 57 | project.extensions.getByType(ChecklistPluginExtension::class.java) 58 | 59 | @Inject 60 | constructor() : this( 61 | ChecklistTaskDependencyProviderImpl() 62 | ) 63 | 64 | @TaskAction 65 | fun run() { 66 | if (apkPath.isBlank()) { 67 | throw IllegalStateException("Checklist couldn't find the apk/aar! " + 68 | "Please be sure that you have set the correct product flavor.") 69 | } 70 | 71 | this.result = if (status == ChecklistTaskStatus.SKIP) { 72 | ChecklistTaskResult(taskCode, status, taskDescription) 73 | } else { 74 | taskAction.invoke() 75 | } 76 | } 77 | 78 | fun skipTask() { 79 | this.status = ChecklistTaskStatus.SKIP 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/ChecklistTaskDependencyProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task 18 | 19 | import com.commencis.checklist.util.command.AaptHelper 20 | import com.commencis.checklist.util.command.ApkAnalyzerHelper 21 | import com.commencis.checklist.util.command.GitHelper 22 | import com.commencis.checklist.util.command.GradleHelper 23 | import com.commencis.checklist.util.file.XmlParser 24 | import com.commencis.checklist.util.plugin.android.IBuildTypeProvider 25 | 26 | interface ChecklistTaskDependencyProvider { 27 | val gradleHelper: GradleHelper 28 | 29 | val apkAnalyzerHelper: ApkAnalyzerHelper 30 | 31 | val aaptHelper: AaptHelper 32 | 33 | val gitHelper: GitHelper 34 | 35 | val xmlParser: XmlParser 36 | 37 | val buildTypeProvider: IBuildTypeProvider 38 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/ChecklistTaskDependencyProviderImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task 18 | 19 | import com.commencis.checklist.util.command.AaptHelper 20 | import com.commencis.checklist.util.command.ApkAnalyzerHelper 21 | import com.commencis.checklist.util.command.CommandExecutor 22 | import com.commencis.checklist.util.command.GitHelper 23 | import com.commencis.checklist.util.command.GradleHelper 24 | import com.commencis.checklist.util.file.XmlParser 25 | import com.commencis.checklist.util.file.XmlParserImpl 26 | import com.commencis.checklist.util.plugin.android.BuildTypeProviderImpl 27 | import com.commencis.checklist.util.plugin.android.IBuildTypeProvider 28 | 29 | class ChecklistTaskDependencyProviderImpl : ChecklistTaskDependencyProvider { 30 | private val commandExecutor = CommandExecutor() 31 | 32 | override val gradleHelper: GradleHelper 33 | get() = GradleHelper(commandExecutor) 34 | override val apkAnalyzerHelper: ApkAnalyzerHelper 35 | get() = ApkAnalyzerHelper(commandExecutor) 36 | override val aaptHelper: AaptHelper 37 | get() = AaptHelper(commandExecutor) 38 | override val gitHelper: GitHelper 39 | get() = GitHelper(commandExecutor) 40 | override val xmlParser: XmlParser 41 | get() = XmlParserImpl() 42 | override val buildTypeProvider: IBuildTypeProvider 43 | get() = BuildTypeProviderImpl() 44 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/ChecklistTaskResult.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task 18 | 19 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 20 | 21 | /** 22 | * Class that contains the values returned by tasks 23 | */ 24 | data class ChecklistTaskResult( 25 | val taskCode: String, 26 | val status: ChecklistTaskStatus, 27 | val taskDescription: String 28 | ) 29 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/apk/APK2Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.apk 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.task.constants.ChecklistTaskType 23 | import com.commencis.checklist.task.constants.OutputSize 24 | import com.commencis.checklist.util.ChecklistData 25 | 26 | /** 27 | * Task that verifies apk size 28 | */ 29 | open class APK2Task : ChecklistTask() { 30 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_APK2 31 | override var taskDescription = "Apk size should not exceed maximum size. " 32 | override var taskType: MutableList = mutableListOf(ChecklistTaskType.APPLICATION) 33 | 34 | override var taskAction = { 35 | val apkSize = apkAnalyzerHelper.getOutputSize(project, apkPath) / 1000 // in Kb 36 | val maxSize = if (checklistPluginExtension.maxOutputSize == 0) { 37 | OutputSize.APK_SIZE 38 | } else { 39 | checklistPluginExtension.maxOutputSize 40 | } 41 | this.status = ChecklistTaskStatus.enumerateTaskStatus(apkSize <= maxSize) 42 | val reportMessage = taskDescription + "Apk Size: $apkSize kb
" + 43 | "Allowed maximum size: $maxSize kb" 44 | 45 | ChecklistTaskResult(taskCode, status, reportMessage) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B10Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether Google play services api is included as separate dependencies 26 | */ 27 | open class B10Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B10 29 | override var taskDescription = "Google Play Services API should be included as separate dependencies. " 30 | 31 | override var taskAction = { 32 | val playDependencies = gradleHelper.getPlayDependencies(project) 33 | this.status = ChecklistTaskStatus.enumerateTaskStatus(playDependencies.isEmpty()) 34 | val reportMessage = taskDescription + "Found: $playDependencies" 35 | 36 | ChecklistTaskResult(taskCode, status, reportMessage) 37 | } 38 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B1Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.commencis.checklist.task.ChecklistTask 21 | import com.commencis.checklist.task.ChecklistTaskResult 22 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 23 | import com.commencis.checklist.util.ChecklistData 24 | 25 | /** 26 | * Task that checks whether res configs include only the necessary resources 27 | */ 28 | open class B1Task : ChecklistTask() { 29 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B1 30 | override var taskDescription = "Res configs should include only the necessary resources. " 31 | 32 | override var taskAction = { 33 | val resConfigs = project.extensions.getByType(BaseExtension::class.java).defaultConfig.resourceConfigurations 34 | val isResConfigsMinimized = checklistPluginExtension.resConfigs.containsAll(resConfigs) 35 | this.status = ChecklistTaskStatus.enumerateTaskStatus(isResConfigsMinimized) 36 | val reportMessage = taskDescription + "Found: $resConfigs" 37 | 38 | ChecklistTaskResult(taskCode, status, reportMessage) 39 | } 40 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B4Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether appId starts with ChecklistPluginExtension#appIdConvention 26 | */ 27 | open class B4Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B4 29 | override var taskDescription = 30 | "Application ID should start with ${checklistPluginExtension.applicationIdConvention}. " 31 | 32 | override var taskAction = { 33 | val appId = apkAnalyzerHelper.getApplicationId(project, apkPath) 34 | this.status = ChecklistTaskStatus.enumerateTaskStatus( 35 | appId.startsWith(checklistPluginExtension.applicationIdConvention)) 36 | val reportMessage = taskDescription + "Found: $appId" 37 | 38 | ChecklistTaskResult(taskCode, status, reportMessage) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B5Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether minSDK <= ChecklistPluginExtension#minSDKVersion 26 | */ 27 | open class B5Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B5 29 | override var taskDescription = "MinSDK version should be at most ${checklistPluginExtension.minSDKVersion}. " 30 | 31 | override var taskAction = { 32 | val minSdkVersion = apkAnalyzerHelper.getMinSdkVersion(project, apkPath) 33 | this.status = ChecklistTaskStatus.enumerateTaskStatus(minSdkVersion <= checklistPluginExtension.minSDKVersion) 34 | val reportMessage = taskDescription + "Found: $minSdkVersion" 35 | 36 | ChecklistTaskResult(taskCode, status, reportMessage) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B6Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether targetSDK >= ChecklistPluginExtension#targetSDKVersion 26 | */ 27 | open class B6Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B6 29 | override var taskDescription = "TargetSDK version should be at least ${checklistPluginExtension.targetSDKVersion}. " 30 | 31 | override var taskAction = { 32 | val targetSdkVersion = apkAnalyzerHelper.getTargetSdkVersion(project, apkPath) 33 | this.status = ChecklistTaskStatus.enumerateTaskStatus( 34 | targetSdkVersion >= checklistPluginExtension.targetSDKVersion) 35 | val reportMessage = taskDescription + "Found: $targetSdkVersion" 36 | 37 | ChecklistTaskResult(taskCode, status, reportMessage) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B7Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether compileSDK >= ChecklistPluginExtension#compileSDKVersion 26 | */ 27 | open class B7Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B7 29 | override var taskDescription = 30 | "CompileSDK version should be at least ${checklistPluginExtension.compileSDKVersion}. " 31 | 32 | override var taskAction = { 33 | val compileSdkVersion = apkAnalyzerHelper.getCompileSdkVersion(project, apkPath, xmlParser) 34 | this.status = ChecklistTaskStatus.enumerateTaskStatus( 35 | compileSdkVersion >= checklistPluginExtension.compileSDKVersion) 36 | val reportMessage = taskDescription + "Found: $compileSdkVersion" 37 | 38 | ChecklistTaskResult(taskCode, status, reportMessage) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B8Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether the dependencies have specific version numbers instead of -SNAPSHOT and + 26 | */ 27 | open class B8Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B8 29 | override var taskDescription = "Dependencies should use specific version number, not '+' or '-SNAPSHOT'." 30 | 31 | override var taskAction = { 32 | val dependencyVersions = gradleHelper.getApkDependencies(project) 33 | this.status = ChecklistTaskStatus.enumerateTaskStatus(!dependencyVersions.contains(Regex("-SNAPSHOT|:\\+"))) 34 | val reportMessage = taskDescription //TODO + "Found: ..." 35 | 36 | ChecklistTaskResult(taskCode, status, reportMessage) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/build/B9Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.build 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether apk/aar is debuggable 26 | */ 27 | open class B9Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_B9 29 | override var taskDescription = "Apk/Aar should not be debuggable. " 30 | 31 | override var taskAction = { 32 | val isDebuggable = apkAnalyzerHelper.isApkDebuggable(project, apkPath) 33 | this.status = ChecklistTaskStatus.enumerateTaskStatus(!isDebuggable) 34 | val reportMessage = taskDescription + "Found: $isDebuggable" 35 | 36 | ChecklistTaskResult(taskCode, status, reportMessage) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/constants/ChecklistTaskContainer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.constants 18 | 19 | import com.commencis.checklist.task.apk.APK2Task 20 | import com.commencis.checklist.task.build.B10Task 21 | import com.commencis.checklist.task.build.B1Task 22 | import com.commencis.checklist.task.build.B4Task 23 | import com.commencis.checklist.task.build.B5Task 24 | import com.commencis.checklist.task.build.B6Task 25 | import com.commencis.checklist.task.build.B7Task 26 | import com.commencis.checklist.task.build.B8Task 27 | import com.commencis.checklist.task.build.B9Task 28 | import com.commencis.checklist.task.distribution.DIST2Task 29 | import com.commencis.checklist.task.general.GEN1Task 30 | import com.commencis.checklist.task.general.GEN2Task 31 | import com.commencis.checklist.task.general.GEN3Task 32 | import com.commencis.checklist.task.general.GEN4Task 33 | import com.commencis.checklist.task.general.GEN5Task 34 | import com.commencis.checklist.task.manifest.MAN1Task 35 | import com.commencis.checklist.task.manifest.MAN2Task 36 | import com.commencis.checklist.task.manifest.MAN3Task 37 | import com.commencis.checklist.task.manifest.MAN5Task 38 | import com.commencis.checklist.task.manifest.MAN6Task 39 | import com.commencis.checklist.task.permissions.PERM2Task 40 | import com.commencis.checklist.task.permissions.PERM3Task 41 | import com.commencis.checklist.task.proguard.PRG1Task 42 | import com.commencis.checklist.task.proguard.PRG3Task 43 | import com.commencis.checklist.task.proguard.PRG6Task 44 | import com.commencis.checklist.task.signing.SIGN1Task 45 | import com.commencis.checklist.task.signing.SIGN3Task 46 | import com.commencis.checklist.task.signing.SIGN4Task 47 | import com.commencis.checklist.util.ChecklistData 48 | 49 | object ChecklistTaskContainer { 50 | 51 | val tasks = mapOf( 52 | ChecklistData.CHECKLIST_TASK_APK2 to APK2Task::class.java, 53 | ChecklistData.CHECKLIST_TASK_B1 to B1Task::class.java, 54 | ChecklistData.CHECKLIST_TASK_B4 to B4Task::class.java, 55 | ChecklistData.CHECKLIST_TASK_B5 to B5Task::class.java, 56 | ChecklistData.CHECKLIST_TASK_B6 to B6Task::class.java, 57 | ChecklistData.CHECKLIST_TASK_B7 to B7Task::class.java, 58 | ChecklistData.CHECKLIST_TASK_B8 to B8Task::class.java, 59 | ChecklistData.CHECKLIST_TASK_B9 to B9Task::class.java, 60 | ChecklistData.CHECKLIST_TASK_B10 to B10Task::class.java, 61 | ChecklistData.CHECKLIST_TASK_DIST2 to DIST2Task::class.java, 62 | ChecklistData.CHECKLIST_TASK_GEN1 to GEN1Task::class.java, 63 | ChecklistData.CHECKLIST_TASK_GEN2 to GEN2Task::class.java, 64 | ChecklistData.CHECKLIST_TASK_GEN3 to GEN3Task::class.java, 65 | ChecklistData.CHECKLIST_TASK_GEN4 to GEN4Task::class.java, 66 | ChecklistData.CHECKLIST_TASK_GEN5 to GEN5Task::class.java, 67 | ChecklistData.CHECKLIST_TASK_PRG1 to PRG1Task::class.java, 68 | ChecklistData.CHECKLIST_TASK_PRG3 to PRG3Task::class.java, 69 | ChecklistData.CHECKLIST_TASK_PRG6 to PRG6Task::class.java, 70 | ChecklistData.CHECKLIST_TASK_PERM2 to PERM2Task::class.java, 71 | ChecklistData.CHECKLIST_TASK_PERM3 to PERM3Task::class.java, 72 | ChecklistData.CHECKLIST_TASK_SIGN1 to SIGN1Task::class.java, 73 | ChecklistData.CHECKLIST_TASK_SIGN3 to SIGN3Task::class.java, 74 | ChecklistData.CHECKLIST_TASK_SIGN4 to SIGN4Task::class.java, 75 | ChecklistData.CHECKLIST_TASK_MAN1 to MAN1Task::class.java, 76 | ChecklistData.CHECKLIST_TASK_MAN2 to MAN2Task::class.java, 77 | ChecklistData.CHECKLIST_TASK_MAN3 to MAN3Task::class.java, 78 | ChecklistData.CHECKLIST_TASK_MAN5 to MAN5Task::class.java, 79 | ChecklistData.CHECKLIST_TASK_MAN6 to MAN6Task::class.java 80 | ) 81 | 82 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/constants/ChecklistTaskStatus.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.constants 18 | 19 | /** 20 | * Checklist task status to be returned after task is finished 21 | */ 22 | enum class ChecklistTaskStatus { 23 | FAIL, 24 | SUCCESS, 25 | SKIP, 26 | INFO; 27 | 28 | companion object{ 29 | fun enumerateTaskStatus(isSuccess: Boolean) = if (isSuccess) { 30 | SUCCESS 31 | } else { 32 | FAIL 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/constants/ChecklistTaskType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.constants 18 | 19 | enum class ChecklistTaskType { 20 | APPLICATION, 21 | LIBRARY, 22 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/constants/InstallLocationValue.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.constants 18 | 19 | enum class InstallLocationValue(val installLocation: String, val value: Int) { 20 | AUTO("auto", 0), 21 | INTERNAL_ONLY("internalOnly", 1), 22 | PREFER_EXTERNAL("preferExternal", 2); 23 | 24 | companion object{ 25 | fun getInstallLocationValueFromIndex(index: Int): InstallLocationValue { 26 | return values().find { it.value == index } ?: AUTO 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/constants/OutputSize.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.constants 18 | 19 | /** 20 | * Build output sizes in kilobytes 21 | */ 22 | object OutputSize { 23 | const val APK_SIZE = 15000 24 | const val AAR_SIZE = 500 25 | const val FEATURE_SIZE = 4000 26 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/distribution/DIST2Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.distribution 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.task.constants.ChecklistTaskType 23 | import com.commencis.checklist.task.constants.OutputSize 24 | import com.commencis.checklist.util.ChecklistData 25 | 26 | /** 27 | * Task that verifies aar size 28 | */ 29 | open class DIST2Task : ChecklistTask() { 30 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_DIST2 31 | override var taskDescription = "Aar size should not exceed maximum size. " 32 | override var taskType: MutableList = mutableListOf(ChecklistTaskType.LIBRARY) 33 | 34 | override var taskAction = { 35 | val aarSize = apkAnalyzerHelper.getOutputSize(project, apkPath) / 1000 // in Kb 36 | val maxSize = if (checklistPluginExtension.maxOutputSize == 0) { 37 | OutputSize.AAR_SIZE 38 | } else { 39 | checklistPluginExtension.maxOutputSize 40 | } 41 | this.status = ChecklistTaskStatus.enumerateTaskStatus(aarSize <= maxSize) 42 | val reportMessage = taskDescription + "Aar Size: $aarSize kb
" + 43 | "Allowed maximum size: $maxSize kb" 44 | 45 | ChecklistTaskResult(taskCode, status, reportMessage) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/general/GEN1Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.general 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether git branch name has correct prefix. 26 | */ 27 | open class GEN1Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_GEN1 29 | override var taskDescription = "Git branch should start with ${checklistPluginExtension.branchPrefix}. " 30 | 31 | override var taskAction = { 32 | val branchName = gitHelper.getBranchName(project) 33 | this.status = ChecklistTaskStatus.enumerateTaskStatus( 34 | branchName.startsWith(checklistPluginExtension.branchPrefix)) 35 | val reportMessage = taskDescription + "Found: $branchName" 36 | 37 | ChecklistTaskResult(taskCode, status, reportMessage) 38 | } 39 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/general/GEN2Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.general 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that reminds to make sure that basic functionality of the app is fully working. 26 | */ 27 | open class GEN2Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_GEN2 29 | override var taskDescription: String = "Make sure that basic functionality of the app is fully working." 30 | 31 | override var taskAction = { 32 | status = ChecklistTaskStatus.INFO 33 | ChecklistTaskResult(taskCode, status, taskDescription) 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/general/GEN3Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.general 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that reminds to make sure that the app doesn't crash and works as expected 26 | */ 27 | open class GEN3Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_GEN3 29 | override var taskDescription: String = 30 | "Make sure that the app doesn't crash and works as expected when the existing one is updated." 31 | 32 | override var taskAction = { 33 | status = ChecklistTaskStatus.INFO 34 | ChecklistTaskResult(taskCode, status, taskDescription) 35 | } 36 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/general/GEN4Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.general 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task to verify permissions, locales and densities 26 | */ 27 | open class GEN4Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_GEN4 29 | override var taskDescription: String = 30 | "Verify permissions, locales and densities supported from apk/aar." 31 | 32 | override var taskAction = { 33 | val apkSummary = aaptHelper.getApkSummary(project, apkPath) 34 | val reportMessage = taskDescription // TODO too long output: + "Found: $apkSummary" 35 | status = ChecklistTaskStatus.INFO 36 | ChecklistTaskResult(taskCode, status, reportMessage) 37 | } 38 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/general/GEN5Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.general 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks that unit tests ran and did not fail 26 | */ 27 | open class GEN5Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_GEN5 29 | override var taskDescription: String = 30 | "Verify that unit tests ran and did not fail" 31 | 32 | override var taskAction = { 33 | val testResult = gradleHelper.runTests(project) 34 | status = ChecklistTaskStatus.enumerateTaskStatus(testResult.isEmpty()) 35 | ChecklistTaskResult(taskCode, status, taskDescription) 36 | } 37 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/manifest/MAN1Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.manifest 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.task.constants.ChecklistTaskType 23 | import com.commencis.checklist.util.ChecklistData 24 | 25 | /** 26 | * Task that shows current version code to check whether it is incremented 27 | */ 28 | open class MAN1Task : ChecklistTask() { 29 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_MAN1 30 | override var taskDescription = 31 | "Version code should be incremented. " 32 | override var taskType: MutableList = mutableListOf(ChecklistTaskType.APPLICATION) 33 | 34 | override var taskAction = { 35 | val versionCode = apkAnalyzerHelper.getVersionCode(project, apkPath, xmlParser) 36 | this.status = ChecklistTaskStatus.INFO 37 | val reportMessage = taskDescription + "Current Version Code: $versionCode" 38 | 39 | ChecklistTaskResult(taskCode, status, reportMessage) 40 | } 41 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/manifest/MAN2Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.manifest 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that shows version name to check if it is updated 26 | */ 27 | open class MAN2Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_MAN2 29 | override var taskDescription = 30 | "Version names should be updated. " 31 | 32 | override var taskAction = { 33 | val versionName = apkAnalyzerHelper.getVersionName(project, apkPath, xmlParser) 34 | this.status = ChecklistTaskStatus.INFO 35 | val reportMessage = taskDescription + "Current VersionName: $versionName" 36 | 37 | ChecklistTaskResult(taskCode, status, reportMessage) 38 | } 39 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/manifest/MAN3Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.manifest 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.task.constants.ChecklistTaskType 23 | import com.commencis.checklist.util.ChecklistData 24 | 25 | /** 26 | * Task that checks if the version name follows ... convention. 27 | */ 28 | open class MAN3Task : ChecklistTask() { 29 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_MAN3 30 | override var taskDescription = 31 | "Version names should follow <major>.<minor>.<patch>.<buildNumber> convention. " 32 | override var taskType: MutableList = mutableListOf(ChecklistTaskType.APPLICATION) 33 | //TODO: Check buildNumber on production releases 34 | override var taskAction = { 35 | val versionName = apkAnalyzerHelper.getVersionName(project, apkPath, xmlParser) 36 | this.status = ChecklistTaskStatus.enumerateTaskStatus( 37 | versionName.matches("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+".toRegex())) 38 | val reportMessage = taskDescription + "Found: $versionName" 39 | 40 | ChecklistTaskResult(taskCode, status, reportMessage) 41 | } 42 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/manifest/MAN5Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.manifest 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.task.constants.ChecklistTaskType 23 | import com.commencis.checklist.task.constants.InstallLocationValue 24 | import com.commencis.checklist.util.ChecklistData 25 | 26 | /** 27 | * Task that verifies installLocation attribute on manifest 28 | */ 29 | open class MAN5Task : ChecklistTask() { 30 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_MAN5 31 | override var taskDescription = 32 | "android:installLocation should not be set preferExternal. " 33 | override var taskType: MutableList = mutableListOf(ChecklistTaskType.APPLICATION) 34 | 35 | override var taskAction = { 36 | val installLocation = apkAnalyzerHelper.getInstallLocation(project, apkPath, xmlParser) 37 | this.status = ChecklistTaskStatus.enumerateTaskStatus(installLocation == -1 || 38 | installLocation in checklistPluginExtension.allowedInstallLocations.map { it.value }) 39 | val reportMessage = taskDescription + 40 | "Found: ${InstallLocationValue.getInstallLocationValueFromIndex(installLocation).installLocation}" 41 | 42 | ChecklistTaskResult(taskCode, status, reportMessage) 43 | } 44 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/manifest/MAN6Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.manifest 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.task.constants.ChecklistTaskType 23 | import com.commencis.checklist.util.ChecklistData 24 | 25 | /** 26 | * Task that checks if the version name follows .. convention. 27 | */ 28 | open class MAN6Task : ChecklistTask() { 29 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_MAN6 30 | override var taskDescription = 31 | "Version names should follow <major>.<minor>.<patch> convention. " 32 | override var taskType: MutableList = mutableListOf(ChecklistTaskType.LIBRARY) 33 | //TODO: Check SNAPSHOT on production releases 34 | override var taskAction = { 35 | val versionName = apkAnalyzerHelper.getVersionName(project, apkPath, xmlParser) 36 | this.status = ChecklistTaskStatus.enumerateTaskStatus( 37 | versionName.matches("[0-9]+\\.[0-9]+\\.[0-9]+".toRegex())) 38 | val reportMessage = taskDescription + "Found: $versionName" 39 | 40 | ChecklistTaskResult(taskCode, status, reportMessage) 41 | } 42 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/permissions/PERM2Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.permissions 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that shows permissions to make sure that there is no unnecessary permission used 26 | */ 27 | open class PERM2Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_PERM2 29 | override var taskDescription = "Make sure that there is no unnecessary permission used. " 30 | 31 | override var taskAction = { 32 | val permissions = aaptHelper.getPermissions(project, apkPath) 33 | this.status = ChecklistTaskStatus.INFO 34 | val reportMessage = taskDescription + "Current Permissions:
$permissions" 35 | 36 | ChecklistTaskResult(taskCode, status, reportMessage) 37 | } 38 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/permissions/PERM3Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.permissions 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether android:required set false in the manifest. 26 | */ 27 | open class PERM3Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_PERM3 29 | override var taskDescription = "android:required should set false in the manifest. " 30 | 31 | override var taskAction = { 32 | val xml = apkAnalyzerHelper.getManifest(project, apkPath) 33 | val isRequired = xmlParser.findAttribute(xml, "android:required") ?: "" 34 | this.status = ChecklistTaskStatus.enumerateTaskStatus(isRequired.isEmpty() || !isRequired.toBoolean()) 35 | val reportMessage = taskDescription + "Found: $isRequired" 36 | 37 | ChecklistTaskResult(taskCode, status, reportMessage) 38 | } 39 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/proguard/PRG1Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.proguard 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | 24 | /** 25 | * Task that checks whether the apk contains logging classes 26 | */ 27 | open class PRG1Task : ChecklistTask() { 28 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_PRG1 29 | override var taskDescription = "Apk should not contain any logging classes. " 30 | 31 | override var taskAction = { 32 | val classes = apkAnalyzerHelper.getClasses(project, apkPath) 33 | this.status = ChecklistTaskStatus.enumerateTaskStatus(!classes.contains("android.util.Log")) 34 | val reportMessage = taskDescription // + "Found: $classes" 35 | 36 | ChecklistTaskResult(taskCode, status, reportMessage) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/proguard/PRG3Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.proguard 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | import com.commencis.checklist.util.plugin.android.AndroidBuildType 24 | 25 | /** 26 | * Task that checks whether proguard files are set through proguardFiles property. 27 | */ 28 | open class PRG3Task : ChecklistTask() { 29 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_PRG3 30 | override var taskDescription = "proguard files should be set through proguardFiles property. " 31 | 32 | override var taskAction = { 33 | val build = buildTypeProvider.getBuildType(project, AndroidBuildType.RELEASE) 34 | this.status = ChecklistTaskStatus.enumerateTaskStatus(build.proguardFiles.isNotEmpty()) 35 | val reportMessage = taskDescription + 36 | "Found: ${build.proguardFiles}" 37 | 38 | ChecklistTaskResult(taskCode, status, reportMessage) 39 | } 40 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/proguard/PRG6Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.proguard 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.ChecklistTaskResult 21 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 22 | import com.commencis.checklist.util.ChecklistData 23 | import com.commencis.checklist.util.plugin.android.AndroidBuildType 24 | 25 | /** 26 | * Task that checks whether minifyEnabled and shrinkResources are set true. for release builds. 27 | */ 28 | open class PRG6Task : ChecklistTask() { 29 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_PRG6 30 | override var taskDescription = "minifyEnabled and shrinkResources should be set to true. " 31 | 32 | override var taskAction = { 33 | val build = buildTypeProvider.getBuildType(project, AndroidBuildType.RELEASE) 34 | val isMinified = build.isMinifyEnabled && build.isShrinkResources 35 | this.status = ChecklistTaskStatus.enumerateTaskStatus(isMinified) 36 | val reportMessage = taskDescription + 37 | "Found: MinifyEnabled:${build.isMinifyEnabled}\n" + 38 | "ShrinkResources: ${build.isShrinkResources}" 39 | 40 | ChecklistTaskResult(taskCode, status, reportMessage) 41 | } 42 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/ChecklistFinalTask.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.commencis.checklist.task.ChecklistTask 21 | import com.commencis.checklist.task.report.container.ChecklistReportContainer 22 | import com.commencis.checklist.task.report.container.ChecklistReportContainerImpl 23 | import com.commencis.checklist.util.file.ChecklistFileHelper 24 | import com.commencis.checklist.util.project.ProjectInfo 25 | import groovy.lang.Closure 26 | import groovy.lang.DelegatesTo 27 | import org.gradle.api.Action 28 | import org.gradle.api.DefaultTask 29 | import org.gradle.api.reporting.Reporting 30 | import org.gradle.api.tasks.TaskAction 31 | import org.gradle.util.ConfigureUtil 32 | 33 | /** 34 | * Main checklist task that depends on all other checklist tasks 35 | * and generates html report file 36 | */ 37 | open class ChecklistFinalTask : DefaultTask(), Reporting { 38 | private val reports: ChecklistReportContainer 39 | 40 | lateinit var reportPath: String 41 | 42 | init { 43 | project.tasks.withType(ChecklistTask::class.java).forEach { 44 | this.dependsOn(it) 45 | } 46 | reports = project.objects.newInstance(ChecklistReportContainerImpl::class.java, this) 47 | reports.getHtml().isEnabled = true 48 | reports.getXml().isEnabled = true 49 | } 50 | 51 | /** 52 | * Gets results from other tasks and generate report file 53 | */ 54 | @TaskAction 55 | fun run() { 56 | val fileHelper = ChecklistFileHelper() 57 | reports.enabled.forEach { 58 | it.destination = fileHelper.getFileWithDirectoryAssurance("$reportPath.${it.name}") 59 | } 60 | val reportGenerator = ChecklistReportGenerator(reports.enabled.asMap) 61 | val allTasks = mutableListOf() 62 | taskDependencies.getDependencies(this).forEach { task -> 63 | if (task is ChecklistTask) { 64 | allTasks.add(task) 65 | } 66 | } 67 | val projectInfo = ProjectInfo( 68 | project.rootProject.name, 69 | project.name, 70 | project.extensions.getByType(BaseExtension::class.java).defaultConfig.versionName 71 | ) 72 | reportGenerator.generateReports(projectInfo, allTasks) 73 | } 74 | 75 | override fun getReports(): ChecklistReportContainer { 76 | return reports 77 | } 78 | 79 | override fun reports( 80 | @DelegatesTo(value = ChecklistReportContainer::class, strategy = Closure.DELEGATE_FIRST) 81 | closure: Closure): ChecklistReportContainer { 82 | return reports(ConfigureUtil.configureUsing(closure)) 83 | } 84 | 85 | override fun reports(configureAction: Action): ChecklistReportContainer { 86 | configureAction.execute(reports) 87 | return reports 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/ChecklistReportGenerator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.report.strategy.ChecklistHTMLReportStrategy 21 | import com.commencis.checklist.task.report.strategy.ChecklistReportStrategy 22 | import com.commencis.checklist.task.report.strategy.ChecklistXMLReportStrategy 23 | import com.commencis.checklist.util.project.ProjectInfo 24 | import org.gradle.api.reporting.SingleFileReport 25 | 26 | class ChecklistReportGenerator(private val enabledReports: Map) { 27 | private val reportStrategies: List = listOf( 28 | ChecklistHTMLReportStrategy(), 29 | ChecklistXMLReportStrategy()) 30 | 31 | fun generateReports(projectInfo: ProjectInfo, tasks: List) { 32 | reportStrategies.forEach { 33 | if (it.reportType in enabledReports) { 34 | val report = enabledReports[it.reportType] 35 | it.generateReport(projectInfo, tasks, report!!.destination) 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/container/ChecklistReportContainer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.container 18 | 19 | import org.gradle.api.reporting.ReportContainer 20 | import org.gradle.api.reporting.SingleFileReport 21 | import org.gradle.api.tasks.Internal 22 | 23 | interface ChecklistReportContainer : ReportContainer { 24 | /** 25 | * The checklist HTML report. 26 | * 27 | * @return The checklist HTML report 28 | */ 29 | @Internal 30 | fun getHtml(): SingleFileReport 31 | 32 | /** 33 | * The checklist XML report. 34 | * 35 | * @return The checklist XML report 36 | */ 37 | @Internal 38 | fun getXml(): SingleFileReport 39 | } 40 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/container/ChecklistReportContainerImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.container 18 | 19 | import org.gradle.api.Task 20 | import org.gradle.api.reporting.SingleFileReport 21 | import org.gradle.api.reporting.internal.CustomizableHtmlReportImpl 22 | import org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport 23 | import org.gradle.api.reporting.internal.TaskReportContainer 24 | import javax.inject.Inject 25 | 26 | const val htmlReportType = "html" 27 | const val xmlReportType = "xml" 28 | 29 | open class ChecklistReportContainerImpl 30 | @Inject 31 | constructor(task: Task) : 32 | TaskReportContainer(SingleFileReport::class.java, task), 33 | ChecklistReportContainer { 34 | 35 | init { 36 | add(CustomizableHtmlReportImpl::class.java, htmlReportType, task) 37 | add(TaskGeneratedSingleFileReport::class.java, xmlReportType, task) 38 | } 39 | 40 | override fun getHtml(): SingleFileReport = getByName(htmlReportType) 41 | 42 | override fun getXml(): SingleFileReport = getByName(xmlReportType) 43 | 44 | } 45 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/strategy/ChecklistHTMLReportStrategy.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.strategy 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.report.container.htmlReportType 21 | import com.commencis.checklist.task.report.writer.ChecklistHtmlWriter 22 | import com.commencis.checklist.util.project.ProjectInfo 23 | import java.io.File 24 | 25 | class ChecklistHTMLReportStrategy : ChecklistReportStrategy() { 26 | override val reportType: String = htmlReportType 27 | 28 | override fun generateReport(projectInfo: ProjectInfo, tasks: List, reportFile: File) { 29 | generateReportInternal(projectInfo, tasks, reportFile, ChecklistHtmlWriter()) 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/strategy/ChecklistReportStrategy.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.strategy 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 21 | import com.commencis.checklist.task.report.writer.ChecklistReportWriter 22 | import com.commencis.checklist.util.project.ProjectInfo 23 | import java.io.File 24 | 25 | abstract class ChecklistReportStrategy { 26 | abstract val reportType: String 27 | abstract fun generateReport(projectInfo: ProjectInfo, tasks: List, reportFile: File) 28 | 29 | protected fun generateReportInternal( 30 | projectInfo: ProjectInfo, 31 | tasks: List, 32 | reportFile: File, 33 | writer: ChecklistReportWriter 34 | ) { 35 | writer.insertGeneralFileInfo(projectInfo) 36 | val failedTasks = tasks.filter { it.result.status == ChecklistTaskStatus.FAIL }.map { it.taskCode } 37 | val skippedTasks = tasks.filter { it.result.status == ChecklistTaskStatus.SKIP }.map { it.taskCode } 38 | val allTasks = tasks.map { it.taskCode } 39 | writer.insertOverallInfo(failedTasks, skippedTasks, allTasks) 40 | tasks.forEach { task -> 41 | writer.insertTask(task.result) 42 | } 43 | writer.writeReport(reportFile) 44 | } 45 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/strategy/ChecklistXMLReportStrategy.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.strategy 18 | 19 | import com.commencis.checklist.task.ChecklistTask 20 | import com.commencis.checklist.task.report.container.xmlReportType 21 | import com.commencis.checklist.task.report.writer.ChecklistXmlWriter 22 | import com.commencis.checklist.util.project.ProjectInfo 23 | import java.io.File 24 | 25 | class ChecklistXMLReportStrategy : ChecklistReportStrategy() { 26 | override val reportType: String = xmlReportType 27 | 28 | override fun generateReport(projectInfo: ProjectInfo, tasks: List, reportFile: File) { 29 | generateReportInternal(projectInfo, tasks, reportFile, ChecklistXmlWriter()) 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/writer/ChecklistHtmlWriter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.writer 18 | 19 | import com.commencis.checklist.task.ChecklistTaskResult 20 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 21 | import com.commencis.checklist.util.project.ProjectInfo 22 | import java.io.File 23 | 24 | class ChecklistHtmlWriter : ChecklistReportWriter { 25 | 26 | private var html = """ 27 | 28 | 29 | 30 | 35 | 38 | 42 | Checklist 43 | 44 | 45 |
46 | """.trimIndent() 47 | 48 | private var table = """ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | """.trimIndent() 63 | 64 | private val tableEnd = "
TaskStatusDescription
" 65 | 66 | private var fileInfo = """ 67 |
68 |

Checklist Plugin Report

69 | """.trimIndent() 70 | 71 | private val fileInfoEnd = "
" 72 | 73 | private var overallInfo = "
" 74 | 75 | private val overallInfoEnd = "
" 76 | 77 | private val fileEnd = """ 78 |
79 | 80 | 82 | 84 | 86 | 92 | 93 | """.trimIndent() 94 | 95 | override fun insertTask(taskResult: ChecklistTaskResult) { 96 | val statusClass = when (taskResult.status) { 97 | ChecklistTaskStatus.SUCCESS -> "" 98 | ChecklistTaskStatus.FAIL -> "" 99 | ChecklistTaskStatus.SKIP -> "" 100 | ChecklistTaskStatus.INFO -> "" 101 | } 102 | val tableRow = """ 103 | $statusClass 104 | ${taskResult.taskCode} 105 | ${taskResult.status} 106 | ${taskResult.taskDescription} 107 | 108 | """.trimIndent() 109 | 110 | table += tableRow 111 | } 112 | 113 | override fun insertOverallInfo( 114 | failedTasks: List, 115 | skippedTasks: List, 116 | allTasks: List 117 | ) { 118 | val totalTaskRow = generateOverallTableRow("primary", "Total Task Count", allTasks.size.toString()) 119 | val failedTaskCountRow = generateOverallTableRow("danger", "Failed Task Count", failedTasks.size.toString()) 120 | val failedTaskRow = generateOverallTableRow("danger", "Failed Tasks", failedTasks.joinToString("
")) 121 | val skippedTaskCountRow = generateOverallTableRow("warning", "Skipped Task Count", skippedTasks.size.toString()) 122 | val skippedTasksRow = generateOverallTableRow("warning", "Skipped Tasks", skippedTasks.joinToString("
")) 123 | 124 | overallInfo += (totalTaskRow + failedTaskCountRow + failedTaskRow + skippedTaskCountRow + skippedTasksRow) 125 | } 126 | 127 | private fun generateOverallTableRow(color: String, header: String, body: String) = """ 128 |
129 |
$header
130 |
131 |
$body
132 |
133 |
134 | """.trimIndent() 135 | 136 | override fun insertGeneralFileInfo(projectInfo: ProjectInfo) { 137 | val projectHtml = """ 138 |

${projectInfo.name}

139 |

Module: ${projectInfo.moduleName}

140 |
Version: ${projectInfo.versionName}
141 | """.trimIndent() 142 | fileInfo += projectHtml 143 | } 144 | 145 | private fun getFileContent(): String = 146 | html + fileInfo + fileInfoEnd + overallInfo + overallInfoEnd + table + tableEnd + fileEnd 147 | 148 | override fun writeReport(file: File) { 149 | file.writeText(getFileContent()) 150 | println("Checklist HTML Report is generated at ${file.absolutePath}") 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/writer/ChecklistReportWriter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.writer 18 | 19 | import com.commencis.checklist.task.ChecklistTaskResult 20 | import com.commencis.checklist.util.project.ProjectInfo 21 | import java.io.File 22 | 23 | interface ChecklistReportWriter { 24 | fun insertTask(taskResult: ChecklistTaskResult) 25 | fun insertOverallInfo( 26 | failedTasks: List, 27 | skippedTasks: List, 28 | allTasks: List 29 | ) 30 | 31 | fun insertGeneralFileInfo(projectInfo: ProjectInfo) 32 | fun writeReport(file: File) 33 | } 34 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/report/writer/ChecklistXmlWriter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.report.writer 18 | 19 | import com.commencis.checklist.task.ChecklistTaskResult 20 | import com.commencis.checklist.util.project.ProjectInfo 21 | import com.sun.xml.txw2.output.IndentingXMLStreamWriter 22 | import java.io.ByteArrayOutputStream 23 | import java.io.File 24 | import java.io.OutputStream 25 | import javax.xml.stream.XMLOutputFactory 26 | 27 | class ChecklistXmlWriter : ChecklistReportWriter { 28 | private var out: OutputStream = ByteArrayOutputStream() 29 | 30 | private val xmlWriter = IndentingXMLStreamWriter(XMLOutputFactory.newFactory().createXMLStreamWriter(out, "UTF-8")) 31 | 32 | init { 33 | xmlWriter.writeStartDocument("utf-8", "1.0") 34 | xmlWriter.writeStartElement("checklist") 35 | } 36 | 37 | override fun insertTask(taskResult: ChecklistTaskResult) { 38 | xmlWriter.writeStartElement("task") 39 | xmlWriter.writeStartElement("code") 40 | xmlWriter.writeCharacters(taskResult.taskCode) 41 | xmlWriter.writeEndElement() 42 | xmlWriter.writeStartElement("status") 43 | xmlWriter.writeCharacters(taskResult.status.name) 44 | xmlWriter.writeEndElement() 45 | xmlWriter.writeStartElement("description") 46 | xmlWriter.writeCharacters(taskResult.taskDescription) 47 | xmlWriter.writeEndElement() 48 | xmlWriter.writeEndElement() 49 | } 50 | 51 | override fun insertOverallInfo(failedTasks: List, skippedTasks: List, allTasks: List) { 52 | xmlWriter.writeStartElement("overallInfo") 53 | xmlWriter.writeStartElement("taskCount") 54 | xmlWriter.writeCharacters(allTasks.size.toString()) 55 | xmlWriter.writeEndElement() 56 | xmlWriter.writeStartElement("failedTaskCount") 57 | xmlWriter.writeCharacters(failedTasks.size.toString()) 58 | xmlWriter.writeEndElement() 59 | xmlWriter.writeStartElement("failedTasks") 60 | xmlWriter.writeCharacters(failedTasks.joinToString(", ")) 61 | xmlWriter.writeEndElement() 62 | xmlWriter.writeStartElement("skippedTaskCount") 63 | xmlWriter.writeCharacters(skippedTasks.size.toString()) 64 | xmlWriter.writeEndElement() 65 | xmlWriter.writeStartElement("skippedTasks") 66 | xmlWriter.writeCharacters(skippedTasks.joinToString(", ")) 67 | xmlWriter.writeEndElement() 68 | xmlWriter.writeEndElement() 69 | xmlWriter.writeStartElement("tasks") 70 | } 71 | 72 | override fun insertGeneralFileInfo(projectInfo: ProjectInfo) { 73 | xmlWriter.writeEmptyElement("project") 74 | xmlWriter.writeAttribute("projectName", projectInfo.name) 75 | xmlWriter.writeAttribute("moduleName", projectInfo.moduleName) 76 | xmlWriter.writeAttribute( 77 | "versionName", 78 | projectInfo.versionName.toString() // Since versionName is nullable, toString() is used 79 | ) 80 | } 81 | 82 | override fun writeReport(file: File) { 83 | xmlWriter.writeEndElement() 84 | xmlWriter.writeEndElement() 85 | xmlWriter.writeEndDocument() 86 | file.writeText(out.toString()) 87 | println("Checklist XML Report is generated at ${file.absolutePath}") 88 | } 89 | 90 | 91 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/signing/SIGN1Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.signing 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.commencis.checklist.task.ChecklistTask 21 | import com.commencis.checklist.task.ChecklistTaskResult 22 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 23 | import com.commencis.checklist.util.ChecklistData 24 | import com.commencis.checklist.util.plugin.android.AndroidBuildType 25 | 26 | /** 27 | * Task that checks whether keystore file is in project folder. 28 | */ 29 | open class SIGN1Task : ChecklistTask() { 30 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_SIGN1 31 | override var taskDescription = "Keystore file should be in project folder. " 32 | 33 | override var taskAction = { 34 | val build = buildTypeProvider.getBuildType(project, AndroidBuildType.RELEASE) 35 | val signingConfig = build.signingConfig 36 | this.status = ChecklistTaskStatus.enumerateTaskStatus(signingConfig != null && 37 | signingConfig.storeFile != null && 38 | signingConfig.storeFile.absolutePath.startsWith(project.projectDir.absolutePath)) 39 | val reportMessage = taskDescription + 40 | "Found: " + when { 41 | signingConfig == null -> { 42 | "No signing config found" 43 | } 44 | signingConfig.storeFile == null -> { 45 | "No store file found" 46 | } 47 | else -> { 48 | signingConfig.storeFile 49 | } 50 | } 51 | 52 | ChecklistTaskResult(taskCode, status, reportMessage) 53 | } 54 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/signing/SIGN3Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.signing 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.commencis.checklist.task.ChecklistTask 21 | import com.commencis.checklist.task.ChecklistTaskResult 22 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 23 | import com.commencis.checklist.util.ChecklistData 24 | import com.commencis.checklist.util.plugin.android.AndroidBuildType 25 | 26 | /** 27 | * Task that checks whether the apk contains release keystore 28 | */ 29 | open class SIGN3Task : ChecklistTask() { 30 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_SIGN3 31 | override var taskDescription = "Apk should not contain release keystore files. " 32 | 33 | override var taskAction = { 34 | val files = apkAnalyzerHelper.getFiles(project, apkPath) 35 | val build = buildTypeProvider.getBuildType(project, AndroidBuildType.RELEASE) 36 | val signingConfig = build.signingConfig 37 | this.status = ChecklistTaskStatus.enumerateTaskStatus(signingConfig == null || 38 | signingConfig.storeFile == null || 39 | !files.contains(signingConfig.storeFile.name)) 40 | val reportMessage = taskDescription // + "Found: $files" 41 | 42 | ChecklistTaskResult(taskCode, status, reportMessage) 43 | } 44 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/task/signing/SIGN4Task.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.task.signing 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.commencis.checklist.task.ChecklistTask 21 | import com.commencis.checklist.task.ChecklistTaskResult 22 | import com.commencis.checklist.task.constants.ChecklistTaskStatus 23 | import com.commencis.checklist.util.ChecklistData 24 | import com.commencis.checklist.util.plugin.android.AndroidBuildType 25 | 26 | /** 27 | * Task that checks whether storePassword, keyAlias, keyPassword are set in the build.gradle file. 28 | */ 29 | open class SIGN4Task : ChecklistTask() { 30 | override var taskCode: String = ChecklistData.CHECKLIST_TASK_SIGN4 31 | override var taskDescription = "storePassword, keyAlias, keyPassword should be set in the build.gradle file. " 32 | 33 | override var taskAction = { 34 | val build = buildTypeProvider.getBuildType(project, AndroidBuildType.RELEASE) 35 | val signingConfig = build.signingConfig 36 | this.status = ChecklistTaskStatus.enumerateTaskStatus( 37 | signingConfig != null && 38 | !signingConfig.storePassword.isNullOrEmpty() && 39 | !signingConfig.keyAlias.isNullOrEmpty() && 40 | !signingConfig.keyPassword.isNullOrEmpty()) 41 | val reportMessage = taskDescription + 42 | "Found:
" + when (signingConfig) { 43 | null -> "No signing config found." 44 | else -> "StorePassword is empty: ${signingConfig.storePassword.isNullOrEmpty()}
" + 45 | "KeyAlias is empty: ${signingConfig.keyAlias.isNullOrEmpty()}
" + 46 | "KeyPassword is empty: ${signingConfig.keyPassword.isNullOrEmpty()}
" 47 | } 48 | 49 | ChecklistTaskResult(taskCode, status, reportMessage) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/ChecklistData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util 18 | 19 | /** 20 | * Contains values used in the project 21 | */ 22 | object ChecklistData { 23 | 24 | const val CHECKLIST_EXTENSION_NAME = "checklist" 25 | 26 | const val CHECKLIST_TASK_PREFIX = "checklist" 27 | 28 | const val CHECKLIST_REPORT_NAME = "$CHECKLIST_TASK_PREFIX-report" 29 | 30 | const val CHECKLIST_TASK_APK2 = "APK2" 31 | 32 | const val CHECKLIST_TASK_B1 = "B1" 33 | const val CHECKLIST_TASK_B2 = "B2" 34 | const val CHECKLIST_TASK_B3 = "B3" 35 | const val CHECKLIST_TASK_B4 = "B4" 36 | const val CHECKLIST_TASK_B5 = "B5" 37 | const val CHECKLIST_TASK_B6 = "B6" 38 | const val CHECKLIST_TASK_B7 = "B7" 39 | const val CHECKLIST_TASK_B8 = "B8" 40 | const val CHECKLIST_TASK_B9 = "B9" 41 | const val CHECKLIST_TASK_B10 = "B10" 42 | 43 | const val CHECKLIST_TASK_DIST2 = "DIST2" 44 | 45 | const val CHECKLIST_TASK_GEN1 = "GEN1" 46 | const val CHECKLIST_TASK_GEN2 = "GEN2" 47 | const val CHECKLIST_TASK_GEN3 = "GEN3" 48 | const val CHECKLIST_TASK_GEN4 = "GEN4" 49 | const val CHECKLIST_TASK_GEN5 = "GEN5" 50 | 51 | const val CHECKLIST_TASK_PRG1 = "PRG1" 52 | const val CHECKLIST_TASK_PRG3 = "PRG3" 53 | const val CHECKLIST_TASK_PRG6 = "PRG6" 54 | 55 | const val CHECKLIST_TASK_PERM2 = "PERM2" 56 | const val CHECKLIST_TASK_PERM3 = "PERM3" 57 | 58 | const val CHECKLIST_TASK_SIGN1 = "SIGN1" 59 | const val CHECKLIST_TASK_SIGN2 = "SIGN2" 60 | const val CHECKLIST_TASK_SIGN3 = "SIGN3" 61 | const val CHECKLIST_TASK_SIGN4 = "SIGN4" 62 | 63 | const val CHECKLIST_TASK_MAN1 = "MAN1" 64 | const val CHECKLIST_TASK_MAN2 = "MAN2" 65 | const val CHECKLIST_TASK_MAN3 = "MAN3" 66 | const val CHECKLIST_TASK_MAN4 = "MAN4" 67 | const val CHECKLIST_TASK_MAN5 = "MAN5" 68 | const val CHECKLIST_TASK_MAN6 = "MAN6" 69 | 70 | const val CHECKLIST_TASK_REPORT = "checklist" 71 | } 72 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/command/AaptHelper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.command 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import org.gradle.api.Project 21 | import java.io.File 22 | 23 | /** 24 | * Helper class for aapt related methods 25 | */ 26 | class AaptHelper(private val commandExecutor: CommandExecutor) { 27 | 28 | /** 29 | * Returns general summary of the apk/aar 30 | * @param project project 31 | * @param apkPath path of the apk 32 | * @return summary of the apk 33 | */ 34 | fun getApkSummary(project: Project, apkPath: String): String { 35 | return commandExecutor.executeCommand( 36 | project, 37 | getAaptPath(project), 38 | "d", 39 | "badging", 40 | apkPath 41 | ) 42 | } 43 | 44 | /** 45 | * Returns permissions of the apk/aar 46 | * @param project project 47 | * @param apkPath path of the apk 48 | * @return permissions 49 | */ 50 | fun getPermissions(project: Project, apkPath: String): String { 51 | return commandExecutor.executeCommand( 52 | project, 53 | getAaptPath(project), 54 | "d", 55 | "permissions", 56 | apkPath 57 | ).replace("\n", "
") 58 | } 59 | 60 | private fun getAaptPath(project: Project): String { 61 | val extension = project.extensions.getByType(BaseExtension::class.java) 62 | return "${extension.sdkDirectory}" + 63 | "${File.separator}build-tools${File.separator}${extension.buildToolsVersion}${File.separator}aapt" 64 | } 65 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/command/ApkAnalyzerHelper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.command 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.commencis.checklist.util.file.XmlParser 21 | import org.gradle.api.Project 22 | import java.io.File 23 | 24 | /** 25 | * Helper class for apkanalyzer related methods 26 | */ 27 | class ApkAnalyzerHelper(private val commandExecutor: CommandExecutor) { 28 | 29 | 30 | /** 31 | * Returns minSDK version from the given apk 32 | * 33 | * @param project project 34 | * @param apkPath path to apk 35 | * @return minSdk version 36 | */ 37 | fun getMinSdkVersion(project: Project, apkPath: String): Int { 38 | val output = commandExecutor.executeCommand( 39 | project, 40 | getApkAnalyzerPath(project), 41 | "manifest", 42 | "min-sdk", 43 | apkPath 44 | ) 45 | return output.trim().toInt() 46 | } 47 | 48 | /** 49 | * Returns targetSDK version from the given apk 50 | * 51 | * @param project project 52 | * @param apkPath path to apk 53 | * @return targetSdk version 54 | */ 55 | fun getTargetSdkVersion(project: Project, apkPath: String): Int { 56 | val output = commandExecutor.executeCommand( 57 | project, 58 | getApkAnalyzerPath(project), 59 | "manifest", 60 | "target-sdk", 61 | apkPath 62 | ) 63 | return output.trim().toInt() 64 | } 65 | 66 | /** 67 | * Returns application id from the given apk 68 | * 69 | * @param project project 70 | * @param apkPath path to apk 71 | * @return appId 72 | */ 73 | fun getApplicationId(project: Project, apkPath: String): String { 74 | val output = commandExecutor.executeCommand( 75 | project, 76 | getApkAnalyzerPath(project), 77 | "manifest", 78 | "application-id", 79 | apkPath 80 | ) 81 | return output.trim() 82 | } 83 | 84 | /** 85 | * Returns if the given apk is debuggable 86 | * 87 | * @param project project 88 | * @param apkPath path to apk 89 | * @return true if apk is debuggable, false otherwise 90 | */ 91 | fun isApkDebuggable(project: Project, apkPath: String): Boolean { 92 | val output = commandExecutor.executeCommand( 93 | project, 94 | getApkAnalyzerPath(project), 95 | "manifest", 96 | "debuggable", 97 | apkPath 98 | ) 99 | return output.trim().toBoolean() 100 | } 101 | 102 | /** 103 | * Returns compileSDK version from the given apk 104 | * 105 | * @param project project 106 | * @param apkPath path to apk 107 | * @return compileSdk version 108 | */ 109 | fun getCompileSdkVersion(project: Project, apkPath: String, xmlParser: XmlParser): Int { 110 | val output = getManifest(project, apkPath) 111 | return xmlParser.findAttributeWithinNode( 112 | output, 113 | "android:compileSdkVersion", 114 | "manifest" 115 | )?.trim()?.toInt() ?: -1 116 | } 117 | 118 | 119 | /** 120 | * Returns Android Manifest of the given apk 121 | * 122 | * @param project project 123 | * @param apkPath path to apk 124 | * @return Manifest 125 | */ 126 | fun getManifest(project: Project, apkPath: String): String { 127 | return commandExecutor.executeCommand( 128 | project, 129 | getApkAnalyzerPath(project), 130 | "manifest", 131 | "print", 132 | apkPath 133 | ) 134 | } 135 | 136 | /** 137 | * Returns version name from the given apk 138 | * 139 | * @param project project 140 | * @param apkPath path to apk 141 | * @return version name 142 | */ 143 | fun getVersionName(project: Project, apkPath: String, xmlParser: XmlParser): String { 144 | val output = getManifest(project, apkPath) 145 | return xmlParser.findAttributeWithinNode( 146 | output, 147 | "android:versionName", 148 | "manifest" 149 | )?.trim() ?: "" 150 | } 151 | 152 | /** 153 | * Returns version code from the given apk 154 | * 155 | * @param project project 156 | * @param apkPath path to apk 157 | * @return version code 158 | */ 159 | fun getVersionCode(project: Project, apkPath: String, xmlParser: XmlParser): Int { 160 | val output = getManifest(project, apkPath) 161 | return xmlParser.findAttributeWithinNode( 162 | output, 163 | "android:versionCode", 164 | "manifest" 165 | )?.trim()?.toInt() ?: -1 166 | } 167 | 168 | /** 169 | * Returns install location value from the given apk 170 | * 171 | * @param project project 172 | * @param apkPath path to apk 173 | * @return install location value 174 | */ 175 | fun getInstallLocation(project: Project, apkPath: String, xmlParser: XmlParser): Int { 176 | val output = getManifest(project, apkPath) 177 | return xmlParser.findAttributeWithinNode( 178 | output, 179 | "android:installLocation", 180 | "application" 181 | )?.trim()?.toInt() ?: -1 182 | } 183 | 184 | /** 185 | * Returns classes inside the given apk 186 | * 187 | * @param project project 188 | * @param apkPath path to apk 189 | * @return classes inside the apk 190 | */ 191 | fun getClasses(project: Project, apkPath: String): String { 192 | return commandExecutor.executeCommand( 193 | project, 194 | getApkAnalyzerPath(project), 195 | "dex", 196 | "packages", 197 | apkPath 198 | ) 199 | } 200 | 201 | /** 202 | * Returns files inside the given apk 203 | * 204 | * @param project project 205 | * @param apkPath path to apk 206 | * @return files inside the apk 207 | */ 208 | fun getFiles(project: Project, apkPath: String): String { 209 | return commandExecutor.executeCommand( 210 | project, 211 | getApkAnalyzerPath(project), 212 | "files", 213 | "list", 214 | apkPath 215 | ) 216 | } 217 | 218 | /** 219 | * Returns output size 220 | * 221 | * @param project project 222 | * @param apkPath path to apk 223 | * @return output size 224 | */ 225 | fun getOutputSize(project: Project, apkPath: String): Int { 226 | return commandExecutor.executeCommand( 227 | project, 228 | getApkAnalyzerPath(project), 229 | "apk", 230 | "file-size", 231 | apkPath 232 | ).trim().toInt() 233 | } 234 | 235 | private fun getApkAnalyzerPath(project: Project) = 236 | "${project.extensions.getByType(BaseExtension::class.java).sdkDirectory}" + 237 | "${File.separator}tools${File.separator}bin${File.separator}apkanalyzer" 238 | 239 | } 240 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/command/CommandExecutor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.command 18 | 19 | import org.gradle.api.Project 20 | import java.io.ByteArrayOutputStream 21 | 22 | /** 23 | * Helper class to execute system commands 24 | */ 25 | class CommandExecutor { 26 | 27 | /** 28 | * Executes given command and returns its output 29 | * 30 | * Given cmd parameter should have the command as its first element 31 | * and options should be another element 32 | * 33 | * @param project project 34 | * @param cmd command to be executed. 35 | */ 36 | fun executeCommand(project: Project, vararg cmd: String): String { 37 | val byteArrayOS = ByteArrayOutputStream() 38 | project.exec { 39 | it.setCommandLine(*cmd) 40 | it.standardOutput = byteArrayOS 41 | } 42 | return byteArrayOS.toString() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/command/GitHelper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.command 18 | 19 | import org.gradle.api.Project 20 | 21 | class GitHelper(private val commandExecutor: CommandExecutor) { 22 | 23 | fun getBranchName(project: Project) : String{ 24 | val output = commandExecutor.executeCommand( 25 | project, 26 | "git", 27 | "rev-parse", 28 | "--abbrev-ref", 29 | "HEAD" 30 | ) 31 | return output.trim() 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/command/GradleHelper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.command 18 | 19 | import org.gradle.api.Project 20 | 21 | /** 22 | * Helper class for gradle related methods 23 | */ 24 | class GradleHelper(private val commandExecutor: CommandExecutor) { 25 | 26 | /** 27 | * Returns dependencies of the given apk 28 | * 29 | * @param project project 30 | * @return dependencies of the apk 31 | */ 32 | fun getApkDependencies(project: Project): String { 33 | return commandExecutor.executeCommand( 34 | project, 35 | "sh", 36 | "-c", 37 | "${project.rootDir}/gradlew :${project.name}:dependencies" 38 | ) 39 | } 40 | 41 | /** 42 | * Returns Google Play dependencies of the given apk 43 | * 44 | * @param project project 45 | * @return Google Play dependencies of the apk 46 | */ 47 | fun getPlayDependencies(project: Project): String { 48 | return commandExecutor.executeCommand( 49 | project, 50 | "sh", 51 | "-c", 52 | "${project.rootDir}/gradlew :${project.name}:dependencies | grep -- \"play-services:\" | cat" 53 | ) 54 | } 55 | 56 | /** 57 | * Executes tests on the project and returns gradle output 58 | * @param project project 59 | * @return empty string if tests passed, error message otherwise 60 | */ 61 | fun runTests(project: Project): String { 62 | return commandExecutor.executeCommand( 63 | project, 64 | "sh", 65 | "-c", 66 | "${project.rootDir}/gradlew -q :${project.name}:test --continue | cat" 67 | ) 68 | } 69 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/file/ChecklistFileHelper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.file 18 | 19 | import java.io.File 20 | import java.nio.file.Paths 21 | 22 | class ChecklistFileHelper { 23 | 24 | fun getFileWithDirectoryAssurance(path: String): File { 25 | val dir = File(Paths.get(path).parent.toUri()) 26 | if (!dir.exists()) dir.mkdirs() 27 | val file = File(path) 28 | file.writeText("") 29 | return file 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/file/XmlParser.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.file 18 | 19 | /** 20 | * Parses files with xml extension and finds fields & values. 21 | */ 22 | interface XmlParser { 23 | 24 | /** 25 | * Find an attribute using with given attribute name. Gets first value if more than one found. 26 | * 27 | * @param xml Xml string to be parsed 28 | * @param attributeName attribute name to be looked 29 | * 30 | * @return attribute found, Otherwise null 31 | */ 32 | fun findAttribute( 33 | xml: String, 34 | attributeName: String 35 | ): T? 36 | 37 | /** 38 | * Find an attribute within the given node using with given attribute name. 39 | * Gets first value if more than one found. 40 | */ 41 | fun findAttributeWithinNode( 42 | xml: String, 43 | attributeName: String, 44 | nodeName: String? 45 | ): T? 46 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/file/XmlParserImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.file 18 | 19 | import groovy.util.XmlSlurper 20 | import groovy.util.slurpersupport.NodeChild 21 | 22 | class XmlParserImpl : XmlParser { 23 | 24 | private val slurper: XmlSlurper by lazy { XmlSlurper() } 25 | 26 | override fun findAttribute(xml: String, attributeName: String): T? { 27 | return findAttributeWithinNode(xml, attributeName, null) 28 | } 29 | 30 | override fun findAttributeWithinNode(xml: String, attributeName: String, nodeName: String?): T? { 31 | slurper.parseText(xml).depthFirst().forEach { 32 | val node = it as? NodeChild 33 | if (node != null && (nodeName == null || node.name() == nodeName)) { 34 | val attributes = node.attributes() 35 | 36 | if (attributes.containsKey(attributeName)) { 37 | return attributes[attributeName] as T 38 | } 39 | } 40 | } 41 | 42 | return null 43 | } 44 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/plugin/android/AndroidBuildType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.plugin.android 18 | 19 | enum class AndroidBuildType(val buildTypeName: String) { 20 | DEBUG("debug"), 21 | RELEASE("release"); 22 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/plugin/android/AndroidPluginHelperImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.plugin.android 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import org.gradle.api.plugins.ExtensionContainer 21 | 22 | class AndroidPluginHelperImpl : IAndroidPluginHelper { 23 | override fun getExtension(extensions: ExtensionContainer): T { 24 | return extensions.getByType(BaseExtension::class.java) as T 25 | } 26 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/plugin/android/AndroidPluginOwner.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.plugin.android 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.android.build.gradle.api.BaseVariant 21 | import org.gradle.api.DomainObjectCollection 22 | import org.gradle.api.Project 23 | 24 | interface AndroidPluginOwner { 25 | 26 | val androidPluginHelper: IAndroidPluginHelper 27 | 28 | /** 29 | * Get android extension. 30 | */ 31 | fun getAndroidExtension(project: Project): BaseExtension = androidPluginHelper.getExtension(project.extensions) 32 | 33 | /** 34 | * Get android build variants. 35 | */ 36 | fun getVariants(project: Project): DomainObjectCollection 37 | 38 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/plugin/android/BuildTypeProviderImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.plugin.android 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import com.android.build.gradle.internal.dsl.BuildType 21 | import org.gradle.api.Project 22 | 23 | class BuildTypeProviderImpl : IBuildTypeProvider { 24 | 25 | override fun getBuildType(project: Project, buildType: AndroidBuildType): BuildType { 26 | return project.extensions.getByType(BaseExtension::class.java).buildTypes.getByName(buildType.buildTypeName) 27 | } 28 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/plugin/android/IAndroidPluginHelper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.plugin.android 18 | 19 | import com.android.build.gradle.BaseExtension 20 | import org.gradle.api.plugins.ExtensionContainer 21 | 22 | interface IAndroidPluginHelper { 23 | 24 | /** 25 | * Gets android extension for project. 26 | * 27 | * @param extensions an extension container for project to search for android extension. 28 | */ 29 | fun getExtension(extensions: ExtensionContainer): T 30 | 31 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/plugin/android/IBuildTypeProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.plugin.android 18 | 19 | import com.android.build.gradle.internal.dsl.BuildType 20 | import org.gradle.api.Project 21 | 22 | interface IBuildTypeProvider { 23 | /** 24 | * Gets a certain build type from base extension. 25 | * 26 | * @param project Project. 27 | * @param buildType Build type that we are looking for. 28 | * 29 | * @return Found build type or throws [org.gradle.api.UnknownDomainObjectException] 30 | */ 31 | fun getBuildType(project: Project, buildType: AndroidBuildType): BuildType 32 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/ProjectInfo.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project 18 | 19 | data class ProjectInfo( 20 | val name: String, 21 | val moduleName: String, 22 | val versionName: String? 23 | ) 24 | -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/ProjectUtil.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project 18 | 19 | import com.commencis.checklist.util.project.resolver.ProjectResolver 20 | import org.gradle.api.plugins.PluginContainer 21 | import org.gradle.api.tasks.TaskContainer 22 | 23 | object ProjectUtil : 24 | ProjectResolver.AndroidProjectResolver { 25 | 26 | override fun isAndroid(pluginContainer: PluginContainer): Boolean { 27 | return isAndroidApplication(pluginContainer) 28 | || isAndroidLibrary(pluginContainer) 29 | || isAndroidFeature(pluginContainer) 30 | } 31 | 32 | override fun isAndroidApplication(pluginContainer: PluginContainer): Boolean { 33 | return pluginContainer.hasPlugin("com.android.application") 34 | } 35 | 36 | override fun isAndroidLibrary(pluginContainer: PluginContainer): Boolean { 37 | return pluginContainer.hasPlugin("com.android.library") 38 | } 39 | 40 | override fun isAndroidFeature(pluginContainer: PluginContainer): Boolean { 41 | return pluginContainer.hasPlugin("com.android.feature") 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/resolver/IProjectResolverProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project.resolver 18 | 19 | interface IProjectResolverProvider { 20 | val androidProjectResolver: ProjectResolver.AndroidProjectResolver 21 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/resolver/ProjectResolver.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project.resolver 18 | 19 | import org.gradle.api.plugins.PluginContainer 20 | import org.gradle.api.tasks.TaskContainer 21 | 22 | interface ProjectResolver { 23 | 24 | interface AndroidProjectResolver { 25 | 26 | /** 27 | * Determines if project is an android project. 28 | */ 29 | fun isAndroid(pluginContainer: PluginContainer): Boolean 30 | 31 | /** 32 | * Determines if project is android application. 33 | * 34 | * @return true if android application, Otherwise false. 35 | */ 36 | fun isAndroidApplication(pluginContainer: PluginContainer): Boolean 37 | 38 | /** 39 | * Determines if project is android library. 40 | * 41 | * @return true if android library, Otherwise false. 42 | */ 43 | fun isAndroidLibrary(pluginContainer: PluginContainer): Boolean 44 | 45 | /** 46 | * Determines if project is android feature. 47 | * 48 | * @return true if android feature, Otherwise false. 49 | */ 50 | fun isAndroidFeature(pluginContainer: PluginContainer): Boolean 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/resolver/ProjectResolverProviderImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project.resolver 18 | 19 | import com.commencis.checklist.util.project.ProjectUtil 20 | 21 | class ProjectResolverProviderImpl : IProjectResolverProvider { 22 | override val androidProjectResolver: ProjectResolver.AndroidProjectResolver 23 | get() = ProjectUtil 24 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/type/IProjectTypeProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project.type 18 | 19 | import com.commencis.checklist.util.project.resolver.IProjectResolverProvider 20 | import org.gradle.api.Project 21 | 22 | interface IProjectTypeProvider { 23 | val projectResolverProvider: IProjectResolverProvider 24 | 25 | fun getProjectType(project: Project) : ProjectType 26 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/type/ProjectType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project.type 18 | 19 | enum class ProjectType { 20 | APPLICATION, 21 | LIBRARY, 22 | FEATURE 23 | } -------------------------------------------------------------------------------- /android-checklist/src/main/kotlin/com/commencis/checklist/util/project/type/ProjectTypeProviderImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist.util.project.type 18 | 19 | import com.commencis.checklist.util.project.resolver.IProjectResolverProvider 20 | import com.commencis.checklist.util.project.resolver.ProjectResolverProviderImpl 21 | import org.gradle.api.Project 22 | 23 | class ProjectTypeProviderImpl : IProjectTypeProvider { 24 | override val projectResolverProvider: IProjectResolverProvider 25 | get() = ProjectResolverProviderImpl() 26 | 27 | override fun getProjectType(project: Project): ProjectType { 28 | return when { 29 | projectResolverProvider.androidProjectResolver.isAndroidApplication(project.plugins) -> 30 | ProjectType.APPLICATION 31 | projectResolverProvider.androidProjectResolver.isAndroidLibrary(project.plugins) -> 32 | ProjectType.LIBRARY 33 | projectResolverProvider.androidProjectResolver.isAndroidFeature(project.plugins) -> 34 | ProjectType.FEATURE 35 | else -> 36 | ProjectType.APPLICATION 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /android-checklist/src/test/kotlin/com/commencis/checklist/ChecklistBasePluginTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.checklist 18 | 19 | import com.commencis.checklist.util.project.type.IProjectTypeProvider 20 | import com.commencis.checklist.util.project.type.ProjectType 21 | import com.commencis.testUtils.getActionField 22 | import com.google.gson.reflect.TypeToken 23 | import com.nhaarman.mockitokotlin2.any 24 | import com.nhaarman.mockitokotlin2.mock 25 | import com.nhaarman.mockitokotlin2.verify 26 | import com.nhaarman.mockitokotlin2.whenever 27 | import org.assertj.core.api.Assertions.assertThat 28 | import org.gradle.api.Action 29 | import org.gradle.api.Project 30 | import org.gradle.api.plugins.ObjectConfigurationAction 31 | import org.junit.jupiter.api.BeforeEach 32 | import org.junit.jupiter.api.Test 33 | import org.mockito.ArgumentCaptor 34 | import org.mockito.Mock 35 | import org.mockito.MockitoAnnotations.initMocks 36 | 37 | class ChecklistBasePluginTest { 38 | 39 | @Mock 40 | private lateinit var mockProjectTypeProvider: IProjectTypeProvider 41 | 42 | private lateinit var checklistBasePlugin: ChecklistBasePlugin 43 | 44 | @BeforeEach 45 | fun init() { 46 | initMocks(this) 47 | checklistBasePlugin = ChecklistBasePlugin(mockProjectTypeProvider) 48 | } 49 | 50 | @Test 51 | fun `When ChecklistBasePlugin applied to an Application Project, it should apply ApplicationChecklistPlugin`() { 52 | val project: Project = mock() 53 | whenever(mockProjectTypeProvider.getProjectType(any())).thenReturn(ProjectType.APPLICATION) 54 | val action = getAction(project) 55 | assertThat(action).isEqualTo(ApplicationChecklistPlugin::class.java) 56 | } 57 | 58 | @Test 59 | fun `When ChecklistBasePlugin applied to an Library Project, it should apply LibraryChecklistPlugin`() { 60 | val project: Project = mock() 61 | whenever(mockProjectTypeProvider.getProjectType(any())).thenReturn(ProjectType.LIBRARY) 62 | val action = getAction(project) 63 | assertThat(action).isEqualTo(LibraryChecklistPlugin::class.java) 64 | } 65 | 66 | @Test 67 | fun `When ChecklistBasePlugin applied to an Feature Project, it should apply FeatureChecklistPlugin`() { 68 | val project: Project = mock() 69 | whenever(mockProjectTypeProvider.getProjectType(any())).thenReturn(ProjectType.FEATURE) 70 | val action = getAction(project) 71 | assertThat(action).isEqualTo(FeatureChecklistPlugin::class.java) 72 | } 73 | 74 | private fun getAction(project: Project): Any{ 75 | checklistBasePlugin.apply(project) 76 | val clazz = object : TypeToken>() {}.rawType!! as Class> 77 | val argumentCaptor: ArgumentCaptor> = ArgumentCaptor.forClass(clazz) 78 | verify(project).apply(argumentCaptor.capture()) 79 | return getActionField("\$clazz", argumentCaptor) 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /android-checklist/src/test/kotlin/com/commencis/testUtils/ActionUtil.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.commencis.testUtils 18 | 19 | import org.mockito.ArgumentCaptor 20 | 21 | fun getActionField(fieldName: String, argumentCaptor: ArgumentCaptor): Any { 22 | val field = argumentCaptor.value.javaClass.getDeclaredField(fieldName) 23 | field.isAccessible = true 24 | val fieldObject = field.get(argumentCaptor.value) 25 | field.isAccessible = false 26 | return fieldObject 27 | } -------------------------------------------------------------------------------- /android-checklist/testing.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply from: "integration-test.gradle" 18 | apply from: "functional-test.gradle" 19 | 20 | test { 21 | useJUnitPlatform() 22 | failFast = true 23 | } 24 | 25 | def assertjVersion = "3.11.1" 26 | def jUnitVersion = "5.3.0" 27 | def mockitoKotlinVersion = "2.2.0" 28 | def androidGradlePluginVersion = "3.3.0" 29 | 30 | dependencies { 31 | testImplementation "com.android.tools.build:gradle:$androidGradlePluginVersion" 32 | testImplementation "org.junit.jupiter:junit-jupiter-api:$jUnitVersion" 33 | testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jUnitVersion" 34 | testImplementation "org.junit.jupiter:junit-jupiter-params:$jUnitVersion" 35 | testImplementation "org.assertj:assertj-core:$assertjVersion" 36 | testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion" 37 | testImplementation "org.jetbrains.kotlin:kotlin-reflect" 38 | 39 | testImplementation gradleTestKit() 40 | } 41 | 42 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | buildscript { 18 | ext.kotlin_version = '1.3.21' 19 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Commencis/Android-Checklist-Plugin/e2d1ff5a18aaf1f59af93b63cc848800a8b21402/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Commencis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | include ':android-checklist' --------------------------------------------------------------------------------