Tutorial for creating-multi-project-builds needs help


(Peter Ruffner) #1

This must get old but a search didn’t find anything.
I was doing the Gradle tutorials for creating-multi-project-builds and was unable to run the Greeter.java file from JME3/Netbeans IDE. It works from the command line because Gradle (gradlew) creates a groovy library for the run and then deletes it afterwords. I searched and found that I needed to make the (Groovy)Library jar. I did that, added it to my project and ran the greeter project again and get the ClassNotFoundException groovy.lang.GroovyObject error. It’s not in the library/jar. (Whine)

  1. How can I add groovy.lang.GroovyObject?
  2. In Library.groovy, you have
    ‘’’
boolean someLibraryMethod(){
    true
}

What does this do? Do you have to call one method so the compiler finds the right library? Can you add a constructor? What about a method without a return value?


(James Justinic) #2

After reading your post and questions, it doesn’t seem that any of them are actually related to the Creating Multi-project Builds Guide. If you follow the guide as written, you shouldn’t encounter any of the items that you’re asking about.

Without seeing what you found, this at least sounds like some confusion about the implementation JARs Gradle generates for its own runtime. The JARs that are generated for this relate to the execution of Gradle. To run a Groovy application, you need Groovy, but that’s just a normal dependency JAR. You get that in your project by the line it tutorial that reads compile 'org.codehaus.groovy:groovy:2.4.10'.

If you’re wanting to use NetBeans to work on Gradle projects with Groovy, you should activate the Gradle and Groovy plugins. If NetBeans is functioning properly, it will pull in all required dependencies declared by Gradle into the classpath when you run the file. It seems like your real question here is how to use a Gradle project in NetBeans. Your issue with GroovyObject will go away if that’s working.

There is no Library.groovy in the guide. That file comes from gradle init --type groovy-library, which just creates a contrived sample project. The method simply returns true so that the sample has something to compile and run a sample test against. It’s pointless except as a sample. You’d replace that code with your actual code if you used gradle init --type groovy-library as a starting point for a library written in Groovy.


(Peter Ruffner) #3

Thank you. That all makes sense. I shouldn’t try something new after midnight.