In Groovy, I overwrite a task like this:
task jar(overwrite: true) {
...
}
How do I do that with Kotlin-dsl? I know that I can create a task like this:
tasks {
val jar by creating {
...
}
}
but I can't find the equivalent way to declare it as overwrite, this leads to an error
From the main menu, select Run | Edit Configurations to open the run/debug configuration for your project. icon. In the list that opens, select Run Gradle task. In the Select Gradle Task dialog, specify the project and the task that you want to execute before launching the project.
To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build. As a result, the test sources aren't compiled, and therefore, aren't executed.
Each project is made up of different tasks and a task is a piece of work which a build performs. The task might be compiling some classes, storing class files into separate target folder, creating JAR, generating Javadoc, or publishing some achieves to the repositories.
Gradle's Kotlin DSL provides an alternative syntax to the traditional Groovy DSL with an enhanced editing experience in supported IDEs, with superior content assist, refactoring, documentation, and more.
By opening an issue on the kotlin-dsl github I found the correct syntax:
tasks.replace("jar") {
...
}
However, this is the old way and does not work within a tasks { }
block, so this issue will be further tracked here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With