Reputation: 51804
I am trying to create a custom Gradle task which invokes an existing Gradle task with parameters which are specific to my project. Here is how I invoke the task from the command line:
./gradlew downloadJson \
-Pendpoint=http://example.com/foo \
-Pdestination=src/main/com/example/foo.json
I would like to create a downloadFoo
task which I can invoke without specifying the parameters explicitely.
tasks.register("downloadFoo" /* type needed? */) {
// What goes here?
}
Upvotes: 2
Views: 1177
Reputation: 21
Try this form:
tasks.register("downloadBackendSchema", com.apollographql.apollo.gradle.internal.ApolloDownloadSchemaTask) { task ->
description("Downloads Apollo Schema")
group("Apollo")
task.schemaRelativeToProject.set("src/main/java/com/project/backend/grqphql/schema.json")
task.endpoint.set("http://your-project.com/graphql")
}
Upvotes: 0
Reputation: 171084
There's no real concept of tasks wrapping other tasks in Gradle...
What you can do in this situation is to just create a new task of type ApolloDownloadSchemaTask
, and then set the properties:
import com.apollographql.apollo.gradle.internal.ApolloDownloadSchemaTask
tasks.register("downloadFoo", ApolloDownloadSchemaTask) { task ->
description("Downloads foo.")
group("Apollo")
task.schemaFilePath.set("src/main/com/example/foo.json")
task.endpointUrl.set("http://example.com/foo")
}
Upvotes: 2