使用Gradle(Kotlin DSL)导入源代码依赖

4
我想在使用Gradle 6.3和Kotlin DSL的Kotlin项目中,将https://github.com/whichdigital/ksv项目的1.0.0版本作为源依赖项导入。 正如页面所告诉我的那样,我将其添加到我的项目的settings.gradle.kts中。
sourceControl {
    gitRepository(java.net.URI.create("https://github.com/whichdigital/ksv.git")) {
        producesModule("uk.co.whichdigital:ksv")
    }
}

并在我的 build.gradle.kts 文件中使用此依赖项:

implementation("uk.co.whichdigital:ksv:1.0.0")

我正在尝试导入KSV代码库的版本/发布1.0.0。但是构建我的项目(导入KSV代码库)失败,出现以下异常:

TaskDependencyResolveException: Could not determine the dependencies of task ':bootJar'.
...
Caused by: DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all task dependencies for configuration ':runtimeClasspath'.
....
Caused by: ModuleVersionResolveException: Git repository at https://github.com/whichdigital/ksv.git did not contain a project publishing the specified dependency.
Required by:
    project :

实际上,我也是编写/发布KSV存储库的人,因此如果有我错过的某些配置,我可以在导入或导入项目中添加它。


为什么不直接下载源代码并将其导入为模块? - vikas kumar
4
因为我希望它成为一个外部依赖,(如果把它放在本地只会引诱团队成员对其进行本地代码修改而不是修复存储库版本)。现在有了 Ramachandran Marugaian 的修复(通过修复组ID),我可以做到了 :) - StephanS
1个回答

2

"uk.co.whichdigital:ksv:1.0.0" 的组ID不正确。

请尝试以下操作:

sourceControl {
   gitRepository(java.net.URI.create("https://github.com/whichdigital/ksv.git")) {
     producesModule("uk.co.whichdigital.ksv:ksv")
   }
}

implementation("uk.co.whichdigital.ksv:ksv:1.0.0")


只是提醒一下,这只适用于公共代码库。如果是私有的,你会得到“需要身份验证但未注册凭据提供程序”的错误。此外,似乎他们还没有整合使用 SSH 进行身份验证的方法,但我可能错了(即使我尝试找到它)。 - acarlstein

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接