[SOLVED] Gradle n00b... what's wrong with my gradle build?

The version on github worked until alpha4:

Now I tried with these modifications:

apply plugin: 'java'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

ext {
    jmonkeyengine_version = '[3.1,)'
}

repositories {
    jcenter()
}

dependencies {
    compile fileTree(dir: 'lib', include: ['*.jar'])
        
        compile "com.jme3:jme3-core:$jmonkeyengine_version.+"


}

sourceSets {
    main {
        java { srcDir 'src'}
        resources { srcDir 'assets' }
    }
}

But still no luck :frowning:

what’s the “.+” at the end of line? remove this.

Still no luck.

  • What went wrong:
    Could not resolve all dependencies for configuration ‘:compile’.

Could not find any version that matches com.jme3:jme3-core:[3.1,).
Searched in the following locations:
https://jcenter.bintray.com/com/jme3/jme3-core/maven-metadata.xml
https://jcenter.bintray.com/com/jme3/jme3-core/
Required by:
:GoldMonkey:unspecified

Yeah, right now you are effectively using version: [3.1,).+

…which isn’t anything real.

see the dot on the end?

Yes but where does it come from?

apply plugin: ‘java’

sourceCompatibility = ‘1.8’
[compileJava, compileTestJava].options.encoding = ‘UTF-8’

// NetBeans will automatically add “run” and “debug” tasks relying on the
// “mainClass” property. You may however define the property prior executing
// tasks by passing a “-PmainClass=<QUALIFIED_CLASS_NAME>” argument.
//
// Note however, that you may define your own “run” and “debug” task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty(‘mainClass’)) {
ext.mainClass = ‘’
}

ext {
jmonkeyengine_version = ‘[3.1,)’
}

repositories {
jcenter()
}

dependencies {
compile fileTree(dir: ‘lib’, include: [’*.jar’])

    compile "com.jme3:jme3-core:$jmonkeyengine_version"

}

sourceSets {
main {
java { srcDir ‘src’}
resources { srcDir ‘assets’ }
}
}

Can you check out this version and see if it still works?

I’m preparing postmortem slides for a meeting so I cannot do it right now. If it works then it will be a starting place for sorting out your issue.

It works. Now I throw away my gradle and copy yours?

Solved!

The problem was this:

compile "com.jme3:jme3-core:$jmonkeyengine_version"
         ^^^^^^^^^^^
compile "org.jmonkeyengine:jme3-core:$jmonkeyengine_version"
         ^^^^^^^^^^^^^^^^^^^^^

Thanks! :slight_smile:

1 Like

Now I’ve added the line

compile 'org.slf4j:slf4j-api:1.7.13'

Full source:

apply plugin: 'java'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

ext {
   jmonkeyengine_version = '[3.1,)'
}

repositories {
    jcenter()
}

dependencies {
   compile fileTree(dir: 'lib', include: ['*.jar'])
        
       compile "org.jmonkeyengine:jme3-core:$jmonkeyengine_version"
      compile 'org.slf4j:slf4j-api:1.7.13'

}

sourceSets {
   main {
      java { srcDir 'src'}
      resources { srcDir 'assets' }
   }
}

And the LoggerFactory cannot be found… what did I miss? Thanks!

slf4j is just the api, you also need a implementation like log4j2 or logback that provides the actual stuff.

LoggerFactory is part of the sl4f-api.jar. But you need to also provide a backend like thoses listed by @Empire_Phoenix. Often I define the backend in scope runtime or testRuntime.

(slf4-api is define in scope compile, few line above)

1 Like

Now is like this:

apply plugin: 'java'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

ext {
   jmonkeyengine_version = '[3.1,)'
}

repositories {
    jcenter()
}

dependencies {
   compile fileTree(dir: 'lib', include: ['*.jar'])
        
       compile "org.jmonkeyengine:jme3-core:$jmonkeyengine_version"
      compile 'org.slf4j:slf4j-api:1.7.13'
      runtime 'ch.qos.logback:logback-classic:1.1.2'

}

sourceSets {
   main {
      java { srcDir 'src'}
      resources { srcDir 'assets' }
   }
}

But I still get
Error:(10, 17) java: package org.slf4j does not exist

Full log ?
Error in command line or in editor/IDE ?

On the idea IDE, however I tried with the command line:

http://pastebin.com/guHa1bHq

sl4fj has no log() that takes level. Your imports may be screwed up or your reference material.

1 Like

OK, in addition to that, I also needed to “sync” the idea project with the gradle project.

Thanks! :slight_smile: