snippetsDir and the kotlin dsl
See original GitHub issueI created a new project with Gradle + Kotlin + Boot 2.1.5 and these dependencies:
- Spring Boot Dev Tools
- Rest Repositories
- Spring Rest Docs
- Spring Boot Actuator
The Initializer create this build.gradle.kts
file (shorten):
extra["snippetsDir"] = file("build/generated-snippets")
tasks.test {
outputs.dir(snippetsDir)
}
tasks.asciidoctor {
inputs.dir(snippetsDir)
dependsOn(test)
}
But imo it should be:
val snippetsDir by extra { file("build/generated-snippets") }
tasks.test {
outputs.dir(snippetsDir)
}
tasks.asciidoctor {
inputs.dir(snippetsDir)
dependsOn(tasks.test) // added tasks. prefix
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:34
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Configure Kotlin in Project: importing fails with "Unresolved ...
New Project wizard. Gradle group, Kotlin DSL build script = Yes, select only Java. Get the project. Main menu / Tools / Kotlin...
Read more >Gradle Kotlin DSL Primer
Everything you can read in a Kotlin DSL script is Kotlin code compiled and executed by Gradle. Many of the objects, functions and...
Read more >Get a property of task? in Gradle kotlin - Stack Overflow
See Tasks documentation : you can access asciidoctor tasks using Kotlin delegated properties, and then access its properties like outputDir
Read more >Kotlin으로 Spring REST Docs 만들기 - devkuma
아래와 같이 변경해 주면 된다. //extra["snippetsDir"] = file("build/generated-snippets") ...
Read more >Multiplatform Gradle DSL reference - Kotlin
Multiplatform Gradle DSL reference. Multiplatform projects are in Alpha. Language features and tooling may change in future Kotlin versions.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also prefer @tristanlins proposal which seems more idiomatic Gradle Kotlin DSL code.
Thanks for the report.
In addition to the proposed solution, an alternative would be to leave the declaration of the
snippetsDir
property as it is and to change how it is referenced:The alternative is more closely aligned with what we currently do for bom imports, but I think I prefer the proposal from @tristanlins. If we go with that approach, we should review how we define and reference properties for bom imports as well.