@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
30
30
import org.jetbrains.kotlin.cli.common.config.ContentRoot
31
31
import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
32
32
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
33
+ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
33
34
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
34
35
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
35
36
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider
@@ -74,7 +75,7 @@ import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
74
75
import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices
75
76
import java.io.File
76
77
import org.jetbrains.kotlin.konan.file.File as KFile
77
-
78
+ import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION
78
79
79
80
const val JAR_SEPARATOR = " !/"
80
81
@@ -289,23 +290,32 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
289
290
val analyzerServices = analysisPlatform.analyzerServices()
290
291
291
292
return buildMap {
292
- classpath.forEach { libraryFile ->
293
- val kotlinLibrary = resolveSingleFileKlib(
294
- libraryFile = KFile (libraryFile.absolutePath),
295
- strategy = ToolingSingleFileKlibResolveStrategy
296
- )
297
-
298
- if (kotlinLibrary.getCompatibilityInfo().isCompatible) {
299
- // exists, is KLIB, has compatible format
300
- put(
301
- libraryFile.absolutePath,
302
- if (analysisPlatform == Platform .native)
303
- DokkaNativeKlibLibraryInfo (kotlinLibrary, analyzerServices, dependencyResolver)
304
- else
305
- DokkaJsKlibLibraryInfo (kotlinLibrary, analyzerServices, dependencyResolver)
306
- )
293
+ classpath
294
+ .filter { it.isDirectory || (it.extension == " jar" || it.extension == KLIB_FILE_EXTENSION ) }
295
+ .forEach { libraryFile ->
296
+ try {
297
+ val kotlinLibrary = resolveSingleFileKlib(
298
+ libraryFile = KFile (libraryFile.absolutePath),
299
+ strategy = ToolingSingleFileKlibResolveStrategy
300
+ )
301
+
302
+ if (kotlinLibrary.getCompatibilityInfo().isCompatible) {
303
+ // exists, is KLIB, has compatible format
304
+ put(
305
+ libraryFile.absolutePath,
306
+ if (analysisPlatform == Platform .native) DokkaNativeKlibLibraryInfo (
307
+ kotlinLibrary,
308
+ analyzerServices,
309
+ dependencyResolver
310
+ )
311
+ else DokkaJsKlibLibraryInfo (kotlinLibrary, analyzerServices, dependencyResolver)
312
+ )
313
+ }
314
+ } catch (e: Throwable ) {
315
+ configuration.getNotNull(CLIConfigurationKeys .MESSAGE_COLLECTOR_KEY )
316
+ .report(CompilerMessageSeverity .WARNING , " Can not resolve KLIB. " + e.message)
317
+ }
307
318
}
308
- }
309
319
}
310
320
}
311
321
@@ -487,7 +497,8 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
487
497
* Classpath for this environment.
488
498
*/
489
499
val classpath: List <File >
490
- get() = configuration.jvmClasspathRoots
500
+ get() = configuration.jvmClasspathRoots + configuration.getList(JSConfigurationKeys .LIBRARIES )
501
+ .mapNotNull { File (it) }
491
502
492
503
/* *
493
504
* Adds list of paths to classpath.
@@ -496,8 +507,9 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
496
507
fun addClasspath (paths : List <File >) {
497
508
if (analysisPlatform == Platform .js) {
498
509
configuration.addAll(JSConfigurationKeys .LIBRARIES , paths.map { it.absolutePath })
510
+ } else {
511
+ configuration.addJvmClasspathRoots(paths)
499
512
}
500
- configuration.addJvmClasspathRoots(paths)
501
513
}
502
514
503
515
/* *
@@ -507,8 +519,9 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
507
519
fun addClasspath (path : File ) {
508
520
if (analysisPlatform == Platform .js) {
509
521
configuration.add(JSConfigurationKeys .LIBRARIES , path.absolutePath)
522
+ } else {
523
+ configuration.addJvmClasspathRoot(path)
510
524
}
511
- configuration.addJvmClasspathRoot(path)
512
525
}
513
526
514
527
/* *
0 commit comments