Skip to content
Open
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
25 changes: 25 additions & 0 deletions build-logic/composeLint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Setup

This plugin automatically adds the lint to all modules defined in the whole project and
use [lint.xml](../../lint.xml) as the single source of truth to configure the lints in every app

To enable these compose lints in a new project, follow these steps:

1. Make sure your top level settings.gradle.kts defines the following if not already done in order to import Core's composite
build:

```kts
pluginManagement {
includeBuild("Core/build-logic")
}
```

2. Inside the top-level build.gradle.kts add the following plugin:

```kts
plugins {
id("com.infomaniak.core.compose.lint")
}
```

And you're done!
16 changes: 16 additions & 0 deletions build-logic/composeLint/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
`kotlin-dsl`
}

dependencies {
compileOnly(core.gradle.build.tools)
}

gradlePlugin {
plugins {
register("coreComposeLint") {
id = "com.infomaniak.core.compose.lint"
implementationClass = "com.infomaniak.core.compose.lint.ComposeLintPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Infomaniak Core - Android
* Copyright (C) 2025 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.core.compose.lint

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

/**
* Automatically adds the lint to all modules defined in the whole project and use Core/lint.xml as the single source of truth to
* configure the lints in every app.
*/
class ComposeLintPlugin : Plugin<Project> {
override fun apply(target: Project) {
target.subprojects {
plugins.withId("com.android.base") {
extensions.configure<com.android.build.gradle.internal.dsl.BaseAppModuleExtension> {
lint {
lintConfig = rootProject.file("Core/lint.xml")
}
}

val coreVersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("core")
dependencies {
add("lintChecks", coreVersionCatalog.findLibrary("compose-lint-checks").get())
}
}
}
}
}
5 changes: 4 additions & 1 deletion build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ dependencyResolutionManagement {

rootProject.name = "build-logic"

include(":composite")
include(
":composite",
":composeLint",
)
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ android {
}
}
}

subprojects {
plugins.withId("com.android.base") {
dependencies {
lintChecks(core.compose.lint.checks)
}
}
}
5 changes: 4 additions & 1 deletion gradle/core.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ biometricKtx = "1.2.0-alpha05"
coil = "3.3.0"
coil2 = "2.7.0" # Coil2 is used in old Legacy modules only
composeBom = "2025.12.00"
composeLintChecks = "1.4.2"
concurrentFuturesKtx = "1.3.0"
constraintLayout = "2.2.1"
coordinatorLayout = "1.3.0"
Expand Down Expand Up @@ -90,8 +91,9 @@ coil-two-gif = { module = "io.coil-kt:coil-gif", version.ref = "coil2" }
coil-video = { module = "io.coil-kt.coil3:coil-video", version.ref = "coil" }
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" }
compose-foundation = { module = "androidx.compose.foundation:foundation" }
compose-material3 = { module = "androidx.compose.material3:material3" }
compose-lint-checks = { module = "com.slack.lint.compose:compose-lint-checks", version.ref = "composeLintChecks" }
compose-material-icons = { group = "androidx.compose.material", name = "material-icons-core" }
compose-material3 = { module = "androidx.compose.material3:material3" }
compose-runtime = { module = "androidx.compose.runtime:runtime" }
compose-ui = { module = "androidx.compose.ui:ui" }
compose-ui-android = { module = "androidx.compose.ui:ui-android" }
Expand All @@ -102,6 +104,7 @@ constraintlayout = { module = "androidx.constraintlayout:constraintlayout", vers
coordinatorlayout = { module = "androidx.coordinatorlayout:coordinatorlayout", version.ref = "coordinatorLayout" }
firebase-messaging-ktx = { module = "com.google.firebase:firebase-messaging-ktx", version.ref = "firebaseMessaging" }
foundation-android = { module = "androidx.compose.foundation:foundation-android" }
gradle-build-tools = { module = "com.android.tools.build:gradle", version.ref = "agp" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hiltAndroid" }
Expand Down
21 changes: 21 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Infomaniak Core - Android
~ Copyright (C) 2026 Infomaniak Network SA
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<lint>
<issue id="ComposeCompositionLocalUsage" severity="ignore" />
<issue id="ComposeModifierMissing" severity="warning" />
</lint>
Loading