英文:
How to prevent gradle from downloading SNAPSHOT jar
问题
我正在使用一个名为 module-x 的依赖模块,该模块可能有或可能没有其他trivial/other依赖的SNAPSHOT版本。当我构建应用程序时,我想确保所有trivial/other依赖都是发布版本,而不是SNAPSHOT版本,因为SNAPSHOT版本会不断变化。
build.gradle 文件
dependencies {
implementation 'org.my-group-x:module-x:1.2'
}
它会下载许多依赖项,其中可能有多个是SNAPSHOT类型的
module-y:2.0-SNAPSHOT.jar
module-z:3.1-SNAPSHOT.jar
module-k:2.7-SNAPSHOT.jar
我该如何确保这些依赖被拒绝并且不会添加到应用程序中?另外,我不知道要排除哪些依赖。
英文:
I am using a dependency module-x which has may or may not have SNAPSHOT version of trivial/other dependencies. When I build the application I wanted to make sure that all the trivial/other dependencies are of release type and not SNAPSHOT as SNAPSHOT keeps changing.
build.gradle file
dependencies {
implementation 'org.my-group-x:module-x:1.2'
}
it downloads a bunch of dependencies and it may have multiple dependencies which are of SNAPSHOT typed
module-y:2.0-SNAPSHOT.jar
module-z:3.1-SNAPSHOT.jar
module-k:2.7-SNAPSHOT.jar
How I can make sure it is rejected and not added to the application? Also i dont know the dependencies to exclude it specifically.
答案1
得分: 4
你可以在构建工具中排除依赖项,参见:
https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps
你还可以配置Gradle中使用的Maven仓库,请参阅:
https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:repository-content-filtering
以下是一个仅使用发布版本或仅使用快照版本的示例:
repositories {
maven {
url "https://repo.mycompany.com/releases"
mavenContent {
releasesOnly()
}
}
maven {
url "https://repo.mycompany.com/snapshots"
mavenContent {
snapshotsOnly()
}
}
}
英文:
You can exclude dependencies in build tools, see:
https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps
You can also configure the Maven repositories used in Gradle, see:
https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:repository-content-filtering <br>
Here is an example to use only release versions or only snapshot version:
repositories {
maven {
url "https://repo.mycompany.com/releases"
mavenContent {
releasesOnly()
}
}
maven {
url "https://repo.mycompany.com/snapshots"
mavenContent {
snapshotsOnly()
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论