I am trying to set up a gradle multi-project build with all common build configuration packaged as convention plugins in a separate buildlogic
directory, which is handled as an included build as described here.
As I have understood, the benefit of using an included build over buildSrc
is that I can have multiple plugins as separate subprojects, so that a change in one plugin only affects those modules of the main build that actually use this plugin (instead of rebuilding everything upon a change to buildSrc
).
Now, my problem is the following: Even though I implement separate convention plugins – say, one for libraries and one for applications – there is some common build logic for all. Therefore, I want to define a common plugin and include this plugin in both the library and app plugins.
My project structure looks as follows
my-project
|- settings.gradle.kts
|- buildlogic
|- settings.gradle.kts
|- common
|- build.gradle.kts
|- src/main/kotlin
|- buildlogicmon.gradle.kts
|- library
|- build.gradle.kts
|- src/main/kotlin
|- buildlogic.library.gradle.kts
|- app
|- build.gradle.kts
|- src/main/kotlin
|- buildlogic.app.gradle.kts
|- module-a // uses the library plugin
|- module-b // uses the app plugin
|... // more modules, gradle wrapper, etc.
I expect to include the common plugin in both buildlogic.library.gradle.kts
and buildlogic.app.gradle.kts
as follows:
plugins {
id("buildlogic-common")
}
...
However, gradle complains that it can't find the plugin. What am I doing wrong? Which is the correct way to include one conventions from another one in an included build with plugins as subprojects?
I am trying to set up a gradle multi-project build with all common build configuration packaged as convention plugins in a separate buildlogic
directory, which is handled as an included build as described here.
As I have understood, the benefit of using an included build over buildSrc
is that I can have multiple plugins as separate subprojects, so that a change in one plugin only affects those modules of the main build that actually use this plugin (instead of rebuilding everything upon a change to buildSrc
).
Now, my problem is the following: Even though I implement separate convention plugins – say, one for libraries and one for applications – there is some common build logic for all. Therefore, I want to define a common plugin and include this plugin in both the library and app plugins.
My project structure looks as follows
my-project
|- settings.gradle.kts
|- buildlogic
|- settings.gradle.kts
|- common
|- build.gradle.kts
|- src/main/kotlin
|- buildlogicmon.gradle.kts
|- library
|- build.gradle.kts
|- src/main/kotlin
|- buildlogic.library.gradle.kts
|- app
|- build.gradle.kts
|- src/main/kotlin
|- buildlogic.app.gradle.kts
|- module-a // uses the library plugin
|- module-b // uses the app plugin
|... // more modules, gradle wrapper, etc.
I expect to include the common plugin in both buildlogic.library.gradle.kts
and buildlogic.app.gradle.kts
as follows:
plugins {
id("buildlogic-common")
}
...
However, gradle complains that it can't find the plugin. What am I doing wrong? Which is the correct way to include one conventions from another one in an included build with plugins as subprojects?
Share Improve this question edited Mar 24 at 7:22 Ulrich Schuster asked Mar 23 at 9:13 Ulrich SchusterUlrich Schuster 1,91618 silver badges34 bronze badges1 Answer
Reset to default 0In order a plugin in one subproject of an included build to apply another, it needs to depend on the build of the latter.
So if buildlogic.library
wants to use buildlogicmon
, then in its build.gradle.kts
it needs to write:
// buildlogic/library/build.gradle.kts
dependencies {
implementation(project(":common"))
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744291991a4567076.html
评论列表(0条)