or even: ```tasks { "bower" { dependsO...
# gradle
g
or even:
Copy code
tasks {
    "bower" {
        dependsOn("gulp_bower")
    }
}
👍 1
c
Will this override "build" or just add the dependency?
Copy code
tasks {
    "build" {
        dependsOn("gulp_build")
    }
}
NVM, found out that this fails, this syntax is for creating tasks
Dependencies without creation in
tasks
block should be defined like this:
Copy code
val build by getting
val gulp_build by getting
build.dependsOn(gulp_build)
Or, to save a line
Copy code
val build by getting
build.dependsOn("gulp_build")
g
Yes, this syntax only for task creation
Or if you want configuration block for existing task:
Copy code
val bower by tasks.getting {
    dependsOn("gulp_build")
}
c
then IJ complains
bower is never used
.
g
I don’t have warning if
val bower
is top level property
c
I do both in
project() { tasks{} }
and in
project() {}
on the build file's top level I don't need this task at all, so [
val by
then use it] remains, it's not too bad really.
it would've been cool if we could write
build by getting { dependsOn("gulp_buld") }
(note: no
val
) Because this one line does everything we need and does not declare unused variable. But I don't know how to even request this feature 🙂 And it is probably not gradle kotlin-dsl related, but core language feature
g
I don’t think that such syntax make sense actually, to strange in terms of language
easier to do something like:
"build".getting { dependsOn("gulp_buld") }
c
you mean create extension function?
g
actually, you can use existing Gradle API for that:
Copy code
tasks.getByName("bower").dependsOn("help")
c
about making sense: why, it says delegate build to getting and do closure with it, forget the result - nobody cares.
LOL, obviously, how did I miss that 😄 Then my full task customization config becomes just
Copy code
tasks {
	getByName("build").dependsOn("gulp_build")
	"gulp_run" { dependsOn("gulp_default") }
	"bower"    { dependsOn("gulp_bower") }
}
g
yes, actually something like that would be better semantically:
Copy code
configure("taskName") {
 configure = "it"
}
c
isn't that how you configure extensions?
e.g.
Copy code
configure<SpringBootPluginExtension> {
		mainClass = "com.example.BootApplication"
	}
g
Yes, I mean in context of tasks
Oh, tasks already have configure, so impossible to use the same name
Haha. actually even better:
Copy code
tasks["build"].dependsOn("gulp_build")
there is
get
operator that works as alias for getByName
c
In my case
tasks["build"]
won't work, I already have tasks {} block, so I'd prefer to have all tasks there.
g
this["build"]
or
get("build")
hmm, I was sure that
tasks { "taskName" {} }
works only with new tasks, but it actually delegates call to maybeCreate, so works with new and existing