Skip to content

Commit

Permalink
Adds support for compiler flags in maven projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Kordyjan committed Oct 23, 2018
1 parent 9766db4 commit b27327b
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jetbrains.kotlin.maven.configuration

import org.apache.maven.model.Plugin
import org.apache.maven.project.MavenProject
import org.codehaus.plexus.util.xml.Xpp3Dom
import org.eclipse.core.resources.ProjectScope
import org.eclipse.core.runtime.IProgressMonitor
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator
Expand Down Expand Up @@ -56,9 +57,14 @@ class KotlinMavenProjectConfigurator : AbstractSourcesGenerationProjectConfigura
compilerProperties.jvmTarget = JvmTarget.fromString(it) ?: JvmTarget.DEFAULT
}

getCompilerFlags(plugin.configuration)?.also {
compilerProperties.compilerFlags = it
configurationChanged = true
}

configureProperty(propertyPath = "kotlin.code.style", isChangingConfiguration = false) { alias ->
KotlinCodeStyleManager.buildsystemAliases[alias]?.let {
with (KotlinCodeStyleProperties(ProjectScope(request.project))) {
with(KotlinCodeStyleProperties(ProjectScope(request.project))) {
codeStyleId = it
globalsOverridden = true
saveChanges()
Expand All @@ -82,6 +88,15 @@ class KotlinMavenProjectConfigurator : AbstractSourcesGenerationProjectConfigura
}
}

private fun getCompilerFlags(configuration: Any): String? =
(configuration as? Xpp3Dom)
?.getChild("args")
?.children
?.filter { it.name == "arg" }
?.map { it.value }
?.takeIf { it.isNotEmpty() }
?.joinToString(separator = " ")

private fun hasKotlinMavenPlugin(mavenProject: MavenProject): Boolean =
mavenProject.buildPlugins.any { checkCoordinates(it, GROUP_ID, MAVEN_PLUGIN_ID) }

Expand Down

0 comments on commit b27327b

Please sign in to comment.