Browse Source

Use gradle logger to filter out when running with only warning logs.

feature/jme/open-room-member-details-when-clicking-on-user-data
Benoit Marty 1 year ago
parent
commit
80b656a9c5
  1. 2
      app/build.gradle.kts
  2. 2
      appnav/build.gradle.kts
  3. 20
      plugins/src/main/kotlin/extension/DependencyHandleScope.kt
  4. 2
      settings.gradle.kts
  5. 2
      tests/uitests/build.gradle.kts

2
app/build.gradle.kts

@ -206,7 +206,7 @@ knit {
dependencies { dependencies {
allLibrariesImpl() allLibrariesImpl()
allServicesImpl() allServicesImpl()
allFeaturesImpl(rootDir) allFeaturesImpl(rootDir, logger)
implementation(projects.libraries.deeplink) implementation(projects.libraries.deeplink)
implementation(projects.tests.uitests) implementation(projects.tests.uitests)
implementation(projects.anvilannotations) implementation(projects.anvilannotations)

2
appnav/build.gradle.kts

@ -36,7 +36,7 @@ dependencies {
implementation(libs.dagger) implementation(libs.dagger)
kapt(libs.dagger.compiler) kapt(libs.dagger.compiler)
allFeaturesApi(rootDir) allFeaturesApi(rootDir, logger)
implementation(projects.libraries.core) implementation(projects.libraries.core)
implementation(projects.libraries.androidutils) implementation(projects.libraries.androidutils)

20
plugins/src/main/kotlin/extension/DependencyHandleScope.kt

@ -19,6 +19,7 @@ package extension
import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.kotlin.dsl.DependencyHandlerScope import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.gradle.kotlin.dsl.project import org.gradle.kotlin.dsl.project
import org.gradle.api.logging.Logger
import java.io.File import java.io.File
private fun DependencyHandlerScope.implementation(dependency: Any) = dependencies.add("implementation", dependency) private fun DependencyHandlerScope.implementation(dependency: Any) = dependencies.add("implementation", dependency)
@ -53,16 +54,21 @@ fun DependencyHandlerScope.composeDependencies(libs: LibrariesForLibs) {
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5") implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5")
} }
private fun DependencyHandlerScope.addImplementationProjects(directory: File, path: String, nameFilter: String) { private fun DependencyHandlerScope.addImplementationProjects(
directory: File,
path: String,
nameFilter: String,
logger: Logger,
) {
directory.listFiles().orEmpty().also { it.sort() }.forEach { file -> directory.listFiles().orEmpty().also { it.sort() }.forEach { file ->
if (file.isDirectory) { if (file.isDirectory) {
val newPath = "$path:${file.name}" val newPath = "$path:${file.name}"
val buildFile = File(file, "build.gradle.kts") val buildFile = File(file, "build.gradle.kts")
if (buildFile.exists() && file.name == nameFilter) { if (buildFile.exists() && file.name == nameFilter) {
implementation(project(newPath)) implementation(project(newPath))
println("Added implementation(project($newPath))") logger.lifecycle("Added implementation(project($newPath))")
} else { } else {
addImplementationProjects(file, newPath, nameFilter) addImplementationProjects(file, newPath, nameFilter, logger)
} }
} }
} }
@ -100,12 +106,12 @@ fun DependencyHandlerScope.allServicesImpl() {
implementation(project(":services:toolbox:impl")) implementation(project(":services:toolbox:impl"))
} }
fun DependencyHandlerScope.allFeaturesApi(rootDir: File) { fun DependencyHandlerScope.allFeaturesApi(rootDir: File, logger: Logger) {
val featuresDir = File(rootDir, "features") val featuresDir = File(rootDir, "features")
addImplementationProjects(featuresDir, ":features", "api") addImplementationProjects(featuresDir, ":features", "api", logger)
} }
fun DependencyHandlerScope.allFeaturesImpl(rootDir: File) { fun DependencyHandlerScope.allFeaturesImpl(rootDir: File, logger: Logger) {
val featuresDir = File(rootDir, "features") val featuresDir = File(rootDir, "features")
addImplementationProjects(featuresDir, ":features", "impl") addImplementationProjects(featuresDir, ":features", "impl", logger)
} }

2
settings.gradle.kts

@ -62,7 +62,7 @@ fun includeProjects(directory: File, path: String, maxDepth: Int = 1) {
val buildFile = File(file, "build.gradle.kts") val buildFile = File(file, "build.gradle.kts")
if (buildFile.exists()) { if (buildFile.exists()) {
include(newPath) include(newPath)
println("Included project: $newPath") logger.lifecycle("Included project: $newPath")
} else if (maxDepth > 0) { } else if (maxDepth > 0) {
includeProjects(file, newPath, maxDepth - 1) includeProjects(file, newPath, maxDepth - 1)
} }

2
tests/uitests/build.gradle.kts

@ -37,5 +37,5 @@ dependencies {
implementation(libs.showkase) implementation(libs.showkase)
allLibrariesImpl() allLibrariesImpl()
allFeaturesImpl(rootDir) allFeaturesImpl(rootDir, logger)
} }

Loading…
Cancel
Save