这是我的项目结构:
- snow
- snow-lib
- snow-base-util
- snow-web-common
- snow-web
- snow-user
这是代码,很简单。 https://github.com/site-weic/snow
当我配置snow-web-common发布到Maven Local时,它发布成功(分支case1)。
dependencies {
api 'org.springframework.boot:spring-boot-starter-web'
api project(':snow-lib:snow-base-util')
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = project.name
version = project.version
from components.java
}
}
}
但是配置snow-base-util会报错(branch case2)
A problem occurred evaluating project ':snow-lib:snow-web-common'.
> Maven publication 'maven' cannot include multiple components
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = project.name
version = project.version
from components.java
}
}
}
dependencies {
api 'org.springframework.boot:spring-boot-starter-web'
api project(':snow-lib:snow-base-util')
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = project.name
version = project.version
from components.java
}
}
}
配置同时发布两个项目会报错(分支case3)
Execution failed for task ':generateMetadataFileForMavenPublication'.
> Invalid publication 'maven':
- Publication only contains dependencies and/or constraints without a version. You need to add minimal version information, publish resolved versions (https://docs.gradle.org/7.4/userguide/publishing_maven.html#publishing_maven:resolved_dependencies) or reference a platform (https://docs.gradle.org/7.4/userguide/platforms.html)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = project.name
version = project.version
from components.java
}
}
}
dependencies {
api 'org.springframework.boot:spring-boot-starter-web'
api project(':snow-lib:snow-base-util')
}
如何修复gradle配置? 还有,gradle 打包多模块项目的最佳实践是什么?能否请您提供一些 Github 或 Books 上的参考项目? 谢谢!!!🙋u200d♂️