Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was failing as actions/cache@v2 is deprecated: https://github.com/Telefonica/android-permissioncheck/actions/runs/21857243109 so I've updated both actions.

uses: actions/cache@v5
with:
path: |
~/.gradle/caches
Expand Down
1 change: 0 additions & 1 deletion .java-version

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```

Expand All @@ -57,7 +57,7 @@ buildscript {
}
}
dependencies {
classpath "com.telefonica:manifestcheck:1.0.2"
classpath "com.telefonica:manifestcheck:1.1.0"
}
}
```
Expand Down
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
Expand All @@ -30,9 +31,9 @@ subprojects {
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xopt-in=kotlin.ExperimentalStdlibApi")
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs.add("-Xopt-in=kotlin.ExperimentalStdlibApi")
}
}

Expand Down
4 changes: 3 additions & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -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}"
Comment thread
jeprubio marked this conversation as resolved.
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions manifestcheck/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new version of this plugin


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())
Expand All @@ -29,10 +30,12 @@ configurations {

// Publish all modules as part of a single uber plugin JAR
tasks.withType<Jar>().configureEach {
dependsOn(":plugin-configurator-v1:jar", ":plugin-core:jar")
from(uber.asSequence().filter { it.startsWith(rootDir) }.map { zipTree(it) }.asIterable())
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
dependsOn("publishToMavenLocal")
}

Expand All @@ -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"
Comment on lines 51 to 52

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tags = listOf("manifestcheck", "permissions")
}
Original file line number Diff line number Diff line change
@@ -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<Project> {
private lateinit var extension: PermissionCheckExtension
Expand All @@ -18,7 +17,7 @@ class PermissionCheckPlugin : Plugin<Project> {
return@configureEach // Only applicable to app modules
}

val taskConfigurator = TaskConfiguratorFactory.getTaskConfigurator()
val taskConfigurator = TaskConfiguratorV1()
taskConfigurator.configureTasks(project, extension)
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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("<manifest", "<!-- comment -->\n<manifest")) // Trigger change

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't update anymore the namespace which has been moved from the manifest to the gradle file so it seems safer to just add a comment in that file.


buildResult = androidProject.runTask(
"checkPermissions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class SingleVariantPermissionCheckIntegrationTest {
assertEquals(TaskOutcome.UP_TO_DATE, buildResult.tasks.outcomeOf("checkDebugPermissions"))

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("<manifest", "<!-- comment -->\n<manifest")) // Trigger change

buildResult = androidProject.runTask(
"checkDebugPermissions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,16 @@ class AndroidProjectExtension : BeforeEachCallback, AfterEachCallback {
}

android {
namespace = "com.telefonica.manifestcheck.sample.app"

@jeprubio jeprubio Feb 10, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace has to be moved from the manifest files to the gradle files when upgrading.

compileSdkVersion(30)

defaultConfig {
minSdkVersion(21)
targetSdkVersion(30)
}

lintOptions {
check("")
lint {
abortOnError = false
}
}

Expand All @@ -159,8 +160,7 @@ class AndroidProjectExtension : BeforeEachCallback, AfterEachCallback {

val androidManifest = mainDir.resolve("AndroidManifest.xml")
androidManifest.writeText("""
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.simonschiller.permissioncheck.sample.app">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.simonschiller.permissioncheck.testutil
Comment thread
jeprubio marked this conversation as resolved.

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
Expand All @@ -11,29 +10,21 @@ class TestVersions : ArgumentsProvider {
override fun provideArguments(context: ExtensionContext): Stream<out Arguments> {
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",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gradle version we test

)

// See https://developer.android.com/studio/releases/gradle-plugin
private val AGP_VERSIONS = listOf(
"7.0.0",
"9.0.0",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agp version we test

)

val LATEST_GRADLE_VERSION = GRADLE_VERSIONS.first()
Expand Down
7 changes: 7 additions & 0 deletions plugin-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
17 changes: 9 additions & 8 deletions sample/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +11 to +12

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the target and minSdk versions in this sample app project with more actual values

}

lintOptions {
checkOnly("") // Disable all Lint checks
}
lint {
abortOnError = false
}
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions sample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.simonschiller.permissioncheck.sample.app">

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package has to be removed and added as namespace in the gradle files

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Expand Down
10 changes: 5 additions & 5 deletions sample/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
3 changes: 1 addition & 2 deletions sample/library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.simonschiller.permissioncheck.sample.library">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="26" />
Expand Down