Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setup js deps #2258

Merged
merged 3 commits into from Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -14,5 +14,6 @@ kotlin {

dependencies {
implementation(kotlin("stdlib"))
implementation(npm("is-sorted", "1.0.5"))
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-router-dom:${properties["dokka_it_react_kotlin_version"]}")
}
Expand Up @@ -12,4 +12,10 @@ class RootPackageClass {
val description = "I do live in the root package!"
}

fun RComponent<*, *>.params() = URLSearchParams()
fun RComponent<*, *>.params() = URLSearchParams()

fun test(list: MutableList<Int>) = "list"

@JsModule("is-sorted")
@JsNonModule
external fun <T> sorted(a: Array<T>): Boolean
Expand Up @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.config.ContentRoot
import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider
Expand Down Expand Up @@ -74,7 +75,7 @@ import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices
import java.io.File
import org.jetbrains.kotlin.konan.file.File as KFile

import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION

const val JAR_SEPARATOR = "!/"

Expand Down Expand Up @@ -289,23 +290,32 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
val analyzerServices = analysisPlatform.analyzerServices()

return buildMap {
classpath.forEach { libraryFile ->
val kotlinLibrary = resolveSingleFileKlib(
libraryFile = KFile(libraryFile.absolutePath),
strategy = ToolingSingleFileKlibResolveStrategy
)

if (kotlinLibrary.getCompatibilityInfo().isCompatible) {
// exists, is KLIB, has compatible format
put(
libraryFile.absolutePath,
if (analysisPlatform == Platform.native)
DokkaNativeKlibLibraryInfo(kotlinLibrary, analyzerServices, dependencyResolver)
else
DokkaJsKlibLibraryInfo(kotlinLibrary, analyzerServices, dependencyResolver)
)
classpath
.filter { it.isDirectory || (it.extension == "jar" || it.extension == KLIB_FILE_EXTENSION) }
.forEach { libraryFile ->
try {
val kotlinLibrary = resolveSingleFileKlib(
libraryFile = KFile(libraryFile.absolutePath),
strategy = ToolingSingleFileKlibResolveStrategy
)

if (kotlinLibrary.getCompatibilityInfo().isCompatible) {
// exists, is KLIB, has compatible format
put(
libraryFile.absolutePath,
if (analysisPlatform == Platform.native) DokkaNativeKlibLibraryInfo(
kotlinLibrary,
analyzerServices,
dependencyResolver
)
else DokkaJsKlibLibraryInfo(kotlinLibrary, analyzerServices, dependencyResolver)
)
}
} catch (e: Throwable) {
configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
.report(CompilerMessageSeverity.WARNING, "Can not resolve KLIB. " + e.message)
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
}

Expand Down Expand Up @@ -487,7 +497,8 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
* Classpath for this environment.
*/
val classpath: List<File>
get() = configuration.jvmClasspathRoots
get() = configuration.jvmClasspathRoots + configuration.getList(JSConfigurationKeys.LIBRARIES)
.mapNotNull { File(it) }

/**
* Adds list of paths to classpath.
Expand All @@ -496,8 +507,9 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
fun addClasspath(paths: List<File>) {
if (analysisPlatform == Platform.js) {
configuration.addAll(JSConfigurationKeys.LIBRARIES, paths.map { it.absolutePath })
} else {
configuration.addJvmClasspathRoots(paths)
Comment on lines +510 to +511
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that a similar problem will arise if paths contains files from Platform.native or Platform.common?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible, but it will depend on runners. I do not expect the similar problem here.
This PR solves only issues which are related with JS deps.

}
configuration.addJvmClasspathRoots(paths)
}

/**
Expand All @@ -507,8 +519,9 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
fun addClasspath(path: File) {
if (analysisPlatform == Platform.js) {
configuration.add(JSConfigurationKeys.LIBRARIES, path.absolutePath)
} else {
configuration.addJvmClasspathRoot(path)
}
configuration.addJvmClasspathRoot(path)
}

/**
Expand Down