Skip to content

Commit 56d1632

Browse files
authored
fix(diktat-maven-plugin): Maven projects with non local parent POM (#1924)
1 parent 8d61ddf commit 56d1632

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • diktat-maven-plugin/src/main/kotlin/com/saveourtool/diktat/plugin/maven

diktat-maven-plugin/src/main/kotlin/com/saveourtool/diktat/plugin/maven/DiktatBaseMojo.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ abstract class DiktatBaseMojo : AbstractMojo() {
9292
if (excludes.isNotEmpty()) " and excluding $excludes" else ""
9393
)
9494

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

141+
private fun getSourceRootDirTransitive(): Path = generateSequence(mavenProject) { project ->
142+
val parent = project.parent
143+
parent?.basedir?.let {
144+
parent
145+
}
146+
}.last().basedir.toPath()
147+
141148
private fun files(): List<Path> {
142149
val (excludedDirs, excludedFiles) = excludes.map(::File).partition { it.isDirectory }
143150
return inputs

0 commit comments

Comments
 (0)