Hi folks,
I am writing a Gradle plugin, let’s call it myPlugin, which, amongst other things, declares its own dependency. The Plugin will be used in a build.gradle with apply plugin: 'myPlugin'
. It also adds a task, which will be invoked later.
Question is: I don’t want to hard code the version for the dependency in the plugin, but rather pass it from the build.gradle. I tried to use a PluginExtension, but it seems that it is too late, because I need the version already before/during apply.
Here are the code snippets:
The plugin:
class MyPlugin implements Plugin<Project> {
void apply(Project project) {
project.dependencies {
compile 'some.dependency:something-useful:1.0.0:classes'
}
project.task("myTask") {
...
}
...
}
The gradle.build:
apply plugin: 'myPlugin'
...
jar.dependsOn myTask
Any ideas? Let me know if I should provide more details.
Best regards,
Stefan