Skip to content

Commit

Permalink
[maven] IDEA-255308 MavenProject.compilerConfigsOrPluginConfig
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 7408397d68e48ee3763671ca19b4490a6196751f
  • Loading branch information
Dmitry Kichinsky authored and intellij-monorepo-bot committed Jan 22, 2025
1 parent eadb03d commit 75f7bbf
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ object MavenImportUtil {
}

private fun getCompilerLevel(level: String): LanguageLevel? {
val configs = if (isTest) mavenProject.testCompilerConfigs else mavenProject.compilerConfigs
val configs = if (isTest) mavenProject.testCompilerConfigs else mavenProject.compilerConfigs + mavenProject.pluginConfig
val fallbackProperty = "maven.compiler.$level"
val levels = configs.mapNotNull { LanguageLevel.parse(findChildValueByPath(it, level)) }
val maxLevel = levels.maxWithOrNull(Comparator.naturalOrder())?.toJavaVersion()?.toFeatureString()
Expand Down Expand Up @@ -380,18 +380,23 @@ object MavenImportUtil {

internal val MavenProject.declaredAnnotationProcessors: List<String>
get() {
return compilerConfigs.flatMap { getDeclaredAnnotationProcessors(it) }
return compilerConfigsOrPluginConfig.flatMap { getDeclaredAnnotationProcessors(it) }
}

private val MavenProject.compilerConfigs: List<Element>
private val MavenProject.compilerConfigsOrPluginConfig: List<Element>
get() {
val configurations: List<Element> = compileExecutionConfigurations
val configurations: List<Element> = compilerConfigs
if (!configurations.isEmpty()) return configurations
return pluginConfig
}

private val MavenProject.pluginConfig: List<Element>
get() {
val configuration: Element? = getPluginConfiguration(COMPILER_PLUGIN_GROUP_ID, COMPILER_PLUGIN_ARTIFACT_ID)
return ContainerUtil.createMaybeSingletonList(configuration)
}

private val MavenProject.compileExecutionConfigurations: List<Element>
private val MavenProject.compilerConfigs: List<Element>
get() {
val plugin = findCompilerPlugin()
if (plugin == null) return emptyList()
Expand Down

0 comments on commit 75f7bbf

Please sign in to comment.