Composite build - includeBuild and use within settings.gradle

plugins

(Josh Burton) #1

I’m developing a plugin to be applied to a project’s settings, and am attempting to use a composite build during development.

Including the build works, but it seems I can’t use that same included build within the settings.gradle. It still attempts to find my plugin in a repository.

buildscript {

repositories {
    mavenCentral()
}

dependencies {
    classpath 'com:myplugin:2.0.0'
}

}


includeBuild '../myplugin'
include ':app', ':module'

apply plugin: 'com.myplugin'

I get the error:

Error:Could not find com.myplugin:2.0.0.
Searched in the following locations:


(Sterling Greene) #2

This doesn’t work yet. It’s a bit of a chicken and egg problem because we need to evaluate settings.gradle (which resolves the classpath without included builds) to get the list of included builds.

What does your Settings plugin do? You might be able to get away with applying your plugin via an init script to get around this.


(Josh Burton) #3

Ah ok I thought that might be the case.

My plugin includes some projects in the build. Can this be done as a Project plugin, or an init plugin?


(Marcel Trautwein) #4

stumbled upon this:
https://docs.gradle.org/4.9/userguide/organizing_gradle_projects.html#sec:build_sources

The directory buildSrc is treated as an included build

while your answer is absolute correct and matches:
https://docs.gradle.org/4.9/userguide/composite_builds.html#current_limitations_and_future_work

Improvements planned: Making the implicit buildSrc project an included build.

perhaps s.o. with more technical insights can verify this doc

last but not least: to state out: actually it is impossible to move buildSrc to another location than “rootproject/buildSrc”, right?