mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 15:30:38 -05:00
Remove gradle-wrapper arg
It is the default behavior to use the project's Gradle wrapper if available.
This commit is contained in:
@@ -35,6 +35,13 @@ application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
(run) {
|
||||||
|
dependsOn(installDist)
|
||||||
|
doFirst {
|
||||||
|
jvmArgs = listOf("-Dorg.nixos.gradle2nix.share=${installDist.get().destinationDir.resolve("share")}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
startScripts {
|
startScripts {
|
||||||
doLast {
|
doLast {
|
||||||
unixScript.writeText(unixScript.readText().replace("@APP_HOME@", "\$APP_HOME"))
|
unixScript.writeText(unixScript.readText().replace("@APP_HOME@", "\$APP_HOME"))
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ import org.gradle.tooling.ProjectConnection
|
|||||||
fun connect(config: Config): ProjectConnection =
|
fun connect(config: Config): ProjectConnection =
|
||||||
GradleConnector.newConnector()
|
GradleConnector.newConnector()
|
||||||
.apply {
|
.apply {
|
||||||
if (config.wrapper) {
|
if (config.gradleVersion != null) {
|
||||||
useBuildDistribution()
|
|
||||||
} else if (config.gradleVersion != null) {
|
|
||||||
useGradleVersion(config.gradleVersion)
|
useGradleVersion(config.gradleVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import java.io.File
|
|||||||
val shareDir: String = System.getProperty("org.nixos.gradle2nix.share")
|
val shareDir: String = System.getProperty("org.nixos.gradle2nix.share")
|
||||||
|
|
||||||
data class Config(
|
data class Config(
|
||||||
val wrapper: Boolean,
|
|
||||||
val gradleVersion: String?,
|
val gradleVersion: String?,
|
||||||
val configurations: List<String>,
|
val configurations: List<String>,
|
||||||
val projectDir: File,
|
val projectDir: File,
|
||||||
@@ -33,10 +32,6 @@ data class Config(
|
|||||||
class Main : CliktCommand(
|
class Main : CliktCommand(
|
||||||
name = "gradle2nix"
|
name = "gradle2nix"
|
||||||
) {
|
) {
|
||||||
private val wrapper: Boolean by option("--gradle-wrapper", "-w",
|
|
||||||
help = "Use the project's gradle wrapper for building")
|
|
||||||
.flag()
|
|
||||||
|
|
||||||
private val gradleVersion: String? by option("--gradle-version", "-g",
|
private val gradleVersion: String? by option("--gradle-version", "-g",
|
||||||
metavar = "VERSION",
|
metavar = "VERSION",
|
||||||
help = "Use a specific Gradle version")
|
help = "Use a specific Gradle version")
|
||||||
@@ -87,7 +82,7 @@ class Main : CliktCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val config = Config(wrapper, gradleVersion, configurations, projectDir, includes, buildSrc, quiet)
|
val config = Config(gradleVersion, configurations, projectDir, includes, buildSrc, quiet)
|
||||||
val (log, _, _) = Logger(verbose = !config.quiet)
|
val (log, _, _) = Logger(verbose = !config.quiet)
|
||||||
|
|
||||||
val paths = resolveProjects(config).map { p ->
|
val paths = resolveProjects(config).map { p ->
|
||||||
@@ -95,9 +90,9 @@ class Main : CliktCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val models = connect(config).use { connection ->
|
val models = connect(config).use { connection ->
|
||||||
paths.associate { project ->
|
paths.associateWith { project ->
|
||||||
log("Resolving project model: ${project.takeIf { it.isNotEmpty() } ?: "root project"}...")
|
log("Resolving project model: ${project.takeIf { it.isNotEmpty() } ?: "root project"}...")
|
||||||
project to connection.getBuildModel(config, project)
|
connection.getBuildModel(config, project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.nixos.gradle2nix
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.io.TempDir
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
class WrapperTest {
|
||||||
|
@TempDir
|
||||||
|
lateinit var root: File
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `resolves gradle version from wrapper configuration`() {
|
||||||
|
val model = root.buildKotlin("""
|
||||||
|
tasks.wrapper {
|
||||||
|
gradleVersion = "5.5.1"
|
||||||
|
}
|
||||||
|
""".trimIndent())
|
||||||
|
|
||||||
|
assertEquals(model.gradle.version, "5.5.1")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user