├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── canidropjetifier ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ └── com.github.plnice │ └── canidropjetifier │ ├── AllOpen.kt │ ├── BlamedDependency.kt │ ├── CanIDropJetifierPlugin.kt │ ├── CanIDropJetifierReporter.kt │ └── CanIDropJetifierTask.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample-dependency ├── build.gradle.kts ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── canidropjetifier │ │ └── sample_dependency │ │ └── ExampleInstrumentedTest.kt │ ├── main │ └── AndroidManifest.xml │ └── test │ └── java │ └── com │ └── example │ └── canidropjetifier │ └── sample_dependency │ └── ExampleUnitTest.kt ├── sample ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── canidropjetifier │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── canidropjetifier │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── canidropjetifier │ └── ExampleUnitTest.kt └── settings.gradle.kts /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | 67 | .idea/ 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | | :exclamation: Deprecated | 2 | |---------------------------| 3 | | This plugin is deprecated and no new versions will be provided. For checking if Jetifier can be disabled, you can switch to `checkJetifier` task provided by the Android Gradle Plugin 7.1+. | 4 | 5 | # Can I drop Jetifier? 6 | 7 | Checks whether there are any dependencies using support library instead of AndroidX artifacts. 8 | 9 | If you migrated to AndroidX, you probably have the Jetifier tool enabled that converts dependencies that still depend on old artifacts to operate on AndroidX classes. Since more and more libraries are migrated to AndroidX, at some point there will be no need to have this tool enabled. This plugin can be used to identify which of the libraries you are using need to be migrated to AndroidX or bumped if the new version is already there. 10 | 11 | ## Setup 12 | 13 | Build script snippet for plugins DSL for Gradle 2.1 and later: 14 | 15 | ``` groovy 16 | plugins { 17 | id "com.github.plnice.canidropjetifier" version "0.5" 18 | } 19 | ``` 20 | 21 | Build script snippet for use in older Gradle versions or where dynamic configuration is required: 22 | 23 | ``` groovy 24 | buildscript { 25 | repositories { 26 | gradlePluginPortal() 27 | } 28 | dependencies { 29 | classpath "com.github.plnice:canidropjetifier:0.5" 30 | } 31 | } 32 | 33 | apply plugin: "com.github.plnice.canidropjetifier" 34 | ``` 35 | 36 | For multi-module projects, you can apply the plugin in the top-level `build.gradle` file. It will analyze all the modules found in the project. 37 | 38 | ## Usage 39 | 40 | The Jetifier tool must be temporarily disabled to make this plugin work correctly. It can be done when calling the plugin's task: 41 | 42 | ``` bash 43 | ./gradlew -Pandroid.enableJetifier=false canIDropJetifier 44 | ``` 45 | 46 | Example output: 47 | 48 | ``` bash 49 | ======================================== 50 | Project sample 51 | ======================================== 52 | 53 | Cannot drop Jetifier due to following module dependencies: 54 | 55 | * sample-dependency (module) 56 | \-- com.android.support:cardview-v7:28.0.0 57 | \-- com.squareup.leakcanary:leakcanary-android:1.6.3 58 | \-- com.android.support:support-core-utils:26.0.0 59 | \-- com.squareup.leakcanary:leakcanary-android:1.6.3 60 | \-- com.squareup.leakcanary:leakcanary-analyzer:1.6.3 61 | \-- com.android.support:support-annotations:28.0.0 62 | 63 | Cannot drop Jetifier due to following external dependencies: 64 | 65 | * com.android.support:cardview-v7:28.0.0 66 | 67 | * com.squareup.leakcanary:leakcanary-android:1.6.3 68 | \-- com.squareup.leakcanary:leakcanary-analyzer:1.6.3 69 | \-- com.android.support:support-annotations:28.0.0 70 | \-- com.android.support:support-core-utils:26.0.0 71 | ``` 72 | 73 | ## Configuration 74 | 75 | ``` groovy 76 | canIDropJetifier { 77 | verbose = true // Default: false, set to true to print the dependencies tree down to the old artifact 78 | includeModules = false // Default: true, print out not only external (library) dependencies, but also module dependencies that use old artifacts 79 | analyzeOnlyAndroidModules = false // Default: true, analyze only modules that use com.android.application or com.android.library plugins 80 | configurationRegex = ".*RuntimeClasspath" // Performance optimization: checks only configurations that match provided regex 81 | parallelMode = true // Default: false, experimental: run analysis of modules in parallel 82 | parallelModePoolSize = 4 // Default: max available processors - 1, experimental: pool size for analysis in parallel 83 | } 84 | ``` 85 | 86 | ## License 87 | 88 | ``` 89 | Copyright 2019 Miłosz Lewandowski 90 | 91 | Licensed under the Apache License, Version 2.0 (the "License"); 92 | you may not use this file except in compliance with the License. 93 | You may obtain a copy of the License at 94 | 95 | http://www.apache.org/licenses/LICENSE-2.0 96 | 97 | Unless required by applicable law or agreed to in writing, software 98 | distributed under the License is distributed on an "AS IS" BASIS, 99 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 100 | See the License for the specific language governing permissions and 101 | limitations under the License. 102 | ``` 103 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | 6 | } 7 | dependencies { 8 | classpath("com.android.tools.build:gradle:3.5.0") 9 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50") 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | google() 16 | jcenter() 17 | } 18 | } 19 | 20 | tasks.register("clean", Delete::class) { 21 | delete(rootProject.buildDir) 22 | } 23 | -------------------------------------------------------------------------------- /canidropjetifier/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | `maven-publish` 4 | id("org.jetbrains.kotlin.plugin.allopen") version "1.3.50" 5 | id("com.gradle.plugin-publish") version "0.10.1" 6 | } 7 | 8 | gradlePlugin { 9 | plugins { 10 | register("canidropjetifier") { 11 | id = "com.github.plnice.canidropjetifier" 12 | displayName = "Can I drop Jetifier?" 13 | description = "Checks whether there are any dependencies using support library instead of AndroidX artifacts." 14 | implementationClass = "com.github.plnice.canidropjetifier.CanIDropJetifierPlugin" 15 | } 16 | } 17 | } 18 | 19 | allOpen { 20 | annotation("com.github.plnice.canidropjetifier.AllOpen") 21 | } 22 | 23 | repositories { 24 | jcenter() 25 | } 26 | 27 | group = "com.github.plnice" 28 | version = "0.5" 29 | 30 | publishing { 31 | repositories { 32 | maven(url = "build/repository") 33 | } 34 | } 35 | 36 | pluginBundle { 37 | website = "https://github.com/plnice/can-i-drop-jetifier" 38 | vcsUrl = "https://github.com/plnice/can-i-drop-jetifier" 39 | tags = listOf("android", "jetifier") 40 | } 41 | -------------------------------------------------------------------------------- /canidropjetifier/settings.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/canidropjetifier/settings.gradle.kts -------------------------------------------------------------------------------- /canidropjetifier/src/main/kotlin/com.github.plnice/canidropjetifier/AllOpen.kt: -------------------------------------------------------------------------------- 1 | package com.github.plnice.canidropjetifier 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.Plugin 5 | 6 | annotation class AllOpen 7 | 8 | @AllOpen 9 | abstract class AllOpenTask : DefaultTask() 10 | 11 | @AllOpen 12 | interface AllOpenPlugin : Plugin 13 | -------------------------------------------------------------------------------- /canidropjetifier/src/main/kotlin/com.github.plnice/canidropjetifier/BlamedDependency.kt: -------------------------------------------------------------------------------- 1 | package com.github.plnice.canidropjetifier 2 | 3 | sealed class BlamedDependency { 4 | data class FirstLevelDependency(val dependency: Dependency) : BlamedDependency() 5 | data class ChildDependency(val parents: List, val dependency: Dependency) : BlamedDependency() 6 | } 7 | 8 | sealed class Dependency(open val name: String) { 9 | data class Module(override val name: String) : Dependency(name) 10 | data class External(override val name: String) : Dependency(name) 11 | } 12 | -------------------------------------------------------------------------------- /canidropjetifier/src/main/kotlin/com.github.plnice/canidropjetifier/CanIDropJetifierPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.github.plnice.canidropjetifier 2 | 3 | import org.gradle.api.Action 4 | import org.gradle.api.Project 5 | 6 | import org.gradle.kotlin.dsl.* 7 | 8 | open class CanIDropJetifierPluginExtension { 9 | var verbose: Boolean = false 10 | var includeModules: Boolean = true 11 | var analyzeOnlyAndroidModules: Boolean = true 12 | var configurationRegex: String = ".*RuntimeClasspath" 13 | var parallelMode: Boolean = false 14 | var parallelModePoolSize: Int? = null 15 | } 16 | 17 | class CanIDropJetifierPlugin : AllOpenPlugin { 18 | 19 | override fun apply(project: Project): Unit = project.run { 20 | val extension = extensions.create("canIDropJetifier") 21 | tasks { 22 | register("canIDropJetifier", CanIDropJetifierTask::class, Action { 23 | verbose = extension.verbose 24 | includeModules = extension.includeModules 25 | analyzeOnlyAndroidModules = extension.analyzeOnlyAndroidModules 26 | configurationRegex = extension.configurationRegex 27 | parallelMode = extension.parallelMode 28 | parallelModePoolSize = extension.parallelModePoolSize 29 | }) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /canidropjetifier/src/main/kotlin/com.github.plnice/canidropjetifier/CanIDropJetifierReporter.kt: -------------------------------------------------------------------------------- 1 | package com.github.plnice.canidropjetifier 2 | 3 | import org.gradle.api.Project 4 | 5 | import com.github.plnice.canidropjetifier.BlamedDependency.ChildDependency 6 | import com.github.plnice.canidropjetifier.BlamedDependency.FirstLevelDependency 7 | import kotlin.math.max 8 | 9 | interface CanIDropJetifierReporter { 10 | val verbose: Boolean 11 | val includeModules: Boolean 12 | fun report(project: Project, blamedDependencies: List) 13 | } 14 | 15 | class TextCanIDropJetifierReporter( 16 | override val verbose: Boolean, 17 | override val includeModules: Boolean 18 | ) : CanIDropJetifierReporter { 19 | 20 | override fun report(project: Project, blamedDependencies: List) { 21 | println("=".repeat(max(40, 8 + project.name.length))) 22 | println("Project ${project.name}") 23 | println("=".repeat(max(40, 8 + project.name.length))) 24 | println("") 25 | 26 | when (blamedDependencies.size) { 27 | 0 -> { 28 | println("No dependencies on old artifacts! Safe to drop Jetifier.") 29 | println("") 30 | } 31 | else -> { 32 | val moduleDependencies = blamedDependencies 33 | .filterIsInstance() 34 | .groupBy { it.parents.first() } 35 | .filter { (parent, _) -> parent is Dependency.Module } 36 | 37 | val firstLevelDependencies = blamedDependencies 38 | .filterIsInstance() 39 | 40 | val externalDependencies = blamedDependencies 41 | .filterIsInstance() 42 | .groupBy { it.parents.first() } 43 | .filter { (parent, _) -> parent is Dependency.External } 44 | 45 | if (includeModules && moduleDependencies.isNotEmpty()) { 46 | println("Cannot drop Jetifier due to following module dependencies:") 47 | println("") 48 | 49 | moduleDependencies.forEach { it.print() } 50 | } 51 | 52 | if (firstLevelDependencies.isNotEmpty() || externalDependencies.isNotEmpty()) { 53 | println("Cannot drop Jetifier due to following external dependencies:") 54 | println("") 55 | 56 | firstLevelDependencies.forEach { it.print() } 57 | externalDependencies.forEach { it.print() } 58 | } 59 | } 60 | } 61 | } 62 | 63 | private fun FirstLevelDependency.print() { 64 | println("* ${dependency.name}") 65 | println("") 66 | } 67 | 68 | private fun Map.Entry>.print() { 69 | val (parent, dependencies) = this 70 | println("* ${parent.name}") 71 | if (verbose) { 72 | dependencies.forEach { 73 | val parentsWithoutFirst = it.parents.subList(1, it.parents.size) 74 | parentsWithoutFirst.forEachIndexed { index: Int, parent: Dependency -> 75 | println(" ".repeat(index + 2) + "\\-- ${parent.name}") 76 | } 77 | println(" ".repeat(parentsWithoutFirst.size + 2) + "\\-- ${it.dependency.name}") 78 | } 79 | } 80 | println("") 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /canidropjetifier/src/main/kotlin/com.github.plnice/canidropjetifier/CanIDropJetifierTask.kt: -------------------------------------------------------------------------------- 1 | package com.github.plnice.canidropjetifier 2 | 3 | import org.gradle.api.artifacts.Configuration 4 | import org.gradle.api.artifacts.ResolvedDependency 5 | import org.gradle.api.tasks.TaskAction 6 | 7 | import com.github.plnice.canidropjetifier.BlamedDependency.ChildDependency 8 | import com.github.plnice.canidropjetifier.BlamedDependency.FirstLevelDependency 9 | import org.gradle.api.GradleException 10 | import org.gradle.api.Project 11 | import java.util.* 12 | import java.util.concurrent.ForkJoinPool 13 | import java.util.function.Consumer 14 | 15 | class CanIDropJetifierTask : AllOpenTask() { 16 | 17 | companion object { 18 | private val OLD_MODULES_PREFIXES = listOf("android.arch", "com.android.support") 19 | } 20 | 21 | var verbose: Boolean = false 22 | var includeModules: Boolean = true 23 | var analyzeOnlyAndroidModules = true 24 | lateinit var configurationRegex: String 25 | var parallelMode = false 26 | var parallelModePoolSize: Int? = null 27 | 28 | private val reporter by lazy { TextCanIDropJetifierReporter(verbose, includeModules) } 29 | 30 | init { 31 | description = "Checks whether there are any dependencies using support library instead of AndroidX artifacts." 32 | group = "Help" 33 | 34 | outputs.upToDateWhen { false } 35 | } 36 | 37 | @TaskAction 38 | fun canIDropJetifier() { 39 | if (project.property("android.enableJetifier") == "true") { 40 | throw GradleException( 41 | "To work correctly, this task needs to be run with Jetifier turned off:" + 42 | " ./gradlew -Pandroid.enableJetifier=false canIDropJetifier" 43 | ) 44 | } else { 45 | val subprojectsToAnalyze = project.allprojects.filter { it.shouldAnalyze() } 46 | when { 47 | parallelMode -> subprojectsToAnalyze.analyzeInParallel() 48 | else -> subprojectsToAnalyze.forEach { it.doAnalyze() } 49 | } 50 | } 51 | } 52 | 53 | private fun List.analyzeInParallel() { 54 | ForkJoinPool(parallelModePoolSize ?: (Runtime.getRuntime().availableProcessors() - 1)).submit(Runnable { 55 | parallelStream().forEach(Consumer { subproject -> 56 | subproject.doAnalyze() 57 | }) 58 | }).get() 59 | } 60 | 61 | private fun Project.doAnalyze() { 62 | configurations 63 | .filter { it.shouldAnalyze() } 64 | .map { it.getBlamedDependencies() } 65 | .flatten() 66 | .distinct() 67 | .let { 68 | reporter.report(this, it) 69 | } 70 | } 71 | 72 | private fun Project.shouldAnalyze(): Boolean = with(project.plugins) { 73 | return if (analyzeOnlyAndroidModules) { 74 | hasPlugin("com.android.application") || hasPlugin("com.android.library") 75 | } else true 76 | } 77 | 78 | private fun Configuration.shouldAnalyze(): Boolean { 79 | return configurationRegex.toRegex() matches name 80 | } 81 | 82 | private fun Configuration.getBlamedDependencies(): Iterable { 83 | val blamedDependencies = mutableSetOf() 84 | try { 85 | if (isCanBeResolved) { 86 | resolvedConfiguration 87 | .firstLevelModuleDependencies 88 | .forEach { firstLevelDependency -> 89 | if (firstLevelDependency.isOldArtifact()) { 90 | blamedDependencies.add(FirstLevelDependency(firstLevelDependency.toDependency())) 91 | } else { 92 | blamedDependencies.traverseAndAddChildren(firstLevelDependency) 93 | } 94 | } 95 | } 96 | } catch (ignored: Throwable) { 97 | } 98 | return blamedDependencies 99 | } 100 | 101 | private data class QueueElement(val parents: List, val children: Iterable) 102 | 103 | private fun MutableSet.traverseAndAddChildren(firstLevelDependency: ResolvedDependency) { 104 | val queue: Queue = LinkedList() 105 | 106 | queue.offer(QueueElement(listOf(firstLevelDependency.toDependency()), firstLevelDependency.children)) 107 | 108 | while (queue.isNotEmpty()) { 109 | val (parents, children) = queue.poll() 110 | children.forEach { child -> 111 | if (child.isOldArtifact()) { 112 | add(ChildDependency(dependency = child.toDependency(), parents = parents)) 113 | } else { 114 | queue.offer(QueueElement(parents + child.toDependency(), child.children)) 115 | } 116 | } 117 | } 118 | } 119 | 120 | private fun ResolvedDependency.isOldArtifact(): Boolean { 121 | return OLD_MODULES_PREFIXES.any { moduleGroup.startsWith(it) } 122 | } 123 | 124 | private fun ResolvedDependency.toDependency() = when { 125 | configuration.endsWith("RuntimeElements") && moduleGroup == project.rootProject.name -> 126 | Dependency.Module("$moduleName (module)") 127 | else -> Dependency.External(name) 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/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-5.6.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /sample-dependency/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.library") 3 | kotlin("android") 4 | kotlin("android.extensions") 5 | } 6 | 7 | android { 8 | compileSdkVersion(28) 9 | defaultConfig { 10 | minSdkVersion(21) 11 | targetSdkVersion(28) 12 | versionCode = 1 13 | versionName = "1.0" 14 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | getByName("release") { 18 | isMinifyEnabled = false 19 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation(fileTree("libs").matching { include("*.jar") }) 26 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50") 27 | implementation("androidx.appcompat:appcompat:1.0.2") 28 | implementation("androidx.core:core-ktx:1.0.1") 29 | implementation("androidx.constraintlayout:constraintlayout:1.1.3") 30 | testImplementation("junit:junit:4.12") 31 | androidTestImplementation("androidx.test:runner:1.1.1") 32 | androidTestImplementation("androidx.test.espresso:espresso-core:3.1.1") 33 | 34 | // Example obsolete dependencies 35 | implementation("com.squareup.leakcanary:leakcanary-android:1.6.3") 36 | implementation("com.android.support:cardview-v7:28.0.0") 37 | } 38 | -------------------------------------------------------------------------------- /sample-dependency/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /sample-dependency/src/androidTest/java/com/example/canidropjetifier/sample_dependency/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.canidropjetifier.sample_dependency 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.example.canidropjetifier.sample_dependency.test", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sample-dependency/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /sample-dependency/src/test/java/com/example/canidropjetifier/sample_dependency/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.canidropjetifier.sample_dependency 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | kotlin("android") 4 | kotlin("android.extensions") 5 | 6 | id("com.github.plnice.canidropjetifier") version "0.5" 7 | } 8 | 9 | android { 10 | compileSdkVersion(28) 11 | defaultConfig { 12 | applicationId = "com.example.canidropjetifier" 13 | minSdkVersion(21) 14 | targetSdkVersion(28) 15 | versionCode = 1 16 | versionName = "1.0" 17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | buildTypes { 20 | getByName("release") { 21 | isMinifyEnabled = false 22 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation(fileTree("libs").matching { include("*.jar") }) 29 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50") 30 | implementation("androidx.appcompat:appcompat:1.0.2") 31 | implementation("androidx.core:core-ktx:1.0.1") 32 | implementation("androidx.constraintlayout:constraintlayout:1.1.3") 33 | testImplementation("junit:junit:4.12") 34 | androidTestImplementation("androidx.test:runner:1.1.1") 35 | androidTestImplementation("androidx.test.espresso:espresso-core:3.1.1") 36 | 37 | // Example obsolete dependencies 38 | implementation("com.squareup.leakcanary:leakcanary-android:1.6.3") 39 | implementation("com.android.support:cardview-v7:28.0.0") 40 | 41 | // Dependency on module which uses obsolete dependencies 42 | api(project(":sample-dependency")) 43 | } 44 | 45 | canIDropJetifier { 46 | verbose = true 47 | parallelMode = true 48 | } 49 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/example/canidropjetifier/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.canidropjetifier 2 | 3 | import androidx.test.InstrumentationRegistry 4 | import androidx.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.example.canidropjetifier", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sample/src/main/java/com/example/canidropjetifier/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.canidropjetifier 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | 6 | class MainActivity : AppCompatActivity() { 7 | 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_main) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plnice/can-i-drop-jetifier/0489a6f797097a576aa76afe3950cd4158c35040/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Can I Drop Jetifier? 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/test/java/com/example/canidropjetifier/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.canidropjetifier 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | include(":canidropjetifier", ":sample", ":sample-dependency") 2 | 3 | pluginManagement { 4 | repositories { 5 | maven { url = uri("canidropjetifier/build/repository") } 6 | gradlePluginPortal() 7 | } 8 | } 9 | --------------------------------------------------------------------------------