[Analysis API Standalone] simplify adding multiple binary roots for KtBinaryModuleBuilder
^KT-60884
This commit is contained in:
committed by
Space Team
parent
52e9167675
commit
67f4ebc022
+9
-1
@@ -9,5 +9,13 @@ import java.nio.file.Path
|
|||||||
|
|
||||||
@KtModuleBuilderDsl
|
@KtModuleBuilderDsl
|
||||||
public abstract class KtBinaryModuleBuilder : KtModuleBuilder() {
|
public abstract class KtBinaryModuleBuilder : KtModuleBuilder() {
|
||||||
public lateinit var binaryRoots: Collection<Path>
|
protected val binaryRoots: MutableList<Path> = mutableListOf()
|
||||||
|
|
||||||
|
public fun addBinaryRoot(root: Path) {
|
||||||
|
binaryRoots.add(root)
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun addBinaryRoots(roots: Collection<Path>) {
|
||||||
|
binaryRoots.addAll(roots)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -151,7 +151,7 @@ internal fun buildKtModuleProviderByCompilerConfiguration(
|
|||||||
compilerConfig: CompilerConfiguration,
|
compilerConfig: CompilerConfiguration,
|
||||||
ktFiles: List<KtFile>,
|
ktFiles: List<KtFile>,
|
||||||
): KtStaticProjectStructureProvider = buildProjectStructureProvider(kotlinCoreProjectEnvironment) {
|
): KtStaticProjectStructureProvider = buildProjectStructureProvider(kotlinCoreProjectEnvironment) {
|
||||||
val (scriptFiles, ordinaryFiles) = ktFiles.partition { it.isScript() }
|
val (scriptFiles, _) = ktFiles.partition { it.isScript() }
|
||||||
val platform = JvmPlatforms.defaultJvmPlatform
|
val platform = JvmPlatforms.defaultJvmPlatform
|
||||||
|
|
||||||
fun KtModuleBuilder.addModuleDependencies(moduleName: String) {
|
fun KtModuleBuilder.addModuleDependencies(moduleName: String) {
|
||||||
@@ -159,7 +159,7 @@ internal fun buildKtModuleProviderByCompilerConfiguration(
|
|||||||
addRegularDependency(
|
addRegularDependency(
|
||||||
buildKtLibraryModule {
|
buildKtLibraryModule {
|
||||||
this.platform = platform
|
this.platform = platform
|
||||||
binaryRoots = libraryRoots.map { it.toPath() }
|
addBinaryRoots(libraryRoots.map { it.toPath() })
|
||||||
libraryName = "Library for $moduleName"
|
libraryName = "Library for $moduleName"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -171,7 +171,7 @@ internal fun buildKtModuleProviderByCompilerConfiguration(
|
|||||||
addRegularDependency(
|
addRegularDependency(
|
||||||
buildKtSdkModule {
|
buildKtSdkModule {
|
||||||
this.platform = platform
|
this.platform = platform
|
||||||
this.binaryRoots = binaryRoots
|
addBinaryRoots(binaryRoots)
|
||||||
sdkName = "JDK for $moduleName"
|
sdkName = "JDK for $moduleName"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user