Skip to content

move log config so that logging works when detector is disabled #298

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

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,36 @@ abstract class AffectedModuleDetector(protected val logger: Logger?) {
val instance = AffectedModuleDetectorWrapper()
rootProject.extensions.add(ROOT_PROP_NAME, instance)

val config =
requireNotNull(
rootProject.extensions.findByType(AffectedModuleConfiguration::class.java)
) {
"Root project ${rootProject.path} must have the AffectedModuleConfiguration " +
"extension added."
}

val distDir = if (config.logFolder != null) {
val distDir = File(config.logFolder!!)
if (!distDir.exists()) {
distDir.mkdirs()
}
distDir
} else {
rootProject.rootDir
}

val outputFile = distDir.resolve(config.logFilename).also {
it.writeText("")
}
val logger = FileLogger(outputFile)

val enabled = isProjectEnabled(rootProject)
if (!enabled) {
val provider =
setupWithParams(rootProject) { spec ->
val params = spec.parameters
params.acceptAll = true
params.log = logger
}
instance.wrapped = provider
return
Expand All @@ -171,29 +195,6 @@ abstract class AffectedModuleDetector(protected val logger: Logger?) {
}
}

val config =
requireNotNull(
rootProject.extensions.findByType(AffectedModuleConfiguration::class.java)
) {
"Root project ${rootProject.path} must have the AffectedModuleConfiguration " +
"extension added."
}

val distDir = if (config.logFolder != null) {
val distDir = File(config.logFolder!!)
if (!distDir.exists()) {
distDir.mkdirs()
}
distDir
} else {
rootProject.rootDir
}

val outputFile = distDir.resolve(config.logFilename).also {
it.writeText("")
}
val logger = FileLogger(outputFile)

val modules =
getModulesProperty(
rootProject
Expand Down
Loading