Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add Dependency Analysis Glean Plugin #2826

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ buildscript {
}

plugins {
alias libs.plugins.dependency.analysis
alias libs.plugins.detekt
}

Expand Down Expand Up @@ -152,6 +153,22 @@ subprojects {
}
}

dependencyAnalysis {
structure {
ignoreKtx(true) // Ignore Android KTX dependencies
}
issues {
all {
onAny {
// Fail the run if any issues are found (default = 'warn')
//severity('fail')
// Ignore warnings about kotlin-stdlib since we don't directly control its usage
exclude('org.jetbrains.kotlin:kotlin-stdlib')
}
}
}
}

detekt {
input = files("${projectDir}/glean-core", "${projectDir}/samples/android", "buildSrc")
config = files("${projectDir}/.detekt.yml")
Expand Down
2 changes: 1 addition & 1 deletion glean-core/android-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ dependencies {
type = "jar"
}
}
implementation(libs.jna) {
runtimeOnly(libs.jna) {
artifact {
extension ="aar"
type = "aar"
Expand Down
10 changes: 1 addition & 9 deletions glean-core/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ dependencies {
type = "jar"
}
}
implementation(libs.jna) {
api(libs.jna) {
artifact {
extension ="aar"
type = "aar"
Expand All @@ -180,14 +180,6 @@ dependencies {
compileOnly libs.junit
compileOnly libs.test.work

// For reasons unknown, resolving the jnaForTest configuration directly
// trips a nasty issue with the Android-Gradle plugin 3.2.1, like `Cannot
// change attributes of configuration ':PROJECT:kapt' after it has been
// resolved`. I think that the configuration is being made a
// super-configuration of the testImplementation and then the `.files` is
// causing it to be resolved. Cloning first dissociates the configuration,
// avoiding other configurations from being resolved. Tricky!
testImplementation files(configurations.jnaForTest.copyRecursive().files)
testImplementation libs.mockito
testImplementation libs.mockwebserver
testImplementation libs.robolectric
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ rust-android-gradle = "0.9.4"
# AndroidX
androidx-annotation = "1.7.1"
androidx-appcompat = "1.6.1"
androidx-browser = "1.7.0"
androidx-lifecycle = "2.7.0"
androidx-work = "2.9.0"

# JNA
jna = "5.14.0"

# Linting and Static Analysis
dependency-analysis = "1.31.0"
detekt = "1.23.5"
ktlint = "0.50.0"

Expand Down Expand Up @@ -62,7 +62,6 @@ mozilla-rust-android-gradle = { group = "org.mozilla.rust-android-gradle", name
# AndroidX
androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "androidx-annotation" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
androidx-browser = { group = "androidx.browser", name = "browser", version.ref = "androidx-browser" }
androidx-lifecycle-common = { group = "androidx.lifecycle", name = "lifecycle-common", version.ref = "androidx-lifecycle" }
androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "androidx-lifecycle" }
androidx-work = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "androidx-work" }
Expand All @@ -89,5 +88,6 @@ mockwebserver = { group = "com.squareup.okhttp3", name = "mockwebserver", versio
robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" }

[plugins]
dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependency-analysis" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
gradle-python-envs = { id = "com.jetbrains.python.envs", version.ref = "python-envs" }
2 changes: 0 additions & 2 deletions samples/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ dependencies {
implementation project(':glean')

implementation libs.androidx.appcompat
implementation libs.androidx.browser

androidTestImplementation libs.mockwebserver
androidTestImplementation libs.test.core
Expand All @@ -51,7 +50,6 @@ dependencies {
androidTestImplementation libs.test.rules
androidTestImplementation libs.test.runner
androidTestImplementation libs.test.uiautomator
androidTestImplementation libs.test.work
}

ext.gleanNamespace = "mozilla.telemetry.glean"
Expand Down
Loading