question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

snippetsDir and the kotlin dsl

See original GitHub issue

I 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:open
  • Created 4 years ago
  • Reactions:34
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
sdeleuzecommented, Jun 12, 2019

I also prefer @tristanlins proposal which seems more idiomatic Gradle Kotlin DSL code.

5reactions
wilkinsonacommented, Jun 12, 2019

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:

tasks.test {
	outputs.dir(project.property("snippetsDir"))
}

tasks.asciidoctor {
	inputs.dir(project.property("snippetsDir"))
	dependsOn(tasks.test)
}

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found