mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 23:40:37 -05:00
Don't run tasks in buildSrc project
This commit is contained in:
@@ -7,7 +7,6 @@ import org.gradle.tooling.ProjectConnection
|
||||
import org.gradle.tooling.ResultHandler
|
||||
import org.gradle.tooling.model.gradle.GradleBuild
|
||||
import org.nixos.gradle2nix.model.DependencySet
|
||||
import org.nixos.gradle2nix.model.RESOLVE_ALL_TASK
|
||||
import java.io.File
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
@@ -50,7 +49,10 @@ suspend fun ProjectConnection.buildModel(): GradleBuild =
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun ProjectConnection.build(config: Config): DependencySet =
|
||||
suspend fun ProjectConnection.build(
|
||||
config: Config,
|
||||
tasks: List<String>,
|
||||
): DependencySet =
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
val cancellationTokenSource = GradleConnector.newCancellationTokenSource()
|
||||
|
||||
@@ -58,13 +60,7 @@ suspend fun ProjectConnection.build(config: Config): DependencySet =
|
||||
|
||||
action { controller -> controller.getModel(DependencySet::class.java) }
|
||||
.withCancellationToken(cancellationTokenSource.token())
|
||||
.apply {
|
||||
if (config.tasks.isNotEmpty()) {
|
||||
forTasks(*config.tasks.toTypedArray())
|
||||
} else {
|
||||
forTasks(RESOLVE_ALL_TASK)
|
||||
}
|
||||
}
|
||||
.forTasks(*tasks.toTypedArray())
|
||||
.setJavaHome(config.gradleJdk)
|
||||
.addArguments(config.gradleArgs)
|
||||
.addArguments(
|
||||
|
||||
@@ -22,6 +22,7 @@ import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.encodeToStream
|
||||
import org.gradle.tooling.model.gradle.GradleBuild
|
||||
import org.nixos.gradle2nix.model.DependencySet
|
||||
import org.nixos.gradle2nix.model.RESOLVE_ALL_TASK
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
|
||||
@@ -71,7 +72,7 @@ class Gradle2Nix : CliktCommand(
|
||||
"-t",
|
||||
metavar = "TASK",
|
||||
help = "Gradle tasks to run",
|
||||
).multiple()
|
||||
).multiple(default = listOf(RESOLVE_ALL_TASK))
|
||||
|
||||
private val projectDir: File by option(
|
||||
"--project",
|
||||
@@ -198,12 +199,12 @@ class Gradle2Nix : CliktCommand(
|
||||
val dependencySets = mutableListOf<DependencySet>()
|
||||
|
||||
connect(config).use { connection ->
|
||||
dependencySets.add(runBlocking { connection.build(config) })
|
||||
dependencySets.add(runBlocking { connection.build(config, config.tasks) })
|
||||
}
|
||||
|
||||
for (buildSrc in buildSrcs) {
|
||||
connect(config, buildSrc).use { connection ->
|
||||
dependencySets.add(runBlocking { connection.build(config) })
|
||||
dependencySets.add(runBlocking { connection.build(config, listOf(RESOLVE_ALL_TASK)) })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user