From fc8e28583b971f30f06baa40c21327832e1c5d0a Mon Sep 17 00:00:00 2001 From: Piotr Rogacki Date: Thu, 18 May 2023 14:34:48 +0200 Subject: [PATCH] Fix resolving package pom --- .../gradle/aem/common/mvn/ModuleResolver.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/cognifide/gradle/aem/common/mvn/ModuleResolver.kt b/src/main/kotlin/com/cognifide/gradle/aem/common/mvn/ModuleResolver.kt index df8659ced..702bd4bc8 100644 --- a/src/main/kotlin/com/cognifide/gradle/aem/common/mvn/ModuleResolver.kt +++ b/src/main/kotlin/com/cognifide/gradle/aem/common/mvn/ModuleResolver.kt @@ -101,7 +101,7 @@ class ModuleResolver(val build: MvnBuild) { fun isPackage(pom: File) = pom.parentFile.resolve(build.contentPath.get()).exists() || pom.readText().let { text -> text.contains("content-package") || packagePlugins.get().any { - text.substringBetweenTag("build").substringBetweenTag("plugins").contains("$it") + text.substringBetweenTag("build").ignoreTag("pluginManagement").substringBetweenTag("plugins").contains("$it") } } @@ -115,4 +115,17 @@ class ModuleResolver(val build: MvnBuild) { private fun String.containsTag(tag: String) = this.contains("<$tag>") && this.contains("") private fun String.substringBetweenTag(tag: String) = this.substringAfter("<$tag>").substringBefore("") + + private fun String.ignoreTag(tag: String): String { + val startTag = "<$tag>" + val endTag = "" + + val startIndex = indexOf(startTag) + val endIndex = indexOf(endTag, startIndex + startTag.length) + + if (startIndex != -1 && endIndex != -1) + return substring(0, startIndex) + substring(endIndex + endTag.length) + + return this + } }