Delete 193 bunch files
This commit is contained in:
-28
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||
import org.gradle.tooling.model.idea.IdeaModule
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension
|
||||
|
||||
// FIX ME WHEN BUNCH 193 REMOVED
|
||||
abstract class AbstractProjectResolverExtensionCompat : AbstractProjectResolverExtension() {
|
||||
override fun createModule(gradleModule: IdeaModule, projectDataNode: DataNode<ProjectData>): DataNode<ModuleData> {
|
||||
return super.createModule(gradleModule, projectDataNode).also {
|
||||
initializeModuleNode(gradleModule, it, projectDataNode)
|
||||
}
|
||||
}
|
||||
|
||||
// Inline after class remove
|
||||
abstract fun initializeModuleNode(
|
||||
gradleModule: IdeaModule,
|
||||
moduleDataNode: DataNode<ModuleData>,
|
||||
projectDataNode: DataNode<ProjectData>,
|
||||
)
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration
|
||||
|
||||
import com.intellij.util.Consumer
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension
|
||||
|
||||
// TODO: Now IDEA can provide filter from gutters only for Test task (JVM tests)
|
||||
// Need to create fake Test task to copy filters from it to custom non-JVM test task
|
||||
class KotlinNonJvmGutterConfigurator : AbstractProjectResolverExtension() {
|
||||
override fun enhanceTaskProcessing(taskNames: MutableList<String>, jvmParametersSetup: String?, initScriptConsumer: Consumer<String>) {
|
||||
initScriptConsumer.consume(
|
||||
//language=Gradle
|
||||
"""
|
||||
({
|
||||
if (org.gradle.util.GradleVersion.current() >= org.gradle.util.GradleVersion.version("4.0")) {
|
||||
Class kotlinTestClass = null
|
||||
try {
|
||||
kotlinTestClass = Class.forName("org.jetbrains.kotlin.gradle.tasks.KotlinTest")
|
||||
} catch (ClassNotFoundException ex) {
|
||||
// ignore, class not available
|
||||
}
|
||||
|
||||
if (kotlinTestClass != null) {
|
||||
gradle.afterProject { project ->
|
||||
// Test task should have some parameters
|
||||
// Create dummy task to consume outputs by Test task
|
||||
project.tasks.create("nonJvmTestIdeSupportDummy")
|
||||
|
||||
// IDEA now process filter parameters only for Test tasks
|
||||
project.tasks.create('nonJvmTestIdeSupport', Test) {
|
||||
testClassesDirs = project.tasks["nonJvmTestIdeSupportDummy"].outputs.files
|
||||
classpath = project.tasks["nonJvmTestIdeSupportDummy"].outputs.files
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
project.tasks.withType(kotlinTestClass) { Task task ->
|
||||
task.dependsOn('nonJvmTestIdeSupport')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gradle.taskGraph.beforeTask { Task task ->
|
||||
if (kotlinTestClass.isAssignableFrom(task.class)) {
|
||||
task.filter.includePatterns = task.project.tasks['nonJvmTestIdeSupport'].filter.includePatterns
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||
|
||||
import com.intellij.openapi.externalSystem.service.project.autoimport.AsyncFileChangeListenerBase
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
|
||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
||||
|
||||
fun addVfsListener(
|
||||
watcher: GradleScriptListener,
|
||||
buildRootsManager: GradleBuildRootsManager
|
||||
) {
|
||||
VirtualFileManager.getInstance().addAsyncFileListener(
|
||||
object : AsyncFileChangeListenerBase() {
|
||||
var fileChangesProcessor = watcher.fileChangesProcessor
|
||||
|
||||
override fun isRelevant(path: String): Boolean {
|
||||
return buildRootsManager.maybeAffectedGradleProjectFile(path)
|
||||
}
|
||||
|
||||
override fun updateFile(file: VirtualFile, event: VFileEvent) {
|
||||
fileChangesProcessor(event.path, file.timeStamp)
|
||||
}
|
||||
|
||||
// do nothing
|
||||
override fun prepareFileDeletion(file: VirtualFile) {}
|
||||
override fun apply() {}
|
||||
override fun reset() {
|
||||
fileChangesProcessor = watcher.fileChangesProcessor
|
||||
}
|
||||
},
|
||||
watcher.project
|
||||
)
|
||||
}
|
||||
-144
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||
|
||||
import com.intellij.notification.*
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.idea.KotlinIcons
|
||||
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
|
||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRoot
|
||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
||||
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
||||
import org.jetbrains.kotlin.psi.UserDataProperty
|
||||
import org.jetbrains.plugins.gradle.service.GradleInstallationManager
|
||||
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
|
||||
val scriptConfigurationsNeedToBeUpdatedBalloon
|
||||
get() = Registry.`is`("kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedBalloon", false)
|
||||
|
||||
fun runPartialGradleImportForAllRoots(project: Project) {
|
||||
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
||||
runPartialGradleImport(project, root)
|
||||
}
|
||||
}
|
||||
|
||||
fun runPartialGradleImport(project: Project, root: GradleBuildRoot) {
|
||||
if (root.isImportingInProgress()) return
|
||||
|
||||
ExternalSystemUtil.refreshProject(
|
||||
root.pathPrefix,
|
||||
ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
fun configurationsAreMissingRequestNeeded() = KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.193.text")
|
||||
fun getConfigurationsActionText() = KotlinIdeaGradleBundle.message("action.label.import.project")
|
||||
fun configurationsAreMissingRequestNeededHelp(): String? = null
|
||||
fun configurationsAreMissingAfterRequest(): String = KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.193.text")
|
||||
|
||||
fun autoReloadScriptConfigurations(project: Project, root: GradleBuildRoot): Boolean {
|
||||
return ExternalSystemApiUtil
|
||||
.getSettings(project, GradleConstants.SYSTEM_ID)
|
||||
.getLinkedProjectSettings(root.pathPrefix)
|
||||
?.isUseAutoImport ?: false
|
||||
}
|
||||
|
||||
private const val kotlinDslNotificationGroupId = "Gradle Kotlin DSL Scripts"
|
||||
private var Project.notificationPanel: ScriptConfigurationChangedNotification?
|
||||
by UserDataProperty<Project, ScriptConfigurationChangedNotification>(Key.create("load.script.configuration.panel"))
|
||||
|
||||
fun scriptConfigurationsNeedToBeUpdated(project: Project, file: VirtualFile) {
|
||||
if (!scriptConfigurationsNeedToBeUpdatedBalloon) return
|
||||
|
||||
val root = GradleBuildRootsManager.getInstance(project).getScriptInfo(file)?.buildRoot ?: return
|
||||
if (autoReloadScriptConfigurations(project, root)) {
|
||||
// import should be run automatically by Gradle plugin
|
||||
return
|
||||
}
|
||||
|
||||
val existingPanel = project.notificationPanel
|
||||
if (existingPanel != null) {
|
||||
return
|
||||
}
|
||||
|
||||
val notificationGroup = NotificationGroup.findRegisteredGroup(kotlinDslNotificationGroupId)
|
||||
if (notificationGroup == null) {
|
||||
NotificationsConfiguration.getNotificationsConfiguration().register(
|
||||
kotlinDslNotificationGroupId, NotificationDisplayType.STICKY_BALLOON, false
|
||||
)
|
||||
}
|
||||
|
||||
val notification = ScriptConfigurationChangedNotification(project)
|
||||
project.notificationPanel = notification
|
||||
notification.notify(project)
|
||||
}
|
||||
|
||||
fun scriptConfigurationsAreUpToDate(project: Project): Boolean {
|
||||
if (project.notificationPanel == null) return false
|
||||
project.notificationPanel?.expire()
|
||||
return true
|
||||
}
|
||||
|
||||
private class ScriptConfigurationChangedNotification(val project: Project) :
|
||||
Notification(
|
||||
kotlinDslNotificationGroupId,
|
||||
KotlinIcons.LOAD_SCRIPT_CONFIGURATION,
|
||||
KotlinIdeaGradleBundle.message("notification.title.script.configuration.has.been.changed"),
|
||||
null,
|
||||
KotlinIdeaGradleBundle.message("notification.text.script.configuration.has.been.changed"),
|
||||
NotificationType.INFORMATION,
|
||||
null
|
||||
) {
|
||||
|
||||
init {
|
||||
addAction(LoadConfigurationAction())
|
||||
addAction(NotificationAction.createSimple(KotlinIdeaGradleBundle.message("action.label.enable.auto.import")) {
|
||||
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
||||
val projectSettings = getGradleProjectSettings(project).find { it.externalProjectPath == root.pathPrefix }
|
||||
if (projectSettings != null) {
|
||||
projectSettings.isUseAutoImport = true
|
||||
}
|
||||
runPartialGradleImport(project, root)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun expire() {
|
||||
super.expire()
|
||||
|
||||
project.notificationPanel = null
|
||||
}
|
||||
|
||||
private class LoadConfigurationAction : AnAction(KotlinIdeaGradleBundle.message("action.label.import.project")) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
runPartialGradleImportForAllRoots(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getGradleVersion(project: Project, settings: GradleProjectSettings): String {
|
||||
// workaround for bug in settings.resolveGradleVersion().version (fixed in 201)
|
||||
return GradleInstallationManager.getGradleVersion(
|
||||
ServiceManager.getService(GradleInstallationManager::class.java)
|
||||
.getGradleHome(project, settings.externalProjectPath)?.path
|
||||
) ?: GradleVersion.current().version
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||
|
||||
import org.jetbrains.kotlin.scripting.definitions.ScriptCompilationConfigurationFromDefinition
|
||||
import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition
|
||||
import org.jetbrains.kotlin.scripting.resolve.KotlinScriptDefinitionFromAnnotatedTemplate
|
||||
import kotlin.script.experimental.api.*
|
||||
import kotlin.script.experimental.host.ScriptingHostConfiguration
|
||||
|
||||
class GradleKotlinScriptDefinitionWrapper(
|
||||
hostConfiguration: ScriptingHostConfiguration,
|
||||
legacyDefinition: KotlinScriptDefinitionFromAnnotatedTemplate,
|
||||
gradleVersion: String,
|
||||
defaultCompilerOptions: Iterable<String>
|
||||
) : ScriptDefinition.FromLegacy(hostConfiguration, legacyDefinition, defaultCompilerOptions) {
|
||||
override val compilationConfiguration by lazy {
|
||||
ScriptCompilationConfigurationFromDefinition(
|
||||
hostConfiguration,
|
||||
legacyDefinition
|
||||
).with {
|
||||
ScriptCompilationConfiguration.ide.acceptedLocations.put(listOf(ScriptAcceptedLocation.Project))
|
||||
}
|
||||
}
|
||||
|
||||
override val canAutoReloadScriptConfigurationsBeSwitchedOff = !kotlinDslScriptsModelImportSupported(gradleVersion)
|
||||
override val canDefinitionBeSwitchedOff: Boolean = false
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.scripting.gradle.importing
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||
import org.gradle.tooling.model.idea.IdeaProject
|
||||
import org.gradle.tooling.model.kotlin.dsl.KotlinDslScriptsModel
|
||||
import org.jetbrains.kotlin.gradle.KotlinDslScriptAdditionalTask
|
||||
import org.jetbrains.kotlin.gradle.KotlinDslScriptModelProvider
|
||||
import org.jetbrains.kotlin.idea.scripting.gradle.kotlinDslScriptsModelImportSupported
|
||||
import org.jetbrains.plugins.gradle.model.Build
|
||||
import org.jetbrains.plugins.gradle.model.ClassSetImportModelProvider
|
||||
import org.jetbrains.plugins.gradle.model.ProjectImportModelProvider
|
||||
|
||||
class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() {
|
||||
override fun requiresTaskRunning() = true
|
||||
|
||||
override fun getModelProvider() = KotlinDslScriptModelProvider()
|
||||
|
||||
override fun getProjectsLoadedModelProvider(): ProjectImportModelProvider? {
|
||||
return ClassSetImportModelProvider(
|
||||
emptySet(),
|
||||
setOf(KotlinDslScriptAdditionalTask::class.java)
|
||||
)
|
||||
}
|
||||
|
||||
override fun populateProjectExtraModels(gradleProject: IdeaProject, ideProject: DataNode<ProjectData>) {
|
||||
super.populateProjectExtraModels(gradleProject, ideProject)
|
||||
|
||||
populateBuildModels(resolverCtx.models.mainBuild, ideProject)
|
||||
|
||||
resolverCtx.models.includedBuilds.forEach { includedRoot ->
|
||||
populateBuildModels(includedRoot, ideProject)
|
||||
}
|
||||
}
|
||||
|
||||
private fun populateBuildModels(
|
||||
root: Build,
|
||||
ideProject: DataNode<ProjectData>
|
||||
) {
|
||||
root.projects.forEach {
|
||||
if (it.projectIdentifier.projectPath == ":") {
|
||||
if (kotlinDslScriptsModelImportSupported(resolverCtx.projectGradleVersion)) {
|
||||
resolverCtx.models.getModel(it, KotlinDslScriptsModel::class.java)?.let { model ->
|
||||
processScriptModel(resolverCtx, model, it.projectIdentifier.projectPath)
|
||||
}
|
||||
}
|
||||
|
||||
saveGradleBuildEnvironment(resolverCtx)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-233
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.idea.codeInsight.gradle;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.codehaus.groovy.runtime.typehandling.ShortTypeHandling;
|
||||
import org.gradle.tooling.BuildActionExecuter;
|
||||
import org.gradle.tooling.GradleConnector;
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.gradle.tooling.internal.consumer.DefaultGradleConnector;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.model.ClassSetProjectImportModelProvider;
|
||||
import org.jetbrains.plugins.gradle.model.ExternalProject;
|
||||
import org.jetbrains.plugins.gradle.model.ProjectImportAction;
|
||||
import org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper;
|
||||
import org.jetbrains.plugins.gradle.tooling.builder.ModelBuildScriptClasspathBuilderImpl;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assume.assumeThat;
|
||||
|
||||
// part of org.jetbrains.plugins.gradle.tooling.builder.AbstractModelBuilderTest
|
||||
@RunWith(value = Parameterized.class)
|
||||
public abstract class AbstractModelBuilderTest {
|
||||
|
||||
public static final Object[][] SUPPORTED_GRADLE_VERSIONS = {{"4.9"}, {"5.6.4"}, {"6.5.1"}};
|
||||
|
||||
private static final Pattern TEST_METHOD_NAME_PATTERN = Pattern.compile("(.*)\\[(\\d*: with Gradle-.*)\\]");
|
||||
|
||||
private static File ourTempDir;
|
||||
|
||||
@NotNull
|
||||
private final String gradleVersion;
|
||||
private File testDir;
|
||||
private ProjectImportAction.AllModels allModels;
|
||||
|
||||
@Rule public TestName name = new TestName();
|
||||
@Rule public VersionMatcherRule versionMatcherRule = new VersionMatcherRule();
|
||||
|
||||
public AbstractModelBuilderTest(@NotNull String gradleVersion) {
|
||||
this.gradleVersion = gradleVersion;
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name = "{index}: with Gradle-{0}")
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(SUPPORTED_GRADLE_VERSIONS);
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
assumeThat(gradleVersion, versionMatcherRule.getMatcher());
|
||||
|
||||
ensureTempDirCreated();
|
||||
|
||||
String methodName = name.getMethodName();
|
||||
Matcher m = TEST_METHOD_NAME_PATTERN.matcher(methodName);
|
||||
if (m.matches()) {
|
||||
methodName = m.group(1);
|
||||
}
|
||||
|
||||
testDir = new File(ourTempDir, methodName);
|
||||
FileUtil.ensureExists(testDir);
|
||||
|
||||
InputStream buildScriptStream = getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.DEFAULT_SCRIPT_NAME);
|
||||
try {
|
||||
FileUtil.writeToFile(
|
||||
new File(testDir, GradleConstants.DEFAULT_SCRIPT_NAME),
|
||||
FileUtil.loadTextAndClose(buildScriptStream)
|
||||
);
|
||||
}
|
||||
finally {
|
||||
StreamUtil.closeStream(buildScriptStream);
|
||||
}
|
||||
|
||||
InputStream settingsStream = getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.SETTINGS_FILE_NAME);
|
||||
try {
|
||||
if (settingsStream != null) {
|
||||
FileUtil.writeToFile(
|
||||
new File(testDir, GradleConstants.SETTINGS_FILE_NAME),
|
||||
FileUtil.loadTextAndClose(settingsStream)
|
||||
);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
StreamUtil.closeStream(settingsStream);
|
||||
}
|
||||
|
||||
GradleConnector connector = GradleConnector.newConnector();
|
||||
|
||||
URI distributionUri = new DistributionLocator().getDistributionFor(GradleVersion.version(gradleVersion));
|
||||
connector.useDistribution(distributionUri);
|
||||
connector.forProjectDirectory(testDir);
|
||||
int daemonMaxIdleTime = 10;
|
||||
try {
|
||||
daemonMaxIdleTime = Integer.parseInt(System.getProperty("gradleDaemonMaxIdleTime", "10"));
|
||||
}
|
||||
catch (NumberFormatException ignore) {
|
||||
}
|
||||
|
||||
((DefaultGradleConnector) connector).daemonMaxIdleTime(daemonMaxIdleTime, TimeUnit.SECONDS);
|
||||
ProjectConnection connection = connector.connect();
|
||||
|
||||
try {
|
||||
ProjectImportAction projectImportAction = new ProjectImportAction(false);
|
||||
projectImportAction.addProjectImportModelProvider(new ClassSetProjectImportModelProvider(getModels()));
|
||||
BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
|
||||
File initScript = GradleExecutionHelper.generateInitScript(false, getToolingExtensionClasses());
|
||||
assertNotNull(initScript);
|
||||
String jdkHome = IdeaTestUtil.requireRealJdkHome();
|
||||
buildActionExecutor.setJavaHome(new File(jdkHome));
|
||||
buildActionExecutor.setJvmArguments("-Xmx128m", "-XX:MaxPermSize=64m");
|
||||
buildActionExecutor
|
||||
.withArguments("--info", "--recompile-scripts", GradleConstants.INIT_SCRIPT_CMD_OPTION, initScript.getAbsolutePath());
|
||||
allModels = buildActionExecutor.run();
|
||||
assertNotNull(allModels);
|
||||
}
|
||||
finally {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<Class> getToolingExtensionClasses() {
|
||||
Set<Class> classes = ContainerUtil.<Class>set(
|
||||
ExternalProject.class,
|
||||
// gradle-tooling-extension-api jar
|
||||
ProjectImportAction.class,
|
||||
// gradle-tooling-extension-impl jar
|
||||
ModelBuildScriptClasspathBuilderImpl.class,
|
||||
Multimap.class,
|
||||
ShortTypeHandling.class
|
||||
);
|
||||
|
||||
ContainerUtil.addAllNotNull(classes, doGetToolingExtensionClasses());
|
||||
return classes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<Class> doGetToolingExtensionClasses() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (testDir != null) {
|
||||
FileUtil.delete(testDir);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Set<Class> getModels();
|
||||
|
||||
|
||||
private static void ensureTempDirCreated() throws IOException {
|
||||
if (ourTempDir != null) return;
|
||||
|
||||
ourTempDir = new File(FileUtil.getTempDirectory(), "gradleTests");
|
||||
FileUtil.delete(ourTempDir);
|
||||
FileUtil.ensureExists(ourTempDir);
|
||||
}
|
||||
|
||||
public static class DistributionLocator {
|
||||
private static final String RELEASE_REPOSITORY_ENV = "GRADLE_RELEASE_REPOSITORY";
|
||||
private static final String SNAPSHOT_REPOSITORY_ENV = "GRADLE_SNAPSHOT_REPOSITORY";
|
||||
private static final String GRADLE_RELEASE_REPO = "https://services.gradle.org/distributions";
|
||||
private static final String GRADLE_SNAPSHOT_REPO = "https://services.gradle.org/distributions-snapshots";
|
||||
|
||||
@NotNull private final String myReleaseRepoUrl;
|
||||
@NotNull private final String mySnapshotRepoUrl;
|
||||
|
||||
public DistributionLocator() {
|
||||
this(DistributionLocator.getRepoUrl(false), DistributionLocator.getRepoUrl(true));
|
||||
}
|
||||
|
||||
public DistributionLocator(@NotNull String releaseRepoUrl, @NotNull String snapshotRepoUrl) {
|
||||
myReleaseRepoUrl = releaseRepoUrl;
|
||||
mySnapshotRepoUrl = snapshotRepoUrl;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public URI getDistributionFor(@NotNull GradleVersion version) throws URISyntaxException {
|
||||
return getDistribution(getDistributionRepository(version), version, "gradle", "bin");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getDistributionRepository(@NotNull GradleVersion version) {
|
||||
return version.isSnapshot() ? mySnapshotRepoUrl : myReleaseRepoUrl;
|
||||
}
|
||||
|
||||
private static URI getDistribution(
|
||||
@NotNull String repositoryUrl,
|
||||
@NotNull GradleVersion version,
|
||||
@NotNull String archiveName,
|
||||
@NotNull String archiveClassifier
|
||||
) throws URISyntaxException {
|
||||
return new URI(String.format("%s/%s-%s-%s.zip", repositoryUrl, archiveName, version.getVersion(), archiveClassifier));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getRepoUrl(boolean isSnapshotUrl) {
|
||||
String envRepoUrl = System.getenv(isSnapshotUrl ? SNAPSHOT_REPOSITORY_ENV : RELEASE_REPOSITORY_ENV);
|
||||
if (envRepoUrl != null) return envRepoUrl;
|
||||
|
||||
return isSnapshotUrl ? GRADLE_SNAPSHOT_REPO : GRADLE_RELEASE_REPO;
|
||||
}
|
||||
}
|
||||
}
|
||||
-987
@@ -1,987 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.codeInsight.gradle
|
||||
|
||||
import com.intellij.openapi.application.Result
|
||||
import com.intellij.openapi.application.WriteAction
|
||||
import com.intellij.openapi.application.runReadAction
|
||||
import com.intellij.openapi.projectRoots.JavaSdk
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.OrderRootType
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.jps.model.java.JavaResourceRootType
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
|
||||
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.idea.caches.project.productionSourceInfo
|
||||
import org.jetbrains.kotlin.idea.caches.project.testSourceInfo
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinStatus
|
||||
import org.jetbrains.kotlin.idea.configuration.ModuleSourceRootMap
|
||||
import org.jetbrains.kotlin.idea.configuration.allConfigurators
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
||||
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinSdkType
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.util.getProjectJdkTableSafe
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.sdk
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.platform.js.isJs
|
||||
import org.jetbrains.kotlin.platform.isCommon
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions
|
||||
import org.junit.*
|
||||
import java.util.*
|
||||
|
||||
internal fun GradleImportingTestCase.facetSettings(moduleName: String) = KotlinFacet.get(getModule(moduleName))!!.configuration.settings
|
||||
|
||||
internal val GradleImportingTestCase.facetSettings: KotlinFacetSettings
|
||||
get() = facetSettings("project_main")
|
||||
|
||||
internal val GradleImportingTestCase.testFacetSettings: KotlinFacetSettings
|
||||
get() = facetSettings("project_test")
|
||||
|
||||
internal fun GradleImportingTestCase.getSourceRootInfos(moduleName: String): List<Pair<String, JpsModuleSourceRootType<*>>> {
|
||||
return ModuleRootManager.getInstance(getModule(moduleName)).contentEntries.flatMap {
|
||||
it.sourceFolders.map { it.url.replace(projectPath, "") to it.rootType }
|
||||
}
|
||||
}
|
||||
|
||||
class GradleFacetImportTest : GradleImportingTestCase() {
|
||||
|
||||
private fun assertSameKotlinSdks(vararg moduleNames: String) {
|
||||
val sdks = moduleNames.map { getModule(it).sdk!! }
|
||||
val refSdk = sdks.firstOrNull() ?: return
|
||||
Assert.assertTrue(refSdk.sdkType is KotlinSdkType)
|
||||
Assert.assertTrue(sdks.all { it === refSdk })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmImport() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceLanguageVersion)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceApiVersion)
|
||||
Assert.assertEquals(JvmPlatforms.jvm18, targetPlatform)
|
||||
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmp -Xsingle-module",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
with(testFacetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceLanguageVersion)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceApiVersion)
|
||||
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
|
||||
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmpTest",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
assertAllModulesConfigured()
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/kotlin" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/resources" to JavaResourceRootType.RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/kotlin" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/resources" to JavaResourceRootType.TEST_RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmImportWithPlugin() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmImport_1_1_2() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
|
||||
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmp -Xsingle-module",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
with(testFacetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
|
||||
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmpTest",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/kotlin" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/resources" to JavaResourceRootType.RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/kotlin" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/resources" to JavaResourceRootType.TEST_RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmImportWithCustomSourceSets() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings("project_myMain")) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm18, targetPlatform)
|
||||
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmp -Xsingle-module",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
with(facetSettings("project_myTest")) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
|
||||
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmpTest",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
assertAllModulesConfigured()
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/kotlin" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/resources" to JavaResourceRootType.RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/kotlin" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/resources" to JavaResourceRootType.TEST_RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmImportWithCustomSourceSets_1_1_2() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings("project_myMain")) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm18, targetPlatform)
|
||||
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmp -Xsingle-module",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
with(facetSettings("project_myTest")) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
|
||||
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files -Xdump-declarations-to=tmpTest",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/kotlin" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/resources" to JavaResourceRootType.RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/kotlin" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/resources" to JavaResourceRootType.TEST_RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCoroutineImportByOptions() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCoroutineImportByProperties() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals(LanguageFeature.State.ENABLED, coroutineSupport)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsImport() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceLanguageVersion)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceApiVersion)
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
with(compilerArguments as K2JSCompilerArguments) {
|
||||
Assert.assertEquals(true, sourceMap)
|
||||
Assert.assertEquals("plain", moduleKind)
|
||||
}
|
||||
Assert.assertEquals(
|
||||
"-main callMain",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
with(testFacetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceLanguageVersion)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceApiVersion)
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
with(compilerArguments as K2JSCompilerArguments) {
|
||||
Assert.assertEquals(false, sourceMap)
|
||||
Assert.assertEquals("umd", moduleKind)
|
||||
}
|
||||
Assert.assertEquals(
|
||||
"-main callTest",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
val rootManager = ModuleRootManager.getInstance(getModule("project_main"))
|
||||
val stdlib = rootManager.orderEntries.filterIsInstance<LibraryOrderEntry>().single { it.libraryName?.contains("js") ?: false }.library
|
||||
assertEquals(JSLibraryKind, (stdlib as LibraryEx).kind)
|
||||
assertTrue(stdlib.getFiles(OrderRootType.CLASSES).isNotEmpty())
|
||||
|
||||
assertSameKotlinSdks("project_main", "project_test")
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/kotlin" to SourceKotlinRootType,
|
||||
"file:///src/main/resources" to ResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/kotlin" to TestSourceKotlinRootType,
|
||||
"file:///src/test/resources" to TestResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsImportTransitive() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
}
|
||||
|
||||
val rootManager = ModuleRootManager.getInstance(getModule("project_main"))
|
||||
val stdlib = rootManager.orderEntries
|
||||
.filterIsInstance<LibraryOrderEntry>()
|
||||
.map { it.library as LibraryEx }
|
||||
.first { "kotlin-stdlib-js" in it.name!! }
|
||||
assertEquals(JSLibraryKind, stdlib.kind)
|
||||
|
||||
assertAllModulesConfigured()
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/kotlin" to SourceKotlinRootType,
|
||||
"file:///src/main/resources" to ResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/kotlin" to TestSourceKotlinRootType,
|
||||
"file:///src/test/resources" to TestResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsImportWithCustomSourceSets() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings("project_myMain")) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
with(compilerArguments as K2JSCompilerArguments) {
|
||||
Assert.assertEquals(true, sourceMap)
|
||||
Assert.assertEquals("plain", moduleKind)
|
||||
}
|
||||
Assert.assertEquals(
|
||||
"-main callMain",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
with(facetSettings("project_myTest")) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
with(compilerArguments as K2JSCompilerArguments) {
|
||||
Assert.assertEquals(false, sourceMap)
|
||||
Assert.assertEquals("umd", moduleKind)
|
||||
}
|
||||
Assert.assertEquals(
|
||||
"-main callTest",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
}
|
||||
|
||||
assertAllModulesConfigured()
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/kotlin" to SourceKotlinRootType,
|
||||
"file:///src/main/resources" to ResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/kotlin" to TestSourceKotlinRootType,
|
||||
"file:///src/test/resources" to TestResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDetectOldJsStdlib() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmImportByPlatformPlugin() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
|
||||
}
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/kotlin" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/resources" to JavaResourceRootType.RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/kotlin" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/resources" to JavaResourceRootType.TEST_RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsImportByPlatformPlugin() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
}
|
||||
|
||||
val rootManager = ModuleRootManager.getInstance(getModule("project_main"))
|
||||
val libraries = rootManager.orderEntries.filterIsInstance<LibraryOrderEntry>().mapNotNull { it.library as LibraryEx }
|
||||
assertEquals(JSLibraryKind, libraries.single { it.name?.contains("kotlin-stdlib-js") == true }.kind)
|
||||
assertEquals(CommonLibraryKind, libraries.single { it.name?.contains("kotlin-stdlib-common") == true }.kind)
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/kotlin" to SourceKotlinRootType,
|
||||
"file:///src/main/resources" to ResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/kotlin" to TestSourceKotlinRootType,
|
||||
"file:///src/test/resources" to TestResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("4.9")
|
||||
fun testCommonImportByPlatformPlugin() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.1", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.1", apiLevel!!.versionString)
|
||||
Assert.assertTrue(targetPlatform.isCommon())
|
||||
}
|
||||
|
||||
val rootManager = ModuleRootManager.getInstance(getModule("project_main"))
|
||||
val stdlib = rootManager.orderEntries.filterIsInstance<LibraryOrderEntry>().single().library
|
||||
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to SourceKotlinRootType,
|
||||
"file:///src/main/kotlin" to SourceKotlinRootType,
|
||||
"file:///src/main/resources" to ResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to TestSourceKotlinRootType,
|
||||
"file:///src/test/kotlin" to TestSourceKotlinRootType,
|
||||
"file:///src/test/resources" to TestResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmImportByKotlinPlugin() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
|
||||
}
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/kotlin" to JavaSourceRootType.SOURCE,
|
||||
"file:///src/main/resources" to JavaResourceRootType.RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/kotlin" to JavaSourceRootType.TEST_SOURCE,
|
||||
"file:///src/test/resources" to JavaResourceRootType.TEST_RESOURCE
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsImportByKotlin2JsPlugin() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
}
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/kotlin" to SourceKotlinRootType,
|
||||
"file:///src/main/resources" to ResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/kotlin" to TestSourceKotlinRootType,
|
||||
"file:///src/test/resources" to TestResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testArgumentEscaping() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals(
|
||||
listOf("-Xallow-no-source-files", "-Xbuild-file=module with spaces"),
|
||||
compilerSettings!!.additionalArgumentsAsList
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoPluginsInAdditionalArgs() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals(
|
||||
"-version",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.stereotype.Component",
|
||||
"plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.transaction.annotation.Transactional",
|
||||
"plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.scheduling.annotation.Async",
|
||||
"plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.cache.annotation.Cacheable",
|
||||
"plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.boot.test.context.SpringBootTest",
|
||||
"plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.validation.annotation.Validated"
|
||||
),
|
||||
compilerArguments!!.pluginOptions!!.toList()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoArgInvokeInitializers() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals(
|
||||
"-version",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"plugin:org.jetbrains.kotlin.noarg:annotation=NoArg",
|
||||
"plugin:org.jetbrains.kotlin.noarg:invokeInitializers=true"
|
||||
),
|
||||
compilerArguments!!.pluginOptions!!.toList()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAndroidGradleJsDetection() {
|
||||
configureByFiles()
|
||||
createProjectSubFile(
|
||||
"local.properties", """
|
||||
sdk.dir=/${KotlinTestUtils.getAndroidSdkSystemIndependentPath()}
|
||||
"""
|
||||
)
|
||||
importProject()
|
||||
|
||||
with(facetSettings("js-module")) {
|
||||
Assert.assertTrue(targetPlatform.isJs())
|
||||
}
|
||||
|
||||
val rootManager = ModuleRootManager.getInstance(getModule("js-module"))
|
||||
val stdlib = rootManager
|
||||
.orderEntries
|
||||
.filterIsInstance<LibraryOrderEntry>()
|
||||
.first { it.libraryName?.startsWith("Gradle: kotlin-stdlib-js-") ?: false }
|
||||
.library!!
|
||||
assertTrue(stdlib.getFiles(OrderRootType.CLASSES).isNotEmpty())
|
||||
assertEquals(JSLibraryKind, (stdlib as LibraryEx).kind)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinAndroidPluginDetection() {
|
||||
configureByFiles()
|
||||
createProjectSubFile(
|
||||
"local.properties", """
|
||||
sdk.dir=/${KotlinTestUtils.getAndroidSdkSystemIndependentPath()}
|
||||
"""
|
||||
)
|
||||
importProject()
|
||||
|
||||
val kotlinFacet = KotlinFacet.get(getModule("project"))!!
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoFacetInModuleWithoutKotlinPlugin() {
|
||||
configureByFiles()
|
||||
|
||||
importProject()
|
||||
|
||||
Assert.assertNotNull(KotlinFacet.get(getModule("gr01_main")))
|
||||
Assert.assertNotNull(KotlinFacet.get(getModule("gr01_test")))
|
||||
Assert.assertNull(KotlinFacet.get(getModule("m1_main")))
|
||||
Assert.assertNull(KotlinFacet.get(getModule("m1_test")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClasspathWithDependenciesImport() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("tmp.jar", (compilerArguments as K2JVMCompilerArguments).classpath)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDependenciesClasspathImport() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals(null, (compilerArguments as K2JVMCompilerArguments).classpath)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJDKImport() {
|
||||
object : WriteAction<Unit>() {
|
||||
override fun run(result: Result<Unit>) {
|
||||
val jdk = JavaSdk.getInstance().createJdk("myJDK", "my/path/to/jdk")
|
||||
getProjectJdkTableSafe().addJdk(jdk)
|
||||
}
|
||||
}.execute()
|
||||
|
||||
try {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
val moduleSDK = ModuleRootManager.getInstance(getModule("project_main")).sdk!!
|
||||
Assert.assertTrue(moduleSDK.sdkType is JavaSdk)
|
||||
Assert.assertEquals("myJDK", moduleSDK.name)
|
||||
Assert.assertEquals("my/path/to/jdk", moduleSDK.homePath)
|
||||
} finally {
|
||||
object : WriteAction<Unit>() {
|
||||
override fun run(result: Result<Unit>) {
|
||||
val jdkTable = getProjectJdkTableSafe()
|
||||
jdkTable.removeJdk(jdkTable.findJdk("myJDK")!!)
|
||||
}
|
||||
}.execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testImplementsDependency() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
Assert.assertEquals(listOf("MultiTest_main"), facetSettings("MultiTest-jvm_main").implementedModuleNames)
|
||||
Assert.assertEquals(listOf("MultiTest_test"), facetSettings("MultiTest-jvm_test").implementedModuleNames)
|
||||
Assert.assertEquals(listOf("MultiTest_main"), facetSettings("MultiTest-js_main").implementedModuleNames)
|
||||
Assert.assertEquals(listOf("MultiTest_test"), facetSettings("MultiTest-js_test").implementedModuleNames)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testImplementsDependencyWithCustomSourceSets() {
|
||||
configureByFiles()
|
||||
|
||||
importProject()
|
||||
|
||||
Assert.assertEquals(listOf("MultiTest_myMain"), facetSettings("MultiTest-jvm_myMain").implementedModuleNames)
|
||||
Assert.assertEquals(listOf("MultiTest_myTest"), facetSettings("MultiTest-jvm_myTest").implementedModuleNames)
|
||||
Assert.assertEquals(listOf("MultiTest_myMain"), facetSettings("MultiTest-js_myMain").implementedModuleNames)
|
||||
Assert.assertEquals(listOf("MultiTest_myTest"), facetSettings("MultiTest-js_myTest").implementedModuleNames)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAPIVersionExceedingLanguageVersion() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
}
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIgnoreProjectLanguageAndAPIVersion() {
|
||||
KotlinCommonCompilerArgumentsHolder.getInstance(myProject).update {
|
||||
languageVersion = "1.0"
|
||||
apiVersion = "1.0"
|
||||
}
|
||||
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.3", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.3", apiLevel!!.versionString)
|
||||
}
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCommonArgumentsImport() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals("1.1", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceLanguageVersion)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceApiVersion)
|
||||
Assert.assertTrue(targetPlatform.isCommon())
|
||||
Assert.assertEquals("my/classpath", (compilerArguments as K2MetadataCompilerArguments).classpath)
|
||||
Assert.assertEquals("my/destination", (compilerArguments as K2MetadataCompilerArguments).destination)
|
||||
}
|
||||
|
||||
with(facetSettings("project_test")) {
|
||||
Assert.assertEquals("1.1", languageLevel!!.versionString)
|
||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceLanguageVersion)
|
||||
Assert.assertFalse(compilerArguments!!.autoAdvanceApiVersion)
|
||||
Assert.assertTrue(targetPlatform.isCommon())
|
||||
Assert.assertEquals("my/test/classpath", (compilerArguments as K2MetadataCompilerArguments).classpath)
|
||||
Assert.assertEquals("my/test/destination", (compilerArguments as K2MetadataCompilerArguments).destination)
|
||||
}
|
||||
|
||||
val rootManager = ModuleRootManager.getInstance(getModule("project_main"))
|
||||
val stdlib = rootManager.orderEntries.filterIsInstance<LibraryOrderEntry>().single().library
|
||||
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
|
||||
|
||||
assertSameKotlinSdks("project_main", "project_test")
|
||||
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/main/java" to SourceKotlinRootType,
|
||||
"file:///src/main/kotlin" to SourceKotlinRootType,
|
||||
"file:///src/main/resources" to ResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_main")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf(
|
||||
"file:///src/test/java" to TestSourceKotlinRootType,
|
||||
"file:///src/test/kotlin" to TestSourceKotlinRootType,
|
||||
"file:///src/test/resources" to TestResourceKotlinRootType
|
||||
),
|
||||
getSourceRootInfos("project_test")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInternalArgumentsFacetImporting() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
// Version is indeed 1.3
|
||||
Assert.assertEquals(LanguageVersion.KOTLIN_1_3, facetSettings.languageLevel)
|
||||
|
||||
// We haven't lost internal argument during importing to facet
|
||||
Assert.assertEquals("-Xallow-no-source-files -XXLanguage:+InlineClasses", facetSettings.compilerSettings?.additionalArguments)
|
||||
|
||||
// Inline classes are enabled even though LV = 1.3
|
||||
Assert.assertEquals(
|
||||
LanguageFeature.State.ENABLED,
|
||||
getModule("project_main").languageVersionSettings.getFeatureSupport(LanguageFeature.InlineClasses)
|
||||
)
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStableModuleNameWhileUsingGradleJS() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
checkStableModuleName("project_main", "project", JsPlatforms.defaultJsPlatform, isProduction = true)
|
||||
// Note "_test" suffix: this is current behavior of K2JS Compiler
|
||||
checkStableModuleName("project_test", "project_test", JsPlatforms.defaultJsPlatform, isProduction = false)
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStableModuleNameWhileUsingGradleJVM() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
checkStableModuleName("project_main", "project", JvmPlatforms.unspecifiedJvmPlatform, isProduction = true)
|
||||
checkStableModuleName("project_test", "project", JvmPlatforms.unspecifiedJvmPlatform, isProduction = false)
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoFriendPathsAreShown() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
Assert.assertEquals(
|
||||
"-Xallow-no-source-files",
|
||||
testFacetSettings.compilerSettings!!.additionalArguments
|
||||
)
|
||||
|
||||
assertAllModulesConfigured()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSharedLanguageVersion() {
|
||||
configureByFiles()
|
||||
|
||||
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||
|
||||
holder.update { languageVersion = "1.1" }
|
||||
|
||||
importProject()
|
||||
|
||||
TestCase.assertEquals("1.3", holder.settings.languageVersion)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNonSharedLanguageVersion() {
|
||||
configureByFiles()
|
||||
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||
|
||||
holder.update { languageVersion = "1.1" }
|
||||
|
||||
importProject()
|
||||
|
||||
TestCase.assertEquals("1.1", holder.settings.languageVersion)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testImportCompilerArgumentsWithInvalidDependencies() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
with(facetSettings("project_main")) {
|
||||
Assert.assertEquals("1.8", (mergedCompilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun checkStableModuleName(projectName: String, expectedName: String, platform: TargetPlatform, isProduction: Boolean) {
|
||||
val module = getModule(projectName)
|
||||
val moduleInfo = if (isProduction) module.productionSourceInfo() else module.testSourceInfo()
|
||||
|
||||
val resolutionFacade = KotlinCacheService.getInstance(myProject).getResolutionFacadeByModuleInfo(moduleInfo!!, platform)!!
|
||||
val moduleDescriptor = resolutionFacade.moduleDescriptor
|
||||
|
||||
Assert.assertEquals("<$expectedName>", moduleDescriptor.stableName?.asString())
|
||||
}
|
||||
|
||||
private fun assertAllModulesConfigured() {
|
||||
runReadAction {
|
||||
for (moduleGroup in ModuleSourceRootMap(myProject).groupByBaseModules(myProject.allModules())) {
|
||||
val configurator = allConfigurators().find {
|
||||
it.getStatus(moduleGroup) == ConfigureKotlinStatus.CAN_BE_CONFIGURED
|
||||
}
|
||||
Assert.assertNull("Configurator $configurator tells that ${moduleGroup.baseModule} can be configured", configurator)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun importProject() {
|
||||
val isCreateEmptyContentRootDirectories = currentExternalProjectSettings.isCreateEmptyContentRootDirectories
|
||||
try {
|
||||
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = true
|
||||
super.importProject()
|
||||
} finally {
|
||||
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = isCreateEmptyContentRootDirectories
|
||||
}
|
||||
}
|
||||
|
||||
override fun testDataDirName(): String {
|
||||
return "gradleFacetImportTest"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user