Get rid of RuntimeLibraryFiles and its remaining uses
This commit is contained in:
@@ -53,16 +53,6 @@ open class KotlinJavaModuleConfigurator internal constructor() : KotlinWithLibra
|
|||||||
override val targetPlatform: TargetPlatform
|
override val targetPlatform: TargetPlatform
|
||||||
get() = JvmPlatform
|
get() = JvmPlatform
|
||||||
|
|
||||||
override val existingJarFiles: RuntimeLibraryFiles
|
|
||||||
get() {
|
|
||||||
val paths = PathUtil.getKotlinPathsForIdeaPlugin()
|
|
||||||
return RuntimeLibraryFiles(
|
|
||||||
assertFileExists(paths.stdlibPath),
|
|
||||||
assertFileExists(paths.reflectPath),
|
|
||||||
assertFileExists(paths.runtimeSourcesPath)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val libraryJarDescriptors: List<LibraryJarDescriptor>
|
override val libraryJarDescriptors: List<LibraryJarDescriptor>
|
||||||
get() = listOf(LibraryJarDescriptor.RUNTIME_JAR,
|
get() = listOf(LibraryJarDescriptor.RUNTIME_JAR,
|
||||||
LibraryJarDescriptor.REFLECT_JAR,
|
LibraryJarDescriptor.REFLECT_JAR,
|
||||||
|
|||||||
@@ -82,17 +82,6 @@ public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
|||||||
return JSLibraryStdDescription.JAVA_SCRIPT_LIBRARY_CREATION;
|
return JSLibraryStdDescription.JAVA_SCRIPT_LIBRARY_CREATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public RuntimeLibraryFiles getExistingJarFiles() {
|
|
||||||
KotlinPaths paths = PathUtil.getKotlinPathsForIdeaPlugin();
|
|
||||||
return new RuntimeLibraryFiles(
|
|
||||||
assertFileExists(paths.getJsStdLibJarPath()),
|
|
||||||
null,
|
|
||||||
assertFileExists(paths.getJsStdLibSrcJarPath())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<LibraryJarDescriptor> getLibraryJarDescriptors() {
|
public List<LibraryJarDescriptor> getLibraryJarDescriptors() {
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj
|
|||||||
|
|
||||||
protected abstract val libraryCaption: String
|
protected abstract val libraryCaption: String
|
||||||
|
|
||||||
abstract val existingJarFiles: RuntimeLibraryFiles
|
|
||||||
|
|
||||||
override fun getStatus(module: Module): ConfigureKotlinStatus {
|
override fun getStatus(module: Module): ConfigureKotlinStatus {
|
||||||
if (!isApplicable(module)) {
|
if (!isApplicable(module)) {
|
||||||
return ConfigureKotlinStatus.NON_APPLICABLE
|
return ConfigureKotlinStatus.NON_APPLICABLE
|
||||||
@@ -235,7 +233,7 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj
|
|||||||
|
|
||||||
protected fun needToChooseJarPath(project: Project): Boolean {
|
protected fun needToChooseJarPath(project: Project): Boolean {
|
||||||
val defaultPath = getDefaultPathToJarFile(project)
|
val defaultPath = getDefaultPathToJarFile(project)
|
||||||
return !isProjectLibraryPresent(project) && !existingJarFiles.getRuntimeDestination(defaultPath).exists()
|
return !isProjectLibraryPresent(project) && !File(defaultPath, libraryJarDescriptors.first().jarName).exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun getDefaultPathToJarFile(project: Project): String {
|
protected open fun getDefaultPathToJarFile(project: Project): String {
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 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.configuration
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class RuntimeLibraryFiles(
|
|
||||||
val runtimeJar: File,
|
|
||||||
val reflectJar: File?,
|
|
||||||
val runtimeSourcesJar: File
|
|
||||||
) {
|
|
||||||
fun getAllJars(): List<File> = listOfNotNull(runtimeJar, reflectJar, runtimeSourcesJar)
|
|
||||||
|
|
||||||
fun getRuntimeDestination(dirToCopyJar: String): File =
|
|
||||||
File(dirToCopyJar + "/" + runtimeJar.name)
|
|
||||||
|
|
||||||
fun getReflectDestination(dirToCopyJar: String): File? =
|
|
||||||
if (reflectJar != null) File(dirToCopyJar + "/" + reflectJar.name) else null
|
|
||||||
|
|
||||||
fun getRuntimeSourcesDestination(dirToCopyJar: String): File =
|
|
||||||
File(dirToCopyJar + "/" + runtimeSourcesJar.name)
|
|
||||||
}
|
|
||||||
+5
-2
@@ -176,10 +176,13 @@ abstract class CustomLibraryDescriptorWithDeferredConfig
|
|||||||
|
|
||||||
// Implements an API added in IDEA 16
|
// Implements an API added in IDEA 16
|
||||||
override fun createNewLibraryWithDefaultSettings(contextDirectory: VirtualFile?): NewLibraryConfiguration? {
|
override fun createNewLibraryWithDefaultSettings(contextDirectory: VirtualFile?): NewLibraryConfiguration? {
|
||||||
return createConfiguration(collectPathsInPlugin(OrderRootType.CLASSES),
|
return createConfigurationFromPluginPaths()
|
||||||
collectPathsInPlugin(OrderRootType.SOURCES))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun createConfigurationFromPluginPaths() =
|
||||||
|
createConfiguration(collectPathsInPlugin(OrderRootType.CLASSES),
|
||||||
|
collectPathsInPlugin(OrderRootType.SOURCES))
|
||||||
|
|
||||||
private fun collectPathsInPlugin(rootType: OrderRootType): List<File> {
|
private fun collectPathsInPlugin(rootType: OrderRootType): List<File> {
|
||||||
return configurator.libraryJarDescriptors
|
return configurator.libraryJarDescriptors
|
||||||
.filter { it.orderRootType == rootType }
|
.filter { it.orderRootType == rootType }
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ import com.intellij.openapi.roots.libraries.NewLibraryConfiguration;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.TestOnly;
|
import org.jetbrains.annotations.TestOnly;
|
||||||
import org.jetbrains.kotlin.idea.configuration.KotlinJsModuleConfigurator;
|
import org.jetbrains.kotlin.idea.configuration.KotlinJsModuleConfigurator;
|
||||||
import org.jetbrains.kotlin.idea.configuration.RuntimeLibraryFiles;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtilsKt.getConfiguratorByName;
|
import static org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtilsKt.getConfiguratorByName;
|
||||||
@@ -52,7 +50,6 @@ public class JSLibraryStdDescription extends CustomLibraryDescriptorWithDeferred
|
|||||||
KotlinJsModuleConfigurator configurator = (KotlinJsModuleConfigurator) getConfiguratorByName(NAME);
|
KotlinJsModuleConfigurator configurator = (KotlinJsModuleConfigurator) getConfiguratorByName(NAME);
|
||||||
assert configurator != null : "Cannot find configurator with name " + NAME;
|
assert configurator != null : "Cannot find configurator with name " + NAME;
|
||||||
|
|
||||||
RuntimeLibraryFiles files = configurator.getExistingJarFiles();
|
return createConfigurationFromPluginPaths();
|
||||||
return createConfiguration(Collections.singletonList(files.getRuntimeJar()), files.getRuntimeSourcesJar());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user