I’m trying to write a plugin that adds a javadoc task that uses a custom doclet to a project.
This means I have to link against the doclet when configuring the task. When I do this directly in a project (not in a plugin) I do this:
javadocTask.options.docletPath = configurations.docletConfig.files.asType(List);
What I want is for when the user apply’s my plugin, it sets up these that it needs (so the user does not have to).
So the question: If you have a dependency needed by a task being created by a plugin, should it be defined in the plugin’s build.gradle file or should the plugin add it to the list of project dependencies?
If it should be in the plugin’s build.gradle, how would I access the dependnecy when setting up the task? Since there is no enclosing project object, there is no way to reference configurations.docletConfig
If I need to add it dynamically via code, how would I do that? So far I have something like this:
void appy(Project project) {
project.configurations.create("docletConfig")
project.getDependencies().add("docletConfig", ||||Something Here|||)
// Set up Task
}
I’ve tried passing in the same list as I would in a build.gradle file (group: ‘com.company’, name ‘doclet’, version:‘1’), that doesn’t work. I also tried doing it like the exact same as I would do it in build.gradle (with the addition of “project.”)
project.dependencies {
docletConfig (group: 'com.company', name 'doclet', version:'1')
}
and that also doesn’t work. Complains that docletConfig is not a method :(.
Help? I feel like I’m missing something horribly obvious here, wouldn’t plugins having to add dependencies to a project be pretty critical functionality? But I haven’t been able to find any docs/examples on it :(.