简体   繁体   English

gradle依赖与基于XML的依赖之间的区别

[英]Difference between a gradle dependency and an XML based dependency

I'm still pretty new this... 我还挺新的...

I'm used to adding a dependencies through the grade file eg 我习惯通过成绩文件添加依赖项,例如

dependencies {
    // ...
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.google.code.gson:gson:2.5'
    // ...
} 

Now I want to add a new dependency , but the depedency in XML format. 现在,我想添加一个新的dependency ,但是XML格式的依赖关系

<dependency>
    <groupId>org.simpleframework</groupId>
    <artifactId>simple-xml</artifactId>
    <version>2.7.1</version>
</dependency>

Why is this code in XML, what is the difference between using Gradle, and where file in my project directory do I put this XML? 为什么此代码使用XML,使用Gradle和在我的项目目录中的XML文件之间有什么区别?

The "XML format" is actually Maven format. “ XML格式”实际上是Maven格式。 That XML is how Maven identifies dependencies. 该XML是Maven识别依赖关系的方式。 Gradle dependency is the same information in a less verbose format. Gradle依赖项是相同的信息,但格式不太详细。

In the long form, it looks like this. 从长格式看,它看起来像这样。 If you pay attention to the tags in xml and the labels here, you'll see it is the same information. 如果您注意xml中的标签和此处的标签,则会看到相同的信息。

compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'

But you'll see the shorter version more commonly: 但是您会更常见地看到较短的版本:

compile 'org.hibernate:hibernate-core:3.6.7.Final'

Learn more about gradle dependencies here . 在此处了解有关gradle依赖的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM