问题描述
我正在发布一个 Gradle 项目(它有依赖项,这些依赖项不在 Maven Central 中)但是当我尝试将我的项目(a-project)添加到另一个项目(b-project)中时,我得到了这个错误:(我正在使用 Gradle shadowJar 插件)
* What went wrong:
Could not determine the dependencies of task ':project-b:shadowJar'.
> Could not resolve all dependencies for configuration ':project-b:runtimeClasspath'.
> Could not find com.example:dependency-of-project-a:3.0.0.
Searched in the following locations:
- <list of repositories in 'project-b'>
required by:
project :b-project > com.example:project-a:2.0.0
我查看了我的 nexus 存储库,发现使用 Maven 发布的项目有一个 <repositories>
部分,我认为这就是它解决传递依赖项的方式。
但是我使用 Gradle 的 maven-publish 发布的项目没有,所以我认为这就是问题所在。
project-a build.gradle:
plugins {
id 'java-library'
id 'maven-publish'
}
repositories {
mavenLocal()
maven { url 'https://transitive-dependencies-repo.example.com/' }
mavenCentral()
}
dependencies {
api 'com.example:dependency-of-project-a:3.0.0'
}
publishing {
repositories {
maven {
url = "url of my repo"
credentials {
username = "user"
password = "password"
}
}
}
publications {
maven(MavenPublication) {
from components.java
}
}
}
project-b build.gradle
plugins {
id 'java-library'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
repositories {
mavenLocal()
maven { url 'url of my repo' }
mavenCentral()
}
dependencies {
api 'com.example:project-a:2.0.0'
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)