Skip to content

Commit 1c0fb5d

Browse files
committed
Hack to get Kotlin Gradle Settings scripts to be loaded with the
correct template
1 parent 86fd15d commit 1c0fb5d

File tree

1 file changed

+9
-0
lines changed
  • server/src/main/kotlin/org/javacs/kt/compiler

1 file changed

+9
-0
lines changed

server/src/main/kotlin/org/javacs/kt/compiler/Compiler.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ private class CompilationEnvironment(
140140
scriptClassLoader.loadClass(it).kotlin,
141141
scriptHostConfig[ScriptingHostConfiguration.getEnvironment]?.invoke()
142142
) {
143+
override fun isScript(fileName: String): Boolean {
144+
// The pattern for KotlinSettingsScript doesn't seem to work well, so kinda "forcing it" for settings.gradle.kts files
145+
if (this.template.simpleName == "KotlinSettingsScript" && fileName.endsWith("settings.gradle.kts")) {
146+
return true
147+
}
148+
149+
return super.isScript(fileName)
150+
}
151+
143152
override val dependencyResolver: DependenciesResolver = object : DependenciesResolver {
144153
override fun resolve(scriptContents: ScriptContents, environment: Environment) = ResolveResult.Success(ScriptDependencies(
145154
imports = listOf(

0 commit comments

Comments
 (0)