diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b09549..59fbc77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,10 @@ Items listed here may not be exhaustive, if you are seeing issues, check the git ## 1.0.0-rc06 - Print output for `adb install` commands. #59 thanks [@plastiv](https://github.com/plastiv). -- Update gradle and AGP to latest stable. `6.2.1` & `3.6.1` respectively. +- Update Gradle, AGP, and Kotlin to latest stable versions. `6.3`,`3.6.2`,`1.3.71` respectively. - Process: Github actions for verification. #36 again, thank you [@plastiv](https://github.com/plastiv). -- Feature: Dynamic-Feature module support -- Feature: Test module support "com.android.test". #71 thanks [@dkostyrev](https://github.com/dkostyrev). +- Incubating Feature: Dynamic-Feature module support. See issue #63 for more details. +- Feature: Test module support `com.android.test`. #71 thanks [@dkostyrev](https://github.com/dkostyrev). ## 1.0.0-rc05 - Catch a specific subset of errors allowing clean disposal of underlying processes. (logcat and instrumentation) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..55a8c25 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,20 @@ +import java.util.Properties + +plugins { + `kotlin-dsl` + `java-gradle-plugin` +} + +repositories { + jcenter() + google() +} + +gradlePlugin { + plugins { + create("adb-uninstall") { + id = "com.trevjonez.adb-uninstall" + implementationClass = "com.trevjonez.AdbUninstallPlugin" + } + } +} diff --git a/buildSrc/src/main/kotlin/com/trevjonez/AdbUninstallPlugin.kt b/buildSrc/src/main/kotlin/com/trevjonez/AdbUninstallPlugin.kt new file mode 100644 index 0000000..00cd6c4 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/trevjonez/AdbUninstallPlugin.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Trevor Jones + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.trevjonez + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.provider.SetProperty +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.register + +abstract class AdbUninstallPlugin: Plugin { + + override fun apply(target: Project) { + val extension = target.extensions.create("adbUninstall") + + val lifecycleTask = target.tasks.register("adbUninstallAll") { + description = "Run all adb uninstall tasks" + group = "Adb Uninstall" + } + + target.afterEvaluate { + extension.packageNames.orNull.orEmpty().forEachIndexed { index, pkgName -> + val nameSuffix = pkgName.split('.') + .joinToString(separator = "") { it.capitalize() } + + val uninstall = tasks.register("adbUninstall$nameSuffix") { + packageName.set(pkgName) + description = "Uninstall '$pkgName'" + group = "Adb Uninstall" + } + + lifecycleTask.configure { + dependsOn(uninstall) + } + } + } + } +} + +abstract class AdbUninstallExtension { + abstract val packageNames: SetProperty +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/trevjonez/RemoveApkTask.kt b/buildSrc/src/main/kotlin/com/trevjonez/RemoveApkTask.kt new file mode 100644 index 0000000..03fbb43 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/trevjonez/RemoveApkTask.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2020 Trevor Jones + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.trevjonez + +import org.gradle.api.provider.Property +import org.gradle.api.tasks.AbstractExecTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Optional +import java.io.File + +abstract class RemoveApkTask : AbstractExecTask(RemoveApkTask::class.java) { + + @get:Input + abstract val packageName: Property + + @get:[Input Optional] + abstract val adbPath: Property + + private val androidHome by lazy { + requireNotNull(System.getenv("ANDROID_HOME")) + } + + private val adb by lazy { + "$androidHome${File.separator}platform-tools${File.separator}adb" + } + + override fun exec() { + isIgnoreExitValue = true + commandLine( + adbPath.orNull ?: adb, + "shell", "pm", "uninstall", + packageName.get() + ) + super.exec() + } +} \ No newline at end of file diff --git a/commander/android/build.gradle b/commander/android/build.gradle index 327816b..fe9389c 100644 --- a/commander/android/build.gradle +++ b/commander/android/build.gradle @@ -1,5 +1,6 @@ apply plugin: "org.jetbrains.kotlin.jvm" apply from: "$rootProject.projectDir/publish.gradle" +apply plugin: "com.trevjonez.adb-uninstall" ext.artifactId = "commander-android" description = "Functions to work with Android SDK Tools like adb, avdmanager, sdkmanager." @@ -14,6 +15,10 @@ dependencies { testRuntimeOnly "org.jetbrains.kotlin:kotlin-reflect" } +adbUninstall { + packageNames.add("com.trevjonez.commander.testsupport") +} + test { useJUnitPlatform { includeEngines 'spek2' diff --git a/gradle.properties b/gradle.properties index 0b00017..f4ae112 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,14 +18,14 @@ group=com.trevjonez.composer CGP_VERSION=1.0.0-rc06 -AGP_VERSION=3.6.1 -#AGP_VERSION=4.0.0-beta01 -#AGP_VERSION=4.1.0-alpha01 +AGP_VERSION=3.6.2 +#AGP_VERSION=4.0.0-beta04 +#AGP_VERSION=4.1.0-alpha05 MIN_SDK=23 COMPILE_SDK=29 -KOTLIN_VERSION=1.3.61 +KOTLIN_VERSION=1.3.71 org.gradle.caching=true org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f3d88b1..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3870775..6623300 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Feb 28 23:27:29 MST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/plugin/build.gradle b/plugin/build.gradle index 0c86c9b..d652a5a 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -2,120 +2,137 @@ apply plugin: "java-gradle-plugin" apply plugin: "org.jetbrains.kotlin.jvm" apply plugin: "maven-publish" apply plugin: "com.gradle.plugin-publish" +apply plugin: "com.trevjonez.adb-uninstall" ext.artifactId = "plugin" gradlePlugin { - plugins { - create("composer") { - displayName = "com.trevjonez.composer" - description = "Gradle task type and plugin for interacting with https://github.com/gojuno/composer" - id = "com.trevjonez.composer" - implementationClass = "com.trevjonez.composer.ComposerPlugin" + plugins { + create("composer") { + displayName = "com.trevjonez.composer" + description = "Gradle task type and plugin for interacting with https://github.com/gojuno/composer" + id = "com.trevjonez.composer" + implementationClass = "com.trevjonez.composer.ComposerPlugin" + } } - } } pluginBundle { - website = "https://github.com/trevjonez/composer-gradle-plugin" - vcsUrl = "https://github.com/trevjonez/composer-gradle-plugin.git" - tags = ["android", "composer", "test", "orchestrator", "report"] + website = "https://github.com/trevjonez/composer-gradle-plugin" + vcsUrl = "https://github.com/trevjonez/composer-gradle-plugin.git" + tags = ["android", "composer", "test", "orchestrator", "report"] } dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - api("com.android.tools.build:gradle:$AGP_VERSION") - api(gradleApi()) - - testImplementation(gradleTestKit()) - testImplementation("junit:junit:4.12") - testImplementation("org.assertj:assertj-core:3.5.2") - testImplementation("commons-io:commons-io:2.5") - testImplementation("org.jetbrains.kotlin:kotlin-reflect") + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + api("com.android.tools.build:gradle:$AGP_VERSION") + api(gradleApi()) + + testImplementation(gradleTestKit()) + testImplementation("junit:junit:4.12") + testImplementation("org.assertj:assertj-core:3.5.2") + testImplementation("commons-io:commons-io:2.5") + testImplementation("org.jetbrains.kotlin:kotlin-reflect") +} + +adbUninstall { + packageNames.addAll( + "com.trevjonez.andapp", + "com.trevjonez.andapp.test", + + "com.trevjonez.anddyn", + "com.trevjonez.anddyn.test", + "com.trevjonez.atinstall.test", + + "com.trevjonez.andlib.test", + + "com.trevjonez.testapp", + "com.trevjonez.testapp.test", + ) } tasks.named("test").configure { - systemProperty("buildDir", buildDir.absolutePath) - systemProperty("andApp", new File(rootProject.projectDir, "and-app").absolutePath) - systemProperty("andLib", new File(rootProject.projectDir, "and-lib").absolutePath) - systemProperty("andDyn", new File(rootProject.projectDir, "and-dyn").absolutePath) - systemProperty("andTest", new File(rootProject.projectDir, "and-test").absolutePath) - systemProperty("org.gradle.testkit.debug", false) + systemProperty("buildDir", buildDir.absolutePath) + systemProperty("andApp", new File(rootProject.projectDir, "and-app").absolutePath) + systemProperty("andLib", new File(rootProject.projectDir, "and-lib").absolutePath) + systemProperty("andDyn", new File(rootProject.projectDir, "and-dyn").absolutePath) + systemProperty("andTest", new File(rootProject.projectDir, "and-test").absolutePath) + systemProperty("org.gradle.testkit.debug", false) - outputs.dir("$buildDir/tests") - outputs.dir(new File(rootProject.projectDir, "and-app/build")) - outputs.dir(new File(rootProject.projectDir, "and-lib/build")) - outputs.dir(new File(rootProject.projectDir, "and-dyn/build")) - outputs.dir(new File(rootProject.projectDir, "and-dyn/base/build")) - outputs.dir(new File(rootProject.projectDir, "and-dyn/atInstall/build")) + outputs.dir("$buildDir/tests") + outputs.dir(new File(rootProject.projectDir, "and-app/build")) + outputs.dir(new File(rootProject.projectDir, "and-lib/build")) + outputs.dir(new File(rootProject.projectDir, "and-dyn/build")) + outputs.dir(new File(rootProject.projectDir, "and-dyn/base/build")) + outputs.dir(new File(rootProject.projectDir, "and-dyn/atInstall/build")) - inputs.files("gradle.properties") - inputs.dir(new File(rootProject.projectDir, "and-app/src")) - inputs.files(new File(rootProject.projectDir, "and-app/build.gradle")) - inputs.files(new File(rootProject.projectDir, "and-app/build-cascade-dsl.gradle")) - inputs.files(new File(rootProject.projectDir, "and-app/build-custom-task.gradle")) - inputs.files(new File(rootProject.projectDir, "and-app/settings.gradle")) + inputs.files("gradle.properties") + inputs.dir(new File(rootProject.projectDir, "and-app/src")) + inputs.files(new File(rootProject.projectDir, "and-app/build.gradle")) + inputs.files(new File(rootProject.projectDir, "and-app/build-cascade-dsl.gradle")) + inputs.files(new File(rootProject.projectDir, "and-app/build-custom-task.gradle")) + inputs.files(new File(rootProject.projectDir, "and-app/settings.gradle")) - inputs.dir(new File(rootProject.projectDir, "and-lib/src")) - inputs.files(new File(rootProject.projectDir, "and-lib/build.gradle")) - inputs.files(new File(rootProject.projectDir, "and-lib/settings.gradle")) + inputs.dir(new File(rootProject.projectDir, "and-lib/src")) + inputs.files(new File(rootProject.projectDir, "and-lib/build.gradle")) + inputs.files(new File(rootProject.projectDir, "and-lib/settings.gradle")) - inputs.files(new File(rootProject.projectDir, "and-dyn/build.gradle")) - inputs.files(new File(rootProject.projectDir, "and-dyn/settings.gradle")) + inputs.files(new File(rootProject.projectDir, "and-dyn/build.gradle")) + inputs.files(new File(rootProject.projectDir, "and-dyn/settings.gradle")) - inputs.dir(new File(rootProject.projectDir, "and-dyn/base/src")) - inputs.files(new File(rootProject.projectDir, "and-dyn/base/build.gradle")) + inputs.dir(new File(rootProject.projectDir, "and-dyn/base/src")) + inputs.files(new File(rootProject.projectDir, "and-dyn/base/build.gradle")) - inputs.dir(new File(rootProject.projectDir, "and-dyn/atInstall/src")) - inputs.files(new File(rootProject.projectDir, "and-dyn/atInstall/build.gradle")) + inputs.dir(new File(rootProject.projectDir, "and-dyn/atInstall/src")) + inputs.files(new File(rootProject.projectDir, "and-dyn/atInstall/build.gradle")) - inputs.dir(new File(rootProject.projectDir, "and-test/app/src")) - inputs.files(new File(rootProject.projectDir, "and-test/app/build.gradle")) + inputs.dir(new File(rootProject.projectDir, "and-test/app/src")) + inputs.files(new File(rootProject.projectDir, "and-test/app/build.gradle")) - inputs.dir(new File(rootProject.projectDir, "and-test/test/src")) - inputs.files(new File(rootProject.projectDir, "and-test/test/build.gradle")) + inputs.dir(new File(rootProject.projectDir, "and-test/test/src")) + inputs.files(new File(rootProject.projectDir, "and-test/test/build.gradle")) - inputs.files(new File(rootProject.projectDir, "and-test/build.gradle")) - inputs.files(new File(rootProject.projectDir, "and-test/settings.gradle")) + inputs.files(new File(rootProject.projectDir, "and-test/build.gradle")) + inputs.files(new File(rootProject.projectDir, "and-test/settings.gradle")) - inputs.dir(new File(rootProject.projectDir, "commander/os/src/main")) - inputs.files(new File(rootProject.projectDir, "commander/os/build.gradle")) + inputs.dir(new File(rootProject.projectDir, "commander/os/src/main")) + inputs.files(new File(rootProject.projectDir, "commander/os/build.gradle")) - inputs.dir(new File(rootProject.projectDir, "commander/android/src/main")) - inputs.files(new File(rootProject.projectDir, "commander/android/build.gradle")) + inputs.dir(new File(rootProject.projectDir, "commander/android/src/main")) + inputs.files(new File(rootProject.projectDir, "commander/android/build.gradle")) - inputs.dir(new File(rootProject.projectDir, "composer/composer/src/main")) - inputs.files(new File(rootProject.projectDir, "composer/composer/build.gradle")) + inputs.dir(new File(rootProject.projectDir, "composer/composer/src/main")) + inputs.files(new File(rootProject.projectDir, "composer/composer/build.gradle")) - inputs.dir(new File(rootProject.projectDir, "composer/html-report")) + inputs.dir(new File(rootProject.projectDir, "composer/html-report")) - dependsOn(":composer:publishToMavenLocal") - dependsOn(":commander:os:publishToMavenLocal") - dependsOn(":commander:android:publishToMavenLocal") + dependsOn(":composer:publishToMavenLocal") + dependsOn(":commander:os:publishToMavenLocal") + dependsOn(":commander:android:publishToMavenLocal") } def sourcesJar = tasks.register("sourcesJar", Jar) { - classifier = "sources" - from(sourceSets["main"].allSource) - dependsOn(sourceSets["main"].classesTaskName) + classifier = "sources" + from(sourceSets["main"].allSource) + dependsOn(sourceSets["main"].classesTaskName) } publishing { - publications { - register("plugin", MavenPublication) { - from(components["java"]) - artifact(sourcesJar.get()) - - pom { - inceptionYear.set("2017") - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - } + publications { + register("plugin", MavenPublication) { + from(components["java"]) + artifact(sourcesJar.get()) + + pom { + inceptionYear.set("2017") + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + } } - } } - } } \ No newline at end of file