diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea3376f..2579b1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Cache Gradle dependencies - uses: actions/cache@v2 + uses: actions/cache@v5 with: path: | ~/.gradle/caches diff --git a/.java-version b/.java-version deleted file mode 100644 index 2dbc24b..0000000 --- a/.java-version +++ /dev/null @@ -1 +0,0 @@ -11.0 diff --git a/README.md b/README.md index c19b366..b5cdc2b 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ To add the PermissionCheck plugin to your project, you have to add this block of ```groovy plugins { - id "com.telefonica.manifestcheck" version "1.0.2" + id "com.telefonica.manifestcheck" version "1.1.0" } ``` @@ -57,7 +57,7 @@ buildscript { } } dependencies { - classpath "com.telefonica:manifestcheck:1.0.2" + classpath "com.telefonica:manifestcheck:1.1.0" } } ``` diff --git a/build.gradle.kts b/build.gradle.kts index c49f908..1c2b3b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.kotlin.dsl.embeddedKotlinVersion import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.gradle.dsl.JvmTarget buildscript { repositories { @@ -9,7 +10,7 @@ buildscript { mavenLocal() } dependencies { - classpath("com.android.tools.build:gradle:7.0.0") + classpath("com.android.tools.build:gradle:9.0.0") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$embeddedKotlinVersion") // classpath("com.telefonica:manifestcheck:+") // Uncomment to use the sample @@ -30,9 +31,9 @@ subprojects { } tasks.withType().configureEach { - kotlinOptions { - jvmTarget = "1.8" - freeCompilerArgs = listOf("-Xopt-in=kotlin.ExperimentalStdlibApi") + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + freeCompilerArgs.add("-Xopt-in=kotlin.ExperimentalStdlibApi") } } diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 9e61a26..f924f92 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,9 +1,11 @@ object Versions { // See https://mvnrepository.com - const val JUNIT_5 = "5.7.1" + const val JUNIT_5 = "5.13.4" + const val JUNIT_PLATFORM_LAUNCHER = "1.13.4" } object Dependencies { const val JUNIT_5_ENGINE = "org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT_5}" const val JUNIT_5_API = "org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT_5}" const val JUNIT_5_PARAMS = "org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT_5}" + const val JUNIT_PLATFORM_LAUNCHER = "org.junit.platform:junit-platform-launcher:${Versions.JUNIT_PLATFORM_LAUNCHER}" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a0f7639..7b0b78c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/manifestcheck/build.gradle.kts b/manifestcheck/build.gradle.kts index 60a32fc..849fb9f 100644 --- a/manifestcheck/build.gradle.kts +++ b/manifestcheck/build.gradle.kts @@ -6,18 +6,19 @@ plugins { } group = "com.telefonica" -version = "1.0.2" // Also update the version in the README +version = "1.1.0" // Also update the version in the README val uber: Configuration by configurations.creating dependencies { compileOnly(gradleKotlinDsl()) - compileOnly("com.android.tools.build:gradle:7.0.0") + compileOnly("com.android.tools.build:gradle:9.0.0") uber(project(":plugin-configurator-v1")) uber(project(":plugin-core")) testRuntimeOnly(Dependencies.JUNIT_5_ENGINE) + testRuntimeOnly(Dependencies.JUNIT_PLATFORM_LAUNCHER) testImplementation(Dependencies.JUNIT_5_API) testImplementation(Dependencies.JUNIT_5_PARAMS) testImplementation(gradleKotlinDsl()) @@ -29,10 +30,12 @@ configurations { // Publish all modules as part of a single uber plugin JAR tasks.withType().configureEach { + dependsOn(":plugin-configurator-v1:jar", ":plugin-core:jar") from(uber.asSequence().filter { it.startsWith(rootDir) }.map { zipTree(it) }.asIterable()) } tasks.withType().configureEach { + useJUnitPlatform() dependsOn("publishToMavenLocal") } @@ -45,9 +48,6 @@ gradlePlugin { implementationClass = "io.github.simonschiller.permissioncheck.PermissionCheckPlugin" } } -} -pluginBundle { website = "https://github.com/Telefonica/android-permissioncheck" vcsUrl = "https://github.com/Telefonica/android-permissioncheck" - tags = listOf("manifestcheck", "permissions") } diff --git a/manifestcheck/src/main/kotlin/io/github/simonschiller/permissioncheck/PermissionCheckPlugin.kt b/manifestcheck/src/main/kotlin/io/github/simonschiller/permissioncheck/PermissionCheckPlugin.kt index 50c56cc..c1091a4 100644 --- a/manifestcheck/src/main/kotlin/io/github/simonschiller/permissioncheck/PermissionCheckPlugin.kt +++ b/manifestcheck/src/main/kotlin/io/github/simonschiller/permissioncheck/PermissionCheckPlugin.kt @@ -1,10 +1,9 @@ package io.github.simonschiller.permissioncheck import com.android.build.gradle.AppPlugin -import io.github.simonschiller.permissioncheck.config.TaskConfiguratorFactory +import io.github.simonschiller.permissioncheck.config.TaskConfiguratorV1 import org.gradle.api.Plugin import org.gradle.api.Project -import java.util.* class PermissionCheckPlugin : Plugin { private lateinit var extension: PermissionCheckExtension @@ -18,7 +17,7 @@ class PermissionCheckPlugin : Plugin { return@configureEach // Only applicable to app modules } - val taskConfigurator = TaskConfiguratorFactory.getTaskConfigurator() + val taskConfigurator = TaskConfiguratorV1() taskConfigurator.configureTasks(project, extension) } } diff --git a/manifestcheck/src/main/kotlin/io/github/simonschiller/permissioncheck/config/TaskConfiguratorFactory.kt b/manifestcheck/src/main/kotlin/io/github/simonschiller/permissioncheck/config/TaskConfiguratorFactory.kt deleted file mode 100644 index 72fae18..0000000 --- a/manifestcheck/src/main/kotlin/io/github/simonschiller/permissioncheck/config/TaskConfiguratorFactory.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.simonschiller.permissioncheck.config - -import org.gradle.util.VersionNumber - -/** Factory that produces different [TaskConfigurator]s to maintain backwards compatibility to older AGP versions. */ -internal object TaskConfiguratorFactory { - - fun getTaskConfigurator(): TaskConfigurator { - val version = VersionNumber.parse(getAndroidGradlePluginVersion()) - return when { - else -> TaskConfiguratorV1() - } - } - - private fun getAndroidGradlePluginVersion(): String { - val version = Class.forName("com.android.Version") - val field = version.getField("ANDROID_GRADLE_PLUGIN_VERSION") - return field.get(null) as String - } -} diff --git a/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/MultiVariantPermissionCheckIntegrationTest.kt b/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/MultiVariantPermissionCheckIntegrationTest.kt index f8fa0b5..7627358 100644 --- a/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/MultiVariantPermissionCheckIntegrationTest.kt +++ b/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/MultiVariantPermissionCheckIntegrationTest.kt @@ -298,7 +298,7 @@ class MultiVariantPermissionCheckIntegrationTest { assertEquals(TaskOutcome.UP_TO_DATE, buildResult.tasks.outcomeOf("checkPermissions")) val manifestFile = androidProject.appDir.resolve("src").resolve("main").resolve("AndroidManifest.xml") - manifestFile.writeText(manifestFile.readText().replace("simonschiller", "johndoe")) // Trigger change + manifestFile.writeText(manifestFile.readText().replace("\n\n + diff --git a/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/testutil/TestVersions.kt b/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/testutil/TestVersions.kt index 077dd33..7dde024 100644 --- a/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/testutil/TestVersions.kt +++ b/manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/testutil/TestVersions.kt @@ -1,6 +1,5 @@ package io.github.simonschiller.permissioncheck.testutil -import org.gradle.util.VersionNumber import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider @@ -11,29 +10,21 @@ class TestVersions : ArgumentsProvider { override fun provideArguments(context: ExtensionContext): Stream { val arguments = AGP_VERSIONS.flatMap { agpVersion -> GRADLE_VERSIONS - .filter { gradleVersion -> VersionNumber.parse(agpVersion).baseVersion isCompatibleWith VersionNumber.parse(gradleVersion).baseVersion } .map { gradleVersion -> Arguments.of(gradleVersion, agpVersion) } } return arguments.stream() } - // Checks if a AGP version (receiver) is compatible with a certain version of Gradle - private infix fun VersionNumber.isCompatibleWith(gradleVersion: VersionNumber) = when { - this >= VersionNumber.parse("7.0.0") -> gradleVersion >= VersionNumber.parse("7.0") - else -> false - } - companion object { // See https://gradle.org/releases private val GRADLE_VERSIONS = listOf( - "7.4.2", - "7.2", + "9.1.0", ) // See https://developer.android.com/studio/releases/gradle-plugin private val AGP_VERSIONS = listOf( - "7.0.0", + "9.0.0", ) val LATEST_GRADLE_VERSION = GRADLE_VERSIONS.first() diff --git a/plugin-core/build.gradle.kts b/plugin-core/build.gradle.kts index 8056d25..695c3d6 100644 --- a/plugin-core/build.gradle.kts +++ b/plugin-core/build.gradle.kts @@ -2,10 +2,17 @@ plugins { kotlin("jvm") } +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + dependencies { compileOnly(gradleKotlinDsl()) + compileOnly("com.android.tools.build:gradle:9.0.0") testRuntimeOnly(Dependencies.JUNIT_5_ENGINE) + testRuntimeOnly(Dependencies.JUNIT_PLATFORM_LAUNCHER) testImplementation(Dependencies.JUNIT_5_API) testImplementation(gradleKotlinDsl()) } diff --git a/sample/app/build.gradle.kts b/sample/app/build.gradle.kts index da4c9da..76d3cab 100644 --- a/sample/app/build.gradle.kts +++ b/sample/app/build.gradle.kts @@ -4,16 +4,17 @@ plugins { } android { - compileSdkVersion(33) + namespace = "com.telefonica.sampleapp" // Update to your actual package name + compileSdk = 36 - defaultConfig { - minSdkVersion(23) - targetSdkVersion(33) - } + defaultConfig { + minSdk = 24 + targetSdk = 36 + } - lintOptions { - checkOnly("") // Disable all Lint checks - } + lint { + abortOnError = false + } } dependencies { diff --git a/sample/app/src/main/AndroidManifest.xml b/sample/app/src/main/AndroidManifest.xml index f9b3697..9f2f1d6 100644 --- a/sample/app/src/main/AndroidManifest.xml +++ b/sample/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/sample/library/build.gradle.kts b/sample/library/build.gradle.kts index 3d9009d..ef39876 100644 --- a/sample/library/build.gradle.kts +++ b/sample/library/build.gradle.kts @@ -3,14 +3,14 @@ plugins { } android { - compileSdkVersion(30) + namespace = "com.telefonica.samplelibrary" // Update to your actual package name + compileSdk = 36 defaultConfig { - minSdkVersion(21) - targetSdkVersion(30) + minSdk = 24 } - lintOptions { - checkOnly("") // Disable all Lint checks + lint { + abortOnError = false } } diff --git a/sample/library/src/main/AndroidManifest.xml b/sample/library/src/main/AndroidManifest.xml index c962a7f..e81352a 100644 --- a/sample/library/src/main/AndroidManifest.xml +++ b/sample/library/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - +