From 56d1632cc5e6fe37598ffe0fd8d1473543403350 Mon Sep 17 00:00:00 2001 From: Andreas Gebhardt Date: Mon, 25 Mar 2024 09:58:10 +0100 Subject: [PATCH] fix(diktat-maven-plugin): Maven projects with non local parent POM (#1924) --- .../saveourtool/diktat/plugin/maven/DiktatBaseMojo.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/diktat-maven-plugin/src/main/kotlin/com/saveourtool/diktat/plugin/maven/DiktatBaseMojo.kt b/diktat-maven-plugin/src/main/kotlin/com/saveourtool/diktat/plugin/maven/DiktatBaseMojo.kt index 38411f0d39..50bd6131c2 100644 --- a/diktat-maven-plugin/src/main/kotlin/com/saveourtool/diktat/plugin/maven/DiktatBaseMojo.kt +++ b/diktat-maven-plugin/src/main/kotlin/com/saveourtool/diktat/plugin/maven/DiktatBaseMojo.kt @@ -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 = (reporters?.getAll() ?: listOf(PlainReporter())) .let { all -> if (githubActions && all.filterIsInstance().isEmpty()) { @@ -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 { val (excludedDirs, excludedFiles) = excludes.map(::File).partition { it.isDirectory } return inputs