I want to start the build task from a new task I’m creating. How do I do this?
I don’t quite understand what you are asking for.
I want to create a new task and have one of the things that the task does be starting a build.
- bump *
Does the org.gradle.api.tasks.GradleBuild task do what you need?
I’m not sure how to use that. I’ve set my task as type GradleBuild but the build doesn’t start.
OK, I think I’ve got it now:
task release(type: GradleBuild) {
tasks = ['build']
}
So is this working for you now Jordan?
Yes - it does what I want. I’m not sure, though, if there’s a better way.
(Gradle newbie here)
I’m curious about Jordan’s solution - does the following snippet do the same thing? (except that the build task would run before the release task)
task release(type: GradleBuild, dependsOn: build) {
}
Shorn - that generates an error. I’m not sure why.
Shorn, no they are two different things.
The org.gradle.api.tasks.GradleBuild task is for launching a separate Gradle process during a Gradle build. So if you need to build a completely separate Gradle project from another Gradle project it’s useful.
If you’re trying to create a task named “release” that just triggers the “build” task in the same build, you just need:
task release(dependsOn: build)
Does that explain the difference?
Oh, yes - I see now (I didn’t realise what the GradleBuild task was doing).
Cheers.