Alpha2 from command line gradle question

I am trying to get jmonkey working from command line. Then eventually Intellij with the new alpha2 code
I have this as my build.gradle

apply plugin : 'java'
apply plugin  : 'application'

mainClassName = "com.scriptblocks.jmonkeytest.Main"

repositories {
    mavenCentral()
jcenter()
maven { url 'http://updates.jmonkeyengine.org/maven' }
maven { url 'https://jcenter.bintray.com/org/jmonkeyengine/'}

}

def jmonkeyengine_version = '3.1'
dependencies {
compile "com.jme3:jme3-core:$jmonkeyengine_version.+"
compile "com.jme3:jme3-effects:$jmonkeyengine_version.+"
compile "com.jme3:jme3-networking:$jmonkeyengine_version.+"
compile "com.jme3:jme3-plugins:$jmonkeyengine_version.+"
compile "com.jme3:jme3-jogg:$jmonkeyengine_version.+"
compile "com.jme3:jme3-terrain:$jmonkeyengine_version.+"
compile "com.jme3:jme3-blender:$jmonkeyengine_version.+"
compile "com.jme3:jme3-jbullet:$jmonkeyengine_version.+"
// compile "com.jme3:jme3-niftygui:$jmonkeyengine_version.+"
compile "com.jme3:jme3-desktop:$jmonkeyengine_version.+"
compile "com.jme3:jme3-lwjgl:$jmonkeyengine_version.+"
runtime "com.jme3:jme3-lwjgl:$jmonkeyengine_version.+"
}

and this as my only class file

package com.scriptblocks.jmonkeytest;

   import com.jme3.app.SimpleApplication;
    import com.jme3.material.Material;
    import com.jme3.math.Vector3f;
    import com.jme3.scene.Geometry;
    import com.jme3.scene.shape.Box;
    import com.jme3.math.ColorRGBA;
/**
 * Created by gbluntzer on 3/13/2016.
 */
public class Main extends SimpleApplication {

public static void main(String[] args){
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp() {
    Box b = new Box(Vector3f.ZERO, 1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    Material mat = new Material(assetManager,
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    geom.setMaterial(mat);
    rootNode.attachChild(geom);
}
}

Two Questions
First, is the gradle build file correct? am I using the right value for def jmonkeyengine_version = ‘3.1’

Second question is the java code correct.

When I set the gradle value from 3.1 to 3.0 the application will launch and i will see the setup screen then the blue cube
When I use 3.1 it will also launch but nothing will be on screen not status text or blue cube and no error will be thrown.

Thanks for any help

If you are going to use a + then you should put it up there.

…but the property way is to use range notation:
def jmonkeyengine_version = ‘[3.1,)’

Really, 3.0 shouldn’t have worked at all and makes me wonder what version you were getting.

If you want to see an example (one I posted in a couple other threads) you can look here:

Thanks @pspeed it worked with intellij community edition after using your sample build file

Some notes for others

get the sample gradle file from git

from command line > gradle run

Start intellij make sure you are using the 64bit version of the IDE if you are using 64bit java (other wise you will get “supplied javaHome seems to be invalid”)

File | New Project from existing src. Find the build.gradle file

Once its done importing click on the Edit Configuration drop down

Add a new gradle configuration and fill in project (find folder with build.gradle) and set task as “run”

1 Like