What's in gradle a group, module and artifact?

蹲街弑〆低调 提交于 2019-12-25 00:15:25

问题


The gradle docs don't take the time to explain the entities they are dealing with. That's why I want to ask such a basic question.

I've got a to understand in detail, what the terms group, module and artifact really mean to alter this code:

compile('com.thoughtworks.xstream:xstream:1.4.7') {
    exclude group: 'xmlpull', module: 'xmlpull'
}

About a year ago I used that exclude statement I took from Android dalvik conversion for xmlpullparser to fix a Multiple dex files failure.

However, after upgrading to Android Studio 3.0 that error occurrs again! Now it says: Multiple dex files define Lorg/xmlpull/mxp1/MXParser and sometimes ...XmlPullParserException.java So, id like to understand how the parameters I give exclude must be shaped.

Reading the documentation one could think a group is the package name and the artifact is the class:

//excluding a particular transitive dependency:
exclude module: 'cglib' //by artifact name
exclude group: 'org.jmock' //by group
exclude group: 'org.unwanted', module: 'iAmBuggy' //by both name and group

Another chinese page (translated) used those excludes

 compile ( 'com.thoughtworks.xstream: xstream: 1.4.7' ) {
       exclude group : 'xmlpull' 
       exclude group : 'XmlPullParser' 
 }

Built on that findings wonder

  • how xmlpull worked when the package name begins with org.xmlpull?
  • what projects those terms refer to in my scenario. Where was the group name defined?
  • What kinda group is XmlPullParser?
  • Must I clean, rebuild or just build the project after altering those parameters? Because sometimes it complains about different files.

回答1:


The group, artifact and version are chosen semi randomly and do NOT need to match packages or classes in the jar file.

For example commons-lang has groupId = 'commons-lang' but the classes are in org.apache.commons.lang.* package

The group, artifact and version are defined within the build file of the project. In maven this will be in pom.xml in gradle this will be in build.gradle (and settings.gradle)

If you want to know the group, artifact, version for a project (aka GAV, aka maven co-ordinates) you will usually go to the project's home page.

You can also use the maven central advanced search to "fuzzy" search eg by artifactId or by a classname within a jar. If you are using an in-house repository you can likely "fuzzy" search via the web interface there also



来源:https://stackoverflow.com/questions/47326984/whats-in-gradle-a-group-module-and-artifact

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!