Configuration: Use project-level JVM target when facet is absent
#KT-17722 Fixed
This commit is contained in:
@@ -25,8 +25,10 @@ import com.intellij.openapi.roots.ProjectFileIndex
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.Argument
|
import org.jetbrains.kotlin.cli.common.arguments.Argument
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.*
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
|
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JvmCompilerArgumentsHolder
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettings
|
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettings
|
||||||
import org.jetbrains.kotlin.idea.facet.getLibraryLanguageLevel
|
import org.jetbrains.kotlin.idea.facet.getLibraryLanguageLevel
|
||||||
@@ -113,7 +115,14 @@ val Module.languageVersionSettings: LanguageVersionSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
val Module.targetPlatform: TargetPlatformKind<*>?
|
val Module.targetPlatform: TargetPlatformKind<*>?
|
||||||
get() = KotlinFacetSettingsProvider.getInstance(project).getSettings(this)?.targetPlatformKind
|
get() = KotlinFacetSettingsProvider.getInstance(project).getSettings(this)?.targetPlatformKind ?: project.targetPlatform
|
||||||
|
|
||||||
|
val Project.targetPlatform: TargetPlatformKind<*>?
|
||||||
|
get() {
|
||||||
|
val jvmTarget = Kotlin2JvmCompilerArgumentsHolder.getInstance(this).settings.jvmTarget ?: return null
|
||||||
|
val version = JvmTarget.fromString(jvmTarget) ?: return null
|
||||||
|
return TargetPlatformKind.Jvm[version]
|
||||||
|
}
|
||||||
|
|
||||||
private val Module.implementsCommonModule: Boolean
|
private val Module.implementsCommonModule: Boolean
|
||||||
get() = targetPlatform != TargetPlatformKind.Common
|
get() = targetPlatform != TargetPlatformKind.Common
|
||||||
|
|||||||
BIN
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="KotlinJavaRuntime (2)" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<resourceExtensions />
|
||||||
|
<wildcardResourcePatterns>
|
||||||
|
<entry name="!?*.java" />
|
||||||
|
<entry name="!?*.form" />
|
||||||
|
<entry name="!?*.class" />
|
||||||
|
<entry name="!?*.groovy" />
|
||||||
|
<entry name="!?*.scala" />
|
||||||
|
<entry name="!?*.flex" />
|
||||||
|
<entry name="!?*.kt" />
|
||||||
|
<entry name="!?*.clj" />
|
||||||
|
<entry name="!?*.aj" />
|
||||||
|
</wildcardResourcePatterns>
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
<component name="CopyrightManager" default="" />
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="KotlinJavaRuntime (2)">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../mockRuntime11/kotlin-runtime.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
|
<component name="Kotlin2JvmCompilerArguments">
|
||||||
|
<option name="jvmTarget" value="1.8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -259,4 +259,8 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
|||||||
public void testJvm6InProjectJvm8InModule() {
|
public void testJvm6InProjectJvm8InModule() {
|
||||||
configureFacetAndCheckJvm(JvmTarget.JVM_1_8);
|
configureFacetAndCheckJvm(JvmTarget.JVM_1_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testProjectWithoutFacetWithJvmTarget18() {
|
||||||
|
assertEquals(TargetPlatformKind.Jvm.Companion.get(JvmTarget.JVM_1_8), PlatformKt.getTargetPlatform(getModule()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user