mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 23:40:37 -05:00
Add "--project", "-p" option for resolving subprojects explicitly
Fixes #4. Also resolves #3 by excluding the local maven repo.
This commit is contained in:
@@ -13,24 +13,18 @@ fun connect(config: Config): ProjectConnection =
|
||||
.forProjectDirectory(config.projectDir)
|
||||
.connect()
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
fun ProjectConnection.getBuildModel(config: Config, path: String): DefaultBuild {
|
||||
val arguments = mutableListOf(
|
||||
"--init-script=$shareDir/init.gradle",
|
||||
"-Dorg.nixos.gradle2nix.configurations='${config.configurations.joinToString(",")}'"
|
||||
)
|
||||
|
||||
if (path.isNotEmpty()) {
|
||||
arguments += "--project-dir=$path"
|
||||
}
|
||||
|
||||
return model(Build::class.java)
|
||||
.withArguments(arguments)
|
||||
.apply {
|
||||
if (!config.quiet) {
|
||||
setStandardOutput(System.err)
|
||||
setStandardError(System.err)
|
||||
}
|
||||
return model(Build::class.java).apply {
|
||||
addArguments("--init-script=$shareDir/init.gradle")
|
||||
if (path.isNotEmpty()) addArguments("--project-dir=$path")
|
||||
addJvmArguments(
|
||||
"-Dorg.nixos.gradle2nix.configurations='${config.configurations.joinToString(",")}'",
|
||||
"-Dorg.nixos.gradle2nix.subprojects='${config.subprojects.joinToString(",")}'"
|
||||
)
|
||||
if (!config.quiet) {
|
||||
setStandardOutput(System.err)
|
||||
setStandardError(System.err)
|
||||
}
|
||||
.get()
|
||||
.let { DefaultBuild(it) }
|
||||
}.get().let { DefaultBuild(it) }
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ data class Config(
|
||||
val configurations: List<String>,
|
||||
val projectDir: File,
|
||||
val includes: List<File>,
|
||||
val subprojects: List<String>,
|
||||
val buildSrc: Boolean,
|
||||
val quiet: Boolean
|
||||
) {
|
||||
@@ -55,6 +56,19 @@ class Main : CliktCommand(
|
||||
}
|
||||
}
|
||||
|
||||
private val subprojects: List<String> by option("--project", "-p",
|
||||
metavar = "PATH",
|
||||
help = "Only resolve these subproject paths, e.g. ':', or ':sub:project' (default: all projects)")
|
||||
.multiple()
|
||||
.validate { paths ->
|
||||
val failures = paths.filterNot { it.startsWith(":") }
|
||||
if (failures.isNotEmpty()) {
|
||||
val message = failures.joinToString("\n ")
|
||||
fail("Subproject paths must be absolute:\n$message\n" +
|
||||
"Paths are in the form ':parent:child'.")
|
||||
}
|
||||
}
|
||||
|
||||
private val outDir: File? by option("--out-dir", "-o",
|
||||
metavar = "DIR",
|
||||
help = "Path to write generated files (default: PROJECT-DIR)")
|
||||
@@ -82,7 +96,7 @@ class Main : CliktCommand(
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
val config = Config(gradleVersion, configurations, projectDir, includes, buildSrc, quiet)
|
||||
val config = Config(gradleVersion, configurations, projectDir, includes, subprojects, buildSrc, quiet)
|
||||
val (log, _, _) = Logger(verbose = !config.quiet)
|
||||
|
||||
val paths = resolveProjects(config).map { p ->
|
||||
|
||||
Reference in New Issue
Block a user