Skip to content

Commit 2fef42d

Browse files
committed
Run all Gradle tasks in a single execution
1 parent f9cb99e commit 2fef42d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,14 @@ private fun readDependenciesViaGradleCLI(projectDirectory: Path, gradleTasks: Li
6262
LOG.info("Resolving dependencies for '{}' through Gradle's CLI using tasks {}...", projectDirectory.fileName, gradleTasks)
6363
val tmpFile = createTemporaryGradleFile(deleteOnExit = false).toPath()
6464
val gradle = getGradleCommand(projectDirectory)
65-
val dependencies = gradleTasks.flatMap { queryGradleCLIDependencies(gradle, tmpFile, it, projectDirectory).orEmpty() }.toSet()
65+
val command = "$gradle -I ${tmpFile.toAbsolutePath()} ${gradleTasks.joinToString(separator = " ")} --console=plain"
66+
val dependencies = findGradleCLIDependencies(command, projectDirectory)
67+
?.also { LOG.debug("Classpath for task {}", it) }
68+
.orEmpty()
6669
Files.delete(tmpFile)
6770
return dependencies
6871
}
6972

70-
private fun queryGradleCLIDependencies(gradle: Path, tmpFile: Path, task: String, projectDirectory: Path): Set<Path>? =
71-
findGradleCLIDependencies("$gradle -I ${tmpFile.toAbsolutePath()} $task --console=plain", projectDirectory)
72-
?.also { LOG.debug("Classpath for task {}", it) }
73-
7473
private fun findGradleCLIDependencies(command: String, projectDirectory: Path): Set<Path>? {
7574
val result = execAndReadStdout(command, projectDirectory)
7675
LOG.debug(result)

0 commit comments

Comments
 (0)