androidgradleandroid-gradle-pluginxstreamxmlpullparser

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


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


Solution

  • 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