Maven repositories

This build.gradle “worked” i e my game starts now if I use this build file.

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'

mainClassName = 'spaceworld.SpaceUFO'

repositories {
    jcenter()
}

ext.jmeVersion = "[3.1,)"

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

    buildDir = rootProject.file("build/assets")

    sourceSets {
        main {
            resources {
                srcDir '.'
            }
        }
    }
}
repositories {
    mavenCentral()
    maven {
        url "https://mvnrepository.com/artifact/cz.advel.jbullet/jbullet"

    }
    maven {
        url 'http://nifty-gui.sourceforge.net/nifty-maven-repo'
    }

}



dependencies {

    compile "org.jmonkeyengine:jme3-core:$jmeVersion"
    compile "org.jmonkeyengine:jme3-desktop:$jmeVersion"
    compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion"
    compile "org.jmonkeyengine:jme3-blender:$jmeVersion"
    compile "org.jmonkeyengine:jme3-bullet:$jmeVersion"
    compile "org.jmonkeyengine:jme3-plugins:$jmeVersion"
    compile "org.jmonkeyengine:jme3-networking:$jmeVersion"
    compile 'lessvoid:nifty:1.4.1'
    compile 'lessvoid:nifty-default-controls:1.4.1'
    compile 'lessvoid:nifty-style-black:1.4.1'
    compile group: "cz.advel.jbullet", name: "jbullet", version: "20101010"



    compile files('libs/cai-nmgen-0.2.0.jar')
    compile files('libs/ext.bundle.opengl.jmonkey-1.1.3.jar')
    runtime project(':assets')
}

task wrapper(type: Wrapper) {
}

task createDirs << {

    def pkg = 'spaceworld'
    def dirs = [
            file("./src/main/java/$pkg"),
            file("./src/main/resources"),
            file("./assets/Interface"),
            file("./assets/MatDefs"),
            file("./assets/Materials"),
            file("./assets/Models"),
            file("./assets/Scenes"),
            file("./assets/Shaders"),
            file("./assets/Sounds"),
            file("./assets/Textures"),
    ]

    dirs.each {
        if (!it.exists()) {
            println "Creating " + it
            it.mkdirs()
        }
        if (it.listFiles().length == 0) {
            def stub = new File(it, 'removeme.txt')
            println "Creating stub file to allow git checkin, file:$stub"
            stub.text = "Remove me when there are files here."
        }
    }
}

Thanks for all the help. I’m still learning gradle. It seems better than maven.

That much is definitely true.

Note: you may not need the createDirs() thing copied from my example. Though I guess it does no harm to leave it.

1 Like

@niklasro

The repositories you add with url like below

are not valid url for a repository that follow the maven repository layout.
It’s the url of a html page on the site, a site that is a search engine on the central maven repository.
So you can remove

    maven {
        url "https://mvnrepository.com/artifact/cz.advel.jbullet/jbullet"
    }

I don’t understand how your conf could work, because you missed:

  • the jme3 jbullet adapter layer.
  • jme3 run with a customized jbullet fork

Why don’t you want to use the recommended jme3-bulltet-native for 3.1.x ?

for nifty you can try the new version that is available on mavenCentral() and jcenter()

compile 'com.github.nifty-gui:nifty:1.4.2'

in this case you can remove

    maven {
        url 'http://nifty-gui.sourceforge.net/nifty-maven-repo'
    }

Content of repository mavenCentral() is included in jcenter()
So if you follow previous point, in your build.gradle you could stay with only one repository (a good practice with only 1 repository defined)

repositories {
    jcenter()
}
...
repositories {
    mavenCentral()
    maven {
        url "https://mvnrepository.com/artifact/cz.advel.jbullet/jbullet"

    }
    maven {
        url 'http://nifty-gui.sourceforge.net/nifty-maven-repo'
    }

}

become (merge group)

repositories {
    jcenter()
    mavenCentral()
    maven {  url "https://mvnrepository.com/artifact/cz.advel.jbullet/jbullet" }
    maven {  url 'http://nifty-gui.sourceforge.net/nifty-maven-repo' }
}

become (remove duplicate, and wrong repo)

repositories {
    jcenter()
    maven {  url 'http://nifty-gui.sourceforge.net/nifty-maven-repo' }
}

become (remove nifty-maven-repo if you upgrade to a new version)

repositories {
    jcenter()
}

He seems to use a Convert class that is only in the JME jbullet tree. At least that’s what my brief github searching showed.