Home > other >  What library versions does mavenCentral() import?
What library versions does mavenCentral() import?

Time:12-04

I am working on a project with Gradle and I have the following in the build.gradle file:

repositories {
    mavenCentral()
}

and I was wondering what version of Apache Commons Codec for example is this importing. (more info about mavenCentral() here )

The question is not how I find out the version (mine is 1.11) but what is the logic behind the default choosing of a specific version.

CodePudding user response:

So you have a gradle file like this:

plugins {
    id 'java'
}

dependencies {
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0' 
    implementation group: 'commons-validator', name: 'commons-validator', version: '1.7'
    implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
}

repositories {
    mavenCentral()
}

If you want to know which dependencies in total are included and why then you can execute gradle dependencies and it will show you among others) this graph:

compileClasspath - Compile classpath for source set 'main'.
 --- org.apache.commons:commons-lang3:3.0
 --- commons-validator:commons-validator:1.7
|     --- commons-beanutils:commons-beanutils:1.9.4
|    |     --- commons-logging:commons-logging:1.2
|    |    \--- commons-collections:commons-collections:3.2.2
|     --- commons-digester:commons-digester:2.1
|     --- commons-logging:commons-logging:1.2
|    \--- commons-collections:commons-collections:3.2.2
\--- org.apache.httpcomponents:httpclient:4.5.13
      --- org.apache.httpcomponents:httpcore:4.4.13
      --- commons-logging:commons-logging:1.2
     \--- commons-codec:commons-codec:1.11

This graph shows that org.apache.httpcomponents:httpclient:4.5.13 (which you explicitly mention in your dependencies) depends upon commons-codec:commons-codec:1.11 and therefore commons-codec:commons-codec:1.11 is included in your project as well.

  • Related