[英]Mapping between different depencendy managers' (e.g. Maven, Gradle) dependency syntax
When I was browsing MvnRepository , I noticed a pattern. 当我浏览MvnRepository时 ,我注意到了一个模式。 For example if I want to use Spring Framework:
例如,如果我想使用Spring Framework:
Using Maven I need to add: 使用Maven我需要添加:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
Using Gradle I need to add: 使用Gradle我需要添加:
'org.springframework:spring:2.5.6.SEC03'
So I came to the conclusion that if groupId = A , artifactId = B , version = C in Maven, I have to express it like 'A:B:C' in Gradle. 所以我得出的结论是,如果groupId = A , artifactId = B ,在Maven中版本= C ,我必须在Gradle中将其表达为'A:B:C' 。 I noticed a similar pattern for Ivy, Grape, Buildr, SBT, Leiningen syntax.
我注意到Ivy,Grape,Buildr,SBT,Leiningen语法的类似模式。
Is it always the rule or only an MvnRepository thing? 它总是规则还是只有MvnRepository的东西? For example, here is JLIBSVM which can be found in a custom respository, and on the webpage it is only given how to use it with Maven.
例如,这里是可以在自定义存储库中找到的JLIBSVM ,并且在网页上仅给出了如何将其与Maven一起使用。 Is it compatible with all these other dependency managers?
它是否与所有其他依赖管理器兼容?
You can also use this syntax in Gradle: 您还可以在Gradle中使用此语法:
dependencies {
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
}
And there are other variations like this: 还有其他类似的变化:
dependencies {
compile (
[group: 'foo', name: 'foo', version: '0.1'],
[group: 'bar', name: 'bar', version: '0.1']
)
}
Also, not all sections are always required. 此外,并非所有部分都是必需的。 For example if you just have a jar file in a flat directory on your system, you can say:
例如,如果您的系统上的平面目录中只有一个jar文件,则可以说:
runtime name: 'name'
Note the jar
prefix is omitted. 请注意,
jar
前缀被省略。
Gradle and most other dependency managers support declaring dependencies that live in a Maven repository because Maven is ubiquitous. Gradle和大多数其他依赖管理器支持声明存在于Maven存储库中的依赖关系,因为Maven无处不在。 The project you mention is indeed hosted in a Maven repository, just not the Maven Central that you may be used to.
您提到的项目确实托管在Maven存储库中,而不是您可能习惯的Maven Central。 When using Gradle for example you have to indicate which Maven repository you want to use in the
repositories
section. 例如,在使用Gradle时,您必须在
repositories
部分中指明要使用的Maven存储repositories
。
是的,尽管周围还有一些修饰符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.