Search code examples
gradlelibgdxmaven-2sonatype

Generate Project: HUGE downloads


I created my first LibGDX project using the Libgdx Project generator. I then opened the project in IntelliJ, upon which it asked me to index the repositories in the build.gradle file. The remote repositories in question were:

  • Maven2
  • all of the oss.sonatype snapshots
  • all of the oss.sonatype releases

All together this totalled about 5 to 6 GB of stuff, that intelliJ happily started downloading. Because it was taking ages to complete, I started looking through some of those repositories. Typically the point of using repo managers like gradle is that for the libraries you're using, you don't downloading the whole thing, just the parts you need. However, sonatype snapshots and releases are full of huge amounts of files and lots and lots of different versions/releases.

My question is: Is supposed to be downloading all of those files or did I miss something? Is there a way I can only download the bits and pieces that I need?

Here is my complete build.gradle:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "HelloWorld"
        gdxVersion = '1.9.6'
        roboVMVersion = '2.3.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    }
}

tasks.eclipse.doLast {
    delete ".project"
}

Solution

  • Not required to download all injected library with all versions.

    If you build with gradle then it only download required artifact with only version that you injected.

    Indexing a maven repository

    A maven repository is made up of artifact and different versions of those artifact. My guess is that when an IDE like IntelliJ for example reads the remote repository, it will create a separate local cache/mini database of library names+versions available in the repository on machine. That is the indexing part. This makes searching for library names/latest versions etc much faster, as it is now being done consulting the index on your machine instead of accessing the repository each time.

    Its nothing major and won't affect your builds, but what your IDE is simply telling is that whenever its looking for a version/dependency name (during auto-complete etc) its having to go online and check for those details (instead of just checking the local cache).

    • Advantage of indexing - search speed
    • Disadvantage - you have to ensure the index is kept up to date otherwise your won't always get up to date search results (new versions etc) also somehow 5 to 6 GB is download is painful.

    You can disable this notification, If you want by clicking Disable:

    Unindexed remote maven repositories found. Disable...

    or on Mac OSX Go to

    IntellijIDEA > Preferences > Appearance & Behavior > Notifications > Unindexed maven repositories gradle detection > Uncheck

    Leave Unindexed remote maven repo, each time if artifact with particular version not found in local repo then it search to remote.