Yip*_*Yay 86 java dependencies ivy gradle maven
告诉Gradle以下内容最简单的方法是什么:
检索'junit'依赖关系并采用其最新的'release'版本.
管理Maven和Ivy存储库对我来说有点新鲜.我尝试了以下步骤,导致Could not resolve dependency ...错误:
compile "junit:junit:latest.release"用存储库设置为只写mavenCentral() (但是,如果我说"junit:junit:4.10",它就可以工作).
compile "junit:junit:latest.release"使用存储库写入以下方式:
ivy {
// I also tried 'http://maven.org' and other possible variants.
url "http://repo1.maven.org"
layout "maven"
}
Run Code Online (Sandbox Code Playgroud)尝试使用Spring Source Ivy存储库:
ivy {
artifactPattern "http://repository.springsource.com/ivy/libraries/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
ivyPattern "http://repository.springsource.com/ivy/libraries/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
}
Run Code Online (Sandbox Code Playgroud)也许我误解了一些事情.为什么获得最新版本的依赖是如此艰巨的任务?
jmr*_*ruc 241
获取最新版本有时非常有用 - 例如,您经常发布自己的依赖项.
您可以获得最新版本
compile "junit:junit:+"
Run Code Online (Sandbox Code Playgroud)
或者更好地指定至少主要版本
compile "junit:junit:4.+"
Run Code Online (Sandbox Code Playgroud)
Pet*_*ser 43
Gradle目前不支持Maven RELEASE(很少使用和弃用),但它确实支持Ivy latest.release.但是,一般建议是针对确切版本进行构建.否则,构建可以变成彩票.
Ben*_*ten 24
查看Gradle-Versions-Plugin.它完全符合您的要求:https://github.com/ben-manes/gradle-versions-plugin
有关安装,请参阅github页面.基本上你需要将这两行添加到build.gradle - 项目文件中:
apply plugin: 'com.github.ben-manes.versions'
buildscript {
[...]
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.8'
[...]
}
}
[...]
Run Code Online (Sandbox Code Playgroud)
然后你可以使用插件,在项目目录的终端中运行这个命令:
./gradlew dependencyUpdates -Drevision=release
Run Code Online (Sandbox Code Playgroud)
它会告诉你哪些依赖已经过时了!
最新的Gradle用户指南提及并解释了加号的版本:
Run Code Online (Sandbox Code Playgroud)dependencies { compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final' testCompile group: 'junit', name: 'junit', version: '4.+' }...构建脚本还声明编译项目测试需要任何junit> = 4.0.
如果依赖项被声明为动态版本(如1. +),Gradle会将其解析为存储库中最新的可用静态版本(如1.2).对于Maven存储库,这是使用maven-metadata.xml文件完成的,而对于Ivy存储库,这是通过目录列表完成的.
| 归档时间: |
|
| 查看次数: |
80931 次 |
| 最近记录: |