diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt index cddcf5fe2..560ad8735 100644 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt @@ -25,6 +25,7 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies abstract class AndroidApplicationConventionPlugin : Plugin { override fun apply(target: Project) { @@ -44,6 +45,10 @@ abstract class AndroidApplicationConventionPlugin : Plugin { configureBadgingTasks(this) } configureSpotlessForAndroid() + + dependencies { + "compileOnly"(project(":lint")) + } } } } diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt index d5aaa131d..9aece5505 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -55,11 +55,13 @@ abstract class AndroidLibraryConventionPlugin : Plugin { } configureSpotlessForAndroid() dependencies { - "androidTestImplementation"(libs.findLibrary("kotlin.test").get()) + if (project.path != ":lint") "compileOnly"(project(":lint")) + "implementation"(libs.findLibrary("androidx.tracing.ktx").get()) + "testImplementation"(libs.findLibrary("kotlin.test").get()) "testImplementation"(libs.findLibrary("junit").get()) - "implementation"(libs.findLibrary("androidx.tracing.ktx").get()) + "androidTestImplementation"(libs.findLibrary("kotlin.test").get()) } } } diff --git a/build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt index c701983b1..13127cf61 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt @@ -44,6 +44,5 @@ class AndroidLintConventionPlugin : Plugin { private fun Lint.configure() { xmlReport = true sarifReport = true - checkDependencies = true disable += "GradleDependency" } diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index 8a138082b..b02b968b4 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -26,8 +26,6 @@ android { } dependencies { - lintPublish(projects.lint) - api(libs.androidx.compose.foundation) api(libs.androidx.compose.foundation.layout) api(libs.androidx.compose.material.iconsExtended) diff --git a/core/designsystem/lint.xml b/core/designsystem/lint.xml new file mode 100644 index 000000000..0e017b751 --- /dev/null +++ b/core/designsystem/lint.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/lint/README.md b/lint/README.md index 24d312242..c5d1ac642 100644 --- a/lint/README.md +++ b/lint/README.md @@ -11,7 +11,7 @@ config: nodePlacementStrategy: SIMPLE --- graph TB - :lint[lint]:::unknown + :lint[lint]:::android-library classDef android-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000; classDef android-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000; diff --git a/lint/build.gradle.kts b/lint/build.gradle.kts index f1722fa78..15a648717 100644 --- a/lint/build.gradle.kts +++ b/lint/build.gradle.kts @@ -14,31 +14,14 @@ * limitations under the License. */ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - plugins { - `java-library` - kotlin("jvm") - alias(libs.plugins.nowinandroid.android.lint) -} - -java { - // Up to Java 11 APIs are available through desugaring - // https://developer.android.com/studio/write/java11-minimal-support-table - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + alias(libs.plugins.nowinandroid.android.library) } -kotlin { - compilerOptions { - jvmTarget = JvmTarget.JVM_11 - } +android { + namespace = "com.google.samples.apps.nowinandroid.lint" } dependencies { - compileOnly(libs.kotlin.stdlib) - compileOnly(libs.lint.api) - testImplementation(libs.kotlin.test) - testImplementation(libs.lint.checks) - testImplementation(libs.lint.tests) + lintPublish(projects.lint.impl) } diff --git a/lint/impl/.gitignore b/lint/impl/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/lint/impl/.gitignore @@ -0,0 +1 @@ +/build diff --git a/lint/impl/README.md b/lint/impl/README.md new file mode 100644 index 000000000..02192c532 --- /dev/null +++ b/lint/impl/README.md @@ -0,0 +1,48 @@ +# `:lint:impl` + +## Module dependency graph + + +```mermaid +--- +config: + layout: elk + elk: + nodePlacementStrategy: SIMPLE +--- +graph TB + subgraph :lint + direction TB + :lint:impl[impl]:::unknown + end + +classDef android-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000; +classDef android-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000; +classDef android-library fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000; +classDef android-test fill:#A0C4FF,stroke:#000,stroke-width:2px,color:#000; +classDef jvm-library fill:#BDB2FF,stroke:#000,stroke-width:2px,color:#000; +classDef unknown fill:#FFADAD,stroke:#000,stroke-width:2px,color:#000; +``` + +
📋 Graph legend + +```mermaid +graph TB + application[application]:::android-application + feature[feature]:::android-feature + library[library]:::android-library + jvm[jvm]:::jvm-library + + application -.-> feature + library --> jvm + +classDef android-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000; +classDef android-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000; +classDef android-library fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000; +classDef android-test fill:#A0C4FF,stroke:#000,stroke-width:2px,color:#000; +classDef jvm-library fill:#BDB2FF,stroke:#000,stroke-width:2px,color:#000; +classDef unknown fill:#FFADAD,stroke:#000,stroke-width:2px,color:#000; +``` + +
+ diff --git a/lint/impl/build.gradle.kts b/lint/impl/build.gradle.kts new file mode 100644 index 000000000..ac330ce5e --- /dev/null +++ b/lint/impl/build.gradle.kts @@ -0,0 +1,44 @@ +/* + * Copyright 2026 The Android Open Source Project + * + * 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 + * + * https://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. + */ + +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +plugins { + `java-library` + kotlin("jvm") + alias(libs.plugins.nowinandroid.android.lint) +} + +java { + // Up to Java 11 APIs are available through desugaring + // https://developer.android.com/studio/write/java11-minimal-support-table + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_11 + } +} + +dependencies { + compileOnly(libs.kotlin.stdlib) + compileOnly(libs.lint.api) + testImplementation(libs.kotlin.test) + testImplementation(libs.lint.checks) + testImplementation(libs.lint.tests) +} diff --git a/lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/NiaIssueRegistry.kt b/lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/NiaIssueRegistry.kt similarity index 86% rename from lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/NiaIssueRegistry.kt rename to lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/NiaIssueRegistry.kt index b806312fd..761e40ef5 100644 --- a/lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/NiaIssueRegistry.kt +++ b/lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/NiaIssueRegistry.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Android Open Source Project + * Copyright 2026 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.lint +package com.google.samples.apps.nowinandroid.lint.impl import com.android.tools.lint.client.api.IssueRegistry import com.android.tools.lint.client.api.Vendor import com.android.tools.lint.detector.api.CURRENT_API -import com.google.samples.apps.nowinandroid.lint.designsystem.DesignSystemDetector +import com.google.samples.apps.nowinandroid.lint.impl.designsystem.DesignSystemDetector class NiaIssueRegistry : IssueRegistry() { diff --git a/lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/TestMethodNameDetector.kt b/lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/TestMethodNameDetector.kt similarity index 98% rename from lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/TestMethodNameDetector.kt rename to lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/TestMethodNameDetector.kt index 532994d99..8d60076f6 100644 --- a/lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/TestMethodNameDetector.kt +++ b/lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/TestMethodNameDetector.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.lint +package com.google.samples.apps.nowinandroid.lint.impl import com.android.tools.lint.detector.api.AnnotationInfo import com.android.tools.lint.detector.api.AnnotationUsageInfo diff --git a/lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/designsystem/DesignSystemDetector.kt b/lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/DesignSystemDetector.kt similarity index 98% rename from lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/designsystem/DesignSystemDetector.kt rename to lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/DesignSystemDetector.kt index 09af17db9..bc1920354 100644 --- a/lint/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/designsystem/DesignSystemDetector.kt +++ b/lint/impl/src/main/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/DesignSystemDetector.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.lint.designsystem +package com.google.samples.apps.nowinandroid.lint.impl.designsystem import com.android.tools.lint.client.api.UElementHandler import com.android.tools.lint.detector.api.Category diff --git a/lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry b/lint/impl/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry similarity index 90% rename from lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry rename to lint/impl/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry index e673c27ff..94742f3ea 100644 --- a/lint/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry +++ b/lint/impl/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry @@ -14,4 +14,4 @@ # limitations under the License. # -com.google.samples.apps.nowinandroid.lint.NiaIssueRegistry +com.google.samples.apps.nowinandroid.lint.impl.NiaIssueRegistry diff --git a/lint/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/designsystem/DesignSystemDetectorTest.kt b/lint/impl/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/DesignSystemDetectorTest.kt similarity index 93% rename from lint/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/designsystem/DesignSystemDetectorTest.kt rename to lint/impl/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/DesignSystemDetectorTest.kt index 188a52ee0..e074ee5c8 100644 --- a/lint/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/designsystem/DesignSystemDetectorTest.kt +++ b/lint/impl/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/DesignSystemDetectorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 The Android Open Source Project + * Copyright 2026 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,14 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.lint.designsystem +package com.google.samples.apps.nowinandroid.lint.impl.designsystem import com.android.tools.lint.checks.infrastructure.TestFile import com.android.tools.lint.checks.infrastructure.TestFiles.kotlin import com.android.tools.lint.checks.infrastructure.TestLintTask.lint -import com.google.samples.apps.nowinandroid.lint.designsystem.DesignSystemDetector.Companion.ISSUE -import com.google.samples.apps.nowinandroid.lint.designsystem.DesignSystemDetector.Companion.METHOD_NAMES -import com.google.samples.apps.nowinandroid.lint.designsystem.DesignSystemDetector.Companion.RECEIVER_NAMES +import com.google.samples.apps.nowinandroid.lint.impl.designsystem.DesignSystemDetector.Companion.ISSUE +import com.google.samples.apps.nowinandroid.lint.impl.designsystem.DesignSystemDetector.Companion.METHOD_NAMES +import com.google.samples.apps.nowinandroid.lint.impl.designsystem.DesignSystemDetector.Companion.RECEIVER_NAMES import org.junit.Test class DesignSystemDetectorTest { diff --git a/lint/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/TestMethodNameDetectorTest.kt b/lint/impl/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/TestMethodNameDetectorTest.kt similarity index 93% rename from lint/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/TestMethodNameDetectorTest.kt rename to lint/impl/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/TestMethodNameDetectorTest.kt index 8da173285..acdd97a14 100644 --- a/lint/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/TestMethodNameDetectorTest.kt +++ b/lint/impl/src/test/kotlin/com/google/samples/apps/nowinandroid/lint/impl/designsystem/TestMethodNameDetectorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 The Android Open Source Project + * Copyright 2026 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.lint +package com.google.samples.apps.nowinandroid.lint.impl.designsystem import com.android.tools.lint.checks.infrastructure.TestFile import com.android.tools.lint.checks.infrastructure.TestFiles.kotlin import com.android.tools.lint.checks.infrastructure.TestLintTask.lint -import com.google.samples.apps.nowinandroid.lint.TestMethodNameDetector.Companion.FORMAT -import com.google.samples.apps.nowinandroid.lint.TestMethodNameDetector.Companion.PREFIX +import com.google.samples.apps.nowinandroid.lint.impl.TestMethodNameDetector.Companion.FORMAT +import com.google.samples.apps.nowinandroid.lint.impl.TestMethodNameDetector.Companion.PREFIX import org.junit.Test class TestMethodNameDetectorTest { diff --git a/settings.gradle.kts b/settings.gradle.kts index 73a1d9d6a..39ed789d5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -78,6 +78,7 @@ include(":feature:search:api") include(":feature:search:impl") include(":feature:settings:impl") include(":lint") +include(":lint:impl") include(":sync:work") include(":sync:sync-test") include(":ui-test-hilt-manifest")