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

1

5

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.
Hydrokinetic answered 16/11, 2017 at 10:16 Comment(0)
T
3

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

That answered 16/11, 2017 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.