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

This commit is contained in:
Benoit Marty 2023-05-25 12:03:51 +02:00
parent 981632b7a4
commit 14366e18e7
5 changed files with 17 additions and 11 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)
} }

View file

@ -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)
} }

View file

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