Gradle 无法解析私有 Nexus 3 存储库的依赖关系
我正在尝试构建一个使用私有 Nexus 存储库中的库的 gradle 项目。
版本:
- Gradle 7.4
- Nexus OSS 3.37
这是 build.gradle
:
plugins {
id 'java'
}
group 'io.riccardopedrielli'
version '1.0.0'
repositories {
maven {
url 'https://nexus.riccardopedrielli.io/repository/maven-releases/'
credentials {
username '<myuser>'
password '<mypass>'
}
}
mavenCentral()
}
dependencies {
implementation 'io.riccardopedrielli.mylib:1.0.0'
}
当我运行 ./gradlew build
时,出现以下错误:
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find io.riccardopedrielli.mylib:1.0.0:.
Required by:
project :
添加 --debug 我看到这些与 lib 相关的行:
[org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.NodeState] dependency: io.riccardopedrielli.mylib:1.0.0 from-conf: implementation to-conf: null is filtered.
[org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.NodeState] dependency: io.riccardopedrielli.mylib:1.0.0 from-conf: implementation to-conf: null is filtered.
[org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.NodeState] dependency: io.riccardopedrielli.mylib:1.0.0 from-conf: implementation to-conf: null is filtered.
[org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for io.riccardopedrielli.mylib:1.0.0: using repositories [maven, MavenRepo]
[org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'io.riccardopedrielli.mylib:1.0.0:' in resolver cache 'maven'
[org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'io.riccardopedrielli.mylib:1.0.0:' in resolver cache 'MavenRepo'
[org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'io.riccardopedrielli.mylib:1.0.0:' in repository 'maven'.
[org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: io.riccardopedrielli.mylib:1.0.0: [changing = false]
[org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'io.riccardopedrielli.mylib:1.0.0:' in repository 'MavenRepo'.
[org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: io.riccardopedrielli.mylib:1.0.0: [changing = false]
相反,如果我将 maven 与以下 pom.xml
一起使用,则一切正常:
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.riccardopedrielli</groupId>
<artifactId>myapp</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>io.riccardopedrielli</groupId>
<artifactId>mylib</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>localNexus</id>
<url>https://nexus.riccardopedrielli.io/repository/maven-releases/</url>
</repository>
</repositories>
<build>
...
</build>
<properties>
...
</properties>
</project>
由于 Nexus 存储库与 maven 兼容,我想我错过了某物在build.gradle
中。
I'm trying to build a gradle project the uses a library from a private Nexus repository.
Versions:
- Gradle 7.4
- Nexus OSS 3.37
This is the build.gradle
:
plugins {
id 'java'
}
group 'io.riccardopedrielli'
version '1.0.0'
repositories {
maven {
url 'https://nexus.riccardopedrielli.io/repository/maven-releases/'
credentials {
username '<myuser>'
password '<mypass>'
}
}
mavenCentral()
}
dependencies {
implementation 'io.riccardopedrielli.mylib:1.0.0'
}
When I run ./gradlew build
I get the following error:
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find io.riccardopedrielli.mylib:1.0.0:.
Required by:
project :
Adding --debug
i see these lines related to the lib:
[org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.NodeState] dependency: io.riccardopedrielli.mylib:1.0.0 from-conf: implementation to-conf: null is filtered.
[org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.NodeState] dependency: io.riccardopedrielli.mylib:1.0.0 from-conf: implementation to-conf: null is filtered.
[org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.NodeState] dependency: io.riccardopedrielli.mylib:1.0.0 from-conf: implementation to-conf: null is filtered.
[org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for io.riccardopedrielli.mylib:1.0.0: using repositories [maven, MavenRepo]
[org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'io.riccardopedrielli.mylib:1.0.0:' in resolver cache 'maven'
[org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'io.riccardopedrielli.mylib:1.0.0:' in resolver cache 'MavenRepo'
[org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'io.riccardopedrielli.mylib:1.0.0:' in repository 'maven'.
[org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: io.riccardopedrielli.mylib:1.0.0: [changing = false]
[org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'io.riccardopedrielli.mylib:1.0.0:' in repository 'MavenRepo'.
[org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: io.riccardopedrielli.mylib:1.0.0: [changing = false]
Instead, if I use maven with the following pom.xml
, everything works fine:
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.riccardopedrielli</groupId>
<artifactId>myapp</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>io.riccardopedrielli</groupId>
<artifactId>mylib</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>localNexus</id>
<url>https://nexus.riccardopedrielli.io/repository/maven-releases/</url>
</repository>
</repositories>
<build>
...
</build>
<properties>
...
</properties>
</project>
Since the Nexus repository is ok with maven, I think I'm missing something in build.gradle
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在maven中添加metadataSources,如下例所示:
Try by adding metadataSources inside maven, as shown in the example below: