Gradle 多项目构建:找不到插件
我有一个非常基本的用例,用于多项目/多模块Gradle构建。我最终需要的是结构上并不比官方Gradle文档中提出的用于声明子项目之间依赖关系的建议更复杂。
在这里复制他们的文档,我们有这个项目结构:
.
├── buildSrc
│ ...
├── api
│ ├── src
│ │ └──...
│ └── build.gradle
├── services
│ └── person-service
│ ├── src
│ │ └──...
│ └── build.gradle
├── shared
│ ├── src
│ │ └──...
│ └── build.gradle
└── settings.gradle
这些构建文件:
// settings.gradle
rootProject.name = 'dependencies-java'
include 'api', 'shared', 'services:person-service'
// buildSrc/src/main/groovy/myproject.java-conventions.gradle
plugins {
id 'java'
}
group = 'com.example'
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
testImplementation "junit:junit:4.13"
}
// api/build.gradle
plugins {
id 'myproject.java-conventions'
}
dependencies {
implementation project(':shared')
}
shared/build.gradle
plugins {
id 'myproject.java-conventions'
}
// services/person-service/build.gradle
plugins {
id 'myproject.java-conventions'
}
dependencies {
implementation project(':shared')
implementation project(':api')
}
但是,当我实际尝试此操作并从项目根目录运行时,我收到以下错误:gradle build
Plugin [id: 'myproject.java-conventions'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
只是为了踢球,我尝试添加一个版本,但可以预见的是,Gradle脾气暴躁,并说它无法解决工件。我做错了什么?
我的 Gradle 版本信息:
------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------
Build time: 2020-06-30 06:32:47 UTC
Revision: 66bc713f7169626a7f0134bf452abde51550ea0a
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.8 (Oracle Corporation 11.0.8+10)
OS: Windows 10 10.0 amd64