Hi,
When writing a custom plugin I came across the following situation. I'd like
to dynamically add a task based on the value of one of the fields in my
convention object. However, when I try to identify the task implementation
class the convention object's values haven't been initialized yet. Here's
some sample code to illustrate this.
1) We have a convention object with a field that determines the task I'd
like to use.
class PluginConvention {
String taskId
}
2) We define two different task implementation classes.
def tasks = ['taskId1': Task1.class, 'taskId2': Task2.class]
3) In my plugin class (implements Plugin) I'd now like to add a task based
on the value of taskId.
def taskClass = tasks[pluginConvention.taskId] <--- will still be null
project.tasks.withType(taskClass).whenTaskAdded { task ->
// do convention mapping
}
def task = project.tasks.add("someTaskName", taskClass)
Is there a way to make this work? Any recommendations would be highly
appreciated.
Thanks,
Ben
--
View this message in context:
http://gradle.1045684.n5.nabble.com/Add-task-based-on-property-value-convention-object-in-plugin-tp4651934p4651934.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email