Gradle在声明自定义maven repo时无法解析依赖项。它在自定义存储库中查找依赖项,而不是maven central。
到目前为止,我所拥有的:
// build.gradle.kts
repositories {
maven {
url = uri("https://maven.pkg.jetbrains.space/myTeam/p/myProject/maven")
credentials {
username = project.extra["space_usr"].toString()
password = project.extra["space_pwd"].toString()
}
}
}
// settings.gradle.kts
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
但是我得到了以下错误:Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app/build.gradle.kts'
。
如果我删除了repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
,那么我会得到以下错误:
Could not determine the dependencies of task ':app:kaptDebugKotlin'.
> Could not resolve all dependencies for configuration ':app:kotlinKaptWorkerDependencies'.
The project declares repositories, effectively ignoring the repositories you have declared in the settings.
You can figure out how project repositories are declared by configuring your build to fail on project repositories.
See https://docs.gradle.org/7.0-rc-1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories for details.
> Could not find org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.4.32.
Searched in the following locations:
- https://maven.pkg.jetbrains.space/...
- https://maven.pkg.jetbrains.space/...
Required by:
project :app
我可以在settings.gradle.kts中添加我的自定义maven依赖项,但project.extra无法访问,需要明文(已编辑)
发布于 2021-04-28 14:43:11
我意识到这是不可能的,相反,我在settings.gradle.kts
中声明了我的maven依赖项,并使用了以下代码:
// settings.gradle.kts
maven {
url = uri(""https://maven.pkg.jetbrains.space/myTeam/p/myProject/maven")
name = "myProject"
credentials(PasswordCredentials::class)
}
// gradle.properties
myProjectUsername = [username]
myProjectPassword = [password]
https://stackoverflow.com/questions/67175807
复制相似问题