Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use classes from a neighbouring subproject during configuration phase

Tags:

gradle

I want to compile one subproject, then have those classes on the classpath while building the other subproject. (A custom tass would use classes created by the first one).

Currently I'm trying:

buildscript {
    dependencies {
        classpath project(':MyOtherProject')
    }
}

... with the following result:

Cannot use project dependencies in a script classpath definition.

like image 465
vbence Avatar asked Jun 12 '16 13:06

vbence


1 Answers

You cannot build something to be used to build the something. (something being the multi-project build here)

You either need to make the MyOtherProject a complete separate build, that you either install to some repository and then depend on it per coordinates or trigger that separate build during configuration phase or your build, then depending on its outcomes.

The other alternative is, that you put it into buildSrc project. This is a full multi-project build contained in your root project that is built and added to the classpath of the main build scripts automatically by Gradle and is meant for Plugins and Custom tasks that you do not want to use in other builds also and thus do not make them a separate build.

like image 126
Vampire Avatar answered Sep 19 '22 07:09

Vampire