Skip to content

Commit 7b7ff2c

Browse files
committed
Update project accessor class path resolution for Kotlin DSL
1 parent 8cc94b9 commit 7b7ff2c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.gradle.kotlin.dsl.accessors.ProjectAccessorsClassPathGenerator
2-
import org.gradle.kotlin.dsl.accessors.PluginAccessorClassPathGenerator
31
import org.gradle.internal.classpath.ClassPath
42

53
allprojects { project ->
@@ -11,16 +9,20 @@ allprojects { project ->
119
.findAll { it.name =~ pattern }
1210
.forEach { System.out.println "kotlin-lsp-gradle $it" }
1311

12+
def projectAccessorsClassPathProperty = "gradleKotlinDsl.projectAccessorsClassPath"
13+
1414
// List dynamically generated Kotlin DSL accessors (e.g. the 'compile' configuration method)
15-
gradle.services.get(ProjectAccessorsClassPathGenerator.class).projectAccessorsClassPath(project, ClassPath.EMPTY)
16-
.bin
17-
.asFiles
18-
.forEach { System.out.println "kotlin-lsp-gradle $it" }
15+
if (project.hasProperty(projectAccessorsClassPathProperty)) {
16+
project.getProperty(projectAccessorsClassPathProperty)
17+
.bin
18+
.asFiles
19+
.forEach { System.out.println "kotlin-lsp-gradle $it" }
20+
}
1921

20-
gradle.services.get(PluginAccessorClassPathGenerator.class).pluginSpecBuildersClassPath(project)
21-
.bin
22-
.asFiles
23-
.forEach { System.out.println "kotlin-lsp-gradle $it" }
22+
// gradle.services.get(PluginAccessorClassPathGenerator.class).pluginSpecBuildersClassPath(project)
23+
// .bin
24+
// .asFiles
25+
// .forEach { System.out.println "kotlin-lsp-gradle $it" }
2426
}
2527
}
2628
}

shared/src/main/kotlin/org/javacs/kt/classpath/GradleClassPathResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private fun readDependenciesViaGradleCLI(projectDirectory: Path, gradleScripts:
8181
val dependencies = findGradleCLIDependencies(command, projectDirectory)
8282
?.also { LOG.debug("Classpath for task {}", it) }
8383
.orEmpty()
84-
.filter { it.toString().toLowerCase().endsWith(".jar") } // Some Gradle plugins seem to cause this to output POMs, therefore filter JARs
84+
.filter { it.toString().toLowerCase().endsWith(".jar") || Files.isDirectory(it) } // Some Gradle plugins seem to cause this to output POMs, therefore filter JARs
8585
.toSet()
8686

8787
tmpScripts.forEach(Files::delete)

0 commit comments

Comments
 (0)