Skip to content

Commit

Permalink
fix(diktat-maven-plugin): Maven projects with non local parent POM (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
agebhar1 authored Mar 25, 2024
1 parent 8d61ddf commit 56d1632
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ abstract class DiktatBaseMojo : AbstractMojo() {
if (excludes.isNotEmpty()) " and excluding $excludes" else ""
)

val sourceRootDir = generateSequence(mavenProject) { it.parent }.last().basedir.toPath()
val sourceRootDir = getSourceRootDirTransitive()
val reporters: List<Reporter> = (reporters?.getAll() ?: listOf(PlainReporter()))
.let { all ->
if (githubActions && all.filterIsInstance<GitHubActionsReporter>().isEmpty()) {
Expand Down Expand Up @@ -138,6 +138,13 @@ abstract class DiktatBaseMojo : AbstractMojo() {
.firstOrNull { it.isRegularFile() }
}

private fun getSourceRootDirTransitive(): Path = generateSequence(mavenProject) { project ->
val parent = project.parent
parent?.basedir?.let {
parent
}
}.last().basedir.toPath()

private fun files(): List<Path> {
val (excludedDirs, excludedFiles) = excludes.map(::File).partition { it.isDirectory }
return inputs
Expand Down

0 comments on commit 56d1632

Please sign in to comment.