I have a gradle project, and am creating a custom plugin to do some extra build work. The source files for the plugin are stored in the buildSrc/
. I have the basic skeleton working, and I can see the plugin tasks by running gradle tasks
.
The problem I'm having is that I need to add project directories to the classpath for the plugin tasks.
I've tried adding the directories using the buildscript
of my main build.gradle
:
buildscript {
repositories { mavenCentral() }
dependencies {
classpath files('migrationScripts')
}
}
But this doesn't seem to have any impact on the classpath that the plugin sees. When I print out the classpath, I get the following:
/home/jharig/project/buildSrc/build/classes/main/
/home/jharig/project/buildSrc/build/resources/main/
How can I add
/home/jharig/project/migrationScripts
To the classpath when my plugin task executes?
Update:
I don't want to declare the migrationScripts
dependency in buildSrc/build.gradle
.
You need to create buildSrc/build.gradle
and declare /home/jharig/project/migrationScripts
as a regular compile
or runtime
dependency. Note that this won't work if migrationScripts
belongs to the same build as buildSrc
, as all projects of a build effectively depend on buildSrc
, and you can't have dependencies in both directions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With