How to specify buildSrc folder?

1.8k views Asked by At

Is there any way to specify the root for buildSrc folder manually?

I saw there is ticket which is opened for 3 years (https://issues.gradle.org/browse/GRADLE-2816).

Does Gradle have this feature now?

2

There are 2 answers

1
lance-java On

You could do this:

  • root/gradle-plugins/build.gradle - Builds the gradle-plugins project
  • root/gradle-plugins/src/main/groovy/foo/MyPlugin.groovy - Example plugin
  • root/build.gradle - Builds all the other projects (except for gradle-plugins). These "other" projects can reference gradle-plugins dependencies by GAV (group/artifact/version) eg "foo:gradle-plugins:$version"
  • root/settings.gradle - includeBuild 'gradle-plugins' to create a composite build of the two seperate builds

If you want the same version across the two builds, you could use this trick

0
Joao Sousa On

There's a "trick" to customize the buildSrc path. Just create a symlink (symbolic link) in the root dir to the buildSrc directory.

> cd /path/to/project
> ln -s ./local/path/to/builSrc builSrc

This will create a symlink and if you sync gradle now it will correctly pick up the buildSrc folder. At least it worked for me.