I'd like to define a new task called dbStatus
that calls (or extends?) run
, and just overrides the args
property.
apply plugin: 'application'
run {
args "server", "service.yml"
}
task(dbStatus, type: run) {
args "db", "status", "service.yml
}
This doesn't work because "run"
isn't a valid task class. Is there a quick way to extend a task and just override a property?
Unfortunately I had to just define a brand new JavaExec
task, and recreate the logic that run
is configured to do. Here is what I came up with:
task(dbStatus, type: JavaExec) {
main mainClassName
classpath sourceSets.main.runtimeClasspath
args "db", "status", "service.yml"
}
I don't think this is exactly the same as run
, since it isn't running against the build jar
I don't believe, but it works for my purposes.
Tasks cannot be "extended" in this way. Instead, declare another task and configure it as appropriate. (It's common to configure multiple tasks at once to avoid code duplication.)
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