Forked from #39 (comment)
refs: #39 (comment)
I'm still working on how to make the use cases of executing subproject's task with dotenv option by using CLI arguments, but I think the following tests would be good to pass.
Now failing test case
@Test
fun changeFileWithIgnoringParentByUsingCliOptionWithCallSubProject() {
RootProject(projectDir) {
settingsGradle(
"""
include("sub")
""".trimIndent()
)
buildGradle(
"""
plugins {
id("base")
id("co.uzzu.dotenv.gradle")
}
println("[root] FOO: ${'$'}{env.FOO.value}")
""".trimIndent()
)
file(
".env.template",
"""
FOO=
""".trimIndent()
)
file(
".env",
"""
FOO=100
""".trimIndent()
)
directory("sub")
file(
"sub/build.gradle",
"""
plugins {
id("base")
}
println("[sub] BAR: ${'$'}{env.BAR.value}")
""".trimIndent()
)
file(
"sub/.env.template",
"""
BAR=
""".trimIndent()
)
file(
"sub/.env",
"""
BAR=200
""".trimIndent()
)
file(
"sub/.env.local",
"""
BAR=2000
""".trimIndent()
)
}
val result = GradleRunner.create()
.withPluginClasspath()
.withProjectDir(projectDir)
.withArguments(":sub:clean", "-Pdotenv.filename=.env.local")
.build()
assertAll {
assertThat(result.output).contains("[root] FOO: 100")
assertThat(result.output).contains("[sub] BAR: 2000")
}
}
execution log
FAILURE: Build failed with an exception.
* Where:
Build file '/private/var/folders/xxx/build.gradle.kts' line: 1
* What went wrong:
An exception occurred applying plugin request [id: 'co.uzzu.dotenv.gradle']
> Failed to apply plugin 'co.uzzu.dotenv.gradle'.
> Could not read the dotenv file specified in the gradle.properties. dotenv.filename: .env.local, path: /private/var/folders/xxx/.env.local
workaround: Use gradle.properties
Forked from #39 (comment)
refs: #39 (comment)
I'm still working on how to make the use cases of executing subproject's task with dotenv option by using CLI arguments, but I think the following tests would be good to pass.
Now failing test case
@Test fun changeFileWithIgnoringParentByUsingCliOptionWithCallSubProject() { RootProject(projectDir) { settingsGradle( """ include("sub") """.trimIndent() ) buildGradle( """ plugins { id("base") id("co.uzzu.dotenv.gradle") } println("[root] FOO: ${'$'}{env.FOO.value}") """.trimIndent() ) file( ".env.template", """ FOO= """.trimIndent() ) file( ".env", """ FOO=100 """.trimIndent() ) directory("sub") file( "sub/build.gradle", """ plugins { id("base") } println("[sub] BAR: ${'$'}{env.BAR.value}") """.trimIndent() ) file( "sub/.env.template", """ BAR= """.trimIndent() ) file( "sub/.env", """ BAR=200 """.trimIndent() ) file( "sub/.env.local", """ BAR=2000 """.trimIndent() ) } val result = GradleRunner.create() .withPluginClasspath() .withProjectDir(projectDir) .withArguments(":sub:clean", "-Pdotenv.filename=.env.local") .build() assertAll { assertThat(result.output).contains("[root] FOO: 100") assertThat(result.output).contains("[sub] BAR: 2000") } }execution log
workaround: Use gradle.properties