Skip to content

Commit

Permalink
Support for multiple ignore files
Browse files Browse the repository at this point in the history
  • Loading branch information
ogolberg authored Dec 18, 2023
1 parent d2c9edb commit a632015
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ExpediterPlugin : Plugin<Project> {

ignore = extension.ignoreSpec.buildIgnore()

ignoreFile = extension.ignoreSpec.file?.let(project::file)
ignoreFiles.from(extension.ignoreSpec.files)

report = project.layout.buildDirectory.file("expediter.json").get().asFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
Expand Down Expand Up @@ -94,10 +93,9 @@ abstract class ExpediterTask : DefaultTask() {
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val typeDescriptors: ConfigurableFileCollection

@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
@Optional
var ignoreFile: File? = null
@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val ignoreFiles: ConfigurableFileCollection

@Input
var failOnIssues: Boolean = false
Expand Down Expand Up @@ -136,11 +134,11 @@ abstract class ExpediterTask : DefaultTask() {
providers.add(PlatformClassloaderTypeProvider)
}

val ignores = ignoreFile?.let {
val ignores = ignoreFiles.flatMap {
it.inputStream().buffered().use {
IssueReport.fromJson(it)
}.issues.toSet()
} ?: setOf()
IssueReport.fromJson(it).issues
}
}.toSet()

val issues = Expediter(
ignore,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
package com.toasttab.expediter.gradle.config

import com.toasttab.expediter.ignore.Ignore
import org.slf4j.LoggerFactory

class IgnoreSpec {
companion object {
private val LOGGER = LoggerFactory.getLogger(PlatformSpec::class.java)
}

var file: Any? = null
set(value) {
LOGGER.warn("file property is deprecated, use the file function instead: ignore { file('path') }")
value?.let(files::add)
}

val files = mutableListOf<Any>()

val ignores = mutableListOf<Ignore>()

fun file(file: Any) {
files.add(file)
}

fun targetStartsWith(vararg partial: String) = or(Ignore.TargetStartsWith(*partial))

fun callerStartsWith(vararg partial: String) = or(Ignore.CallerStartsWith(*partial))
Expand Down

0 comments on commit a632015

Please sign in to comment.