Set default jvmTarget when configuring Kotlin with Maven
This commit is contained in:
@@ -298,6 +298,17 @@ class PomFile private constructor(val xmlFile: XmlFile, val domModel: MavenDomPr
|
|||||||
return configurationTag.add(newTag) as XmlTag
|
return configurationTag.add(newTag) as XmlTag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addPluginConfiguration(plugin: MavenDomPlugin, optionName: String, optionValue: String) {
|
||||||
|
val configurationTag = plugin.configuration.ensureTagExists()
|
||||||
|
val existingTag = configurationTag.findFirstSubTag(optionName)
|
||||||
|
if (existingTag != null) {
|
||||||
|
existingTag.value.text = optionValue
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
configurationTag.add(configurationTag.createChildTag(optionName, optionValue))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun addPluginRepository(id: String, name: String, url: String, snapshots: Boolean = false, releases: Boolean = true): MavenDomRepository {
|
fun addPluginRepository(id: String, name: String, url: String, snapshots: Boolean = false, releases: Boolean = true): MavenDomRepository {
|
||||||
ensurePluginRepositories()
|
ensurePluginRepositories()
|
||||||
|
|
||||||
|
|||||||
+9
@@ -21,6 +21,7 @@ import com.intellij.openapi.roots.ModuleRootManager
|
|||||||
import org.jetbrains.idea.maven.dom.model.MavenDomPlugin
|
import org.jetbrains.idea.maven.dom.model.MavenDomPlugin
|
||||||
import org.jetbrains.kotlin.idea.configuration.hasKotlinJvmRuntimeInScope
|
import org.jetbrains.kotlin.idea.configuration.hasKotlinJvmRuntimeInScope
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
|
import org.jetbrains.kotlin.idea.versions.getDefaultJvmTarget
|
||||||
import org.jetbrains.kotlin.idea.versions.getStdlibArtifactId
|
import org.jetbrains.kotlin.idea.versions.getStdlibArtifactId
|
||||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||||
@@ -44,6 +45,14 @@ class KotlinJavaMavenConfigurator : KotlinMavenConfigurator(KotlinJavaMavenConfi
|
|||||||
createExecution(pomFile, kotlinPlugin, PomFile.DefaultPhases.TestCompile, PomFile.KotlinGoals.TestCompile, module, true)
|
createExecution(pomFile, kotlinPlugin, PomFile.DefaultPhases.TestCompile, PomFile.KotlinGoals.TestCompile, module, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun configurePlugin(pom: PomFile, plugin: MavenDomPlugin, module: Module, version: String) {
|
||||||
|
val sdk = ModuleRootManager.getInstance(module).sdk
|
||||||
|
val jvmTarget = getDefaultJvmTarget(sdk, version)
|
||||||
|
if (jvmTarget != null) {
|
||||||
|
pom.addPluginConfiguration(plugin, "jvmTarget", jvmTarget.description)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override val targetPlatform: TargetPlatform
|
override val targetPlatform: TargetPlatform
|
||||||
get() = JvmPlatform
|
get() = JvmPlatform
|
||||||
|
|
||||||
|
|||||||
+5
@@ -160,11 +160,16 @@ abstract class KotlinMavenConfigurator
|
|||||||
val plugin = pom.addPlugin(MavenId(GROUP_ID, MAVEN_PLUGIN_ID, "\${$KOTLIN_VERSION_PROPERTY}"))
|
val plugin = pom.addPlugin(MavenId(GROUP_ID, MAVEN_PLUGIN_ID, "\${$KOTLIN_VERSION_PROPERTY}"))
|
||||||
createExecutions(pom, plugin, module)
|
createExecutions(pom, plugin, module)
|
||||||
|
|
||||||
|
configurePlugin(pom, plugin, module, version)
|
||||||
|
|
||||||
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement<PsiFile>(file)
|
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement<PsiFile>(file)
|
||||||
|
|
||||||
collector.addMessage(virtualFile.path + " was modified")
|
collector.addMessage(virtualFile.path + " was modified")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun configurePlugin(pom: PomFile, plugin: MavenDomPlugin, module: Module, version: String) {
|
||||||
|
}
|
||||||
|
|
||||||
protected fun createExecution(
|
protected fun createExecution(
|
||||||
pomFile: PomFile,
|
pomFile: PomFile,
|
||||||
kotlinPlugin: MavenDomPlugin,
|
kotlinPlugin: MavenDomPlugin,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jre7</artifactId>
|
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -48,6 +48,9 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
@@ -40,7 +43,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jre7</artifactId>
|
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jre7</artifactId>
|
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -47,6 +47,9 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jre7</artifactId>
|
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -49,6 +49,9 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jre7</artifactId>
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jre7</artifactId>
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+4
-1
@@ -15,7 +15,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jre7</artifactId>
|
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -77,6 +77,9 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
Reference in New Issue
Block a user