Hello Guest

Installing lwjgl 3 for eclipse using gradle

  • 8 Replies
  • 17535 Views
Installing lwjgl 3 for eclipse using gradle
« on: March 20, 2019, 00:26:31 »
The 1.2.-Install webpage under the eclipse section "highly recommends" using gradle/maven, so I figure that is probably what I should do.  Unfortunately I don't really know much of anything about either.  I research a bit and it seems like I should probably go with gradle.  I build a gradle download bundle whatever from the download page and I get a build.gradle file which I have no idea what to do with now.  It seems like everywhere I look everyone is just getting a zip and coping all the jar files into a new library folder.  So I get the impression nobody really uses the "high recommendation".  But maybe I am just misunderstanding something.  Is this a recommendation only if you are experienced with gradle or maven, and if not just use the zip file option?  If so, might be good to say something along those lines on this install webpage so folks like me don't get so confused.  So, if I should really be going the gradle route, could someone explain what I need to do with this build.gradle file and whatever else I might need to do to get eclipse to use it, etc.  The install page only says to use a gradle/maven project, but says nothing about how to use it.  If I should just do the zip copy to library thing than that's fine, just say so or if no one answers I'll just assume zip is the way to go and pretend I was never highly recommended to use gradle to begin with. :)

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Installing lwjgl 3 for eclipse using gradle
« Reply #1 on: March 20, 2019, 09:04:35 »
Both Maven and Gradle are extremely popular in the Java development community and there is a staggering amount of documentation/tutorials/examples available. Sorry, but teaching people how to use build systems is outside the scope of the LWJGL project. We don't have the resources to do it and it would be huge waste of time for no benefit at all. If you don't have experience with either and don't want to invest time in becoming familiar with them, you could use the zip distribution and setup the Eclipse project manually, that's totally fine (otherwise it wouldn't be an available option).

Re: Installing lwjgl 3 for eclipse using gradle
« Reply #2 on: March 20, 2019, 17:09:02 »
Ya, sorry.  I think I'm getting it now.  I didn't initially realize it was a build/make system.  I was under the impression is was some kind of automated installation/integration system for getting lwjgl and eclipse fused together so to speak.  Instead, I'm guessing this build.gradle is kind of an initial make file that handles building the lwjgl parts, and you'd expand on this file to include handling of your own project.  That might not be quite right but maybe close enough to the general idea.  So misunderstanding on my part.  Thanks for your patience.  I think I'll just go with the zip for now and revisit the gradle stuff later since I'm not doing anything complex enough right now to justify using it.  More important things to learn first like how to use lwjgl. :)

*

Offline KaiHH

  • ****
  • 334
Re: Installing lwjgl 3 for eclipse using gradle
« Reply #3 on: March 20, 2019, 17:20:51 »
Considering any possible future for you as a programmer, I'd say learning Gradle/Maven instead of LWJGL is a hugely better investment. On top of that: When people say "learning LWJGL" most of the time what they actually wanted to say was "learning OpenGL".
What I observe is that there is a somewhat big misunderstanding in the world of people watching YouTube tutorials/videos what LWJGL is. LWJGL is an enabling technology to just be able to use OpenGL, OpenAL, OpenCL, Vulkan, and a whole host of other native libraries, in Java via JNI. On top of that, it provides handling native/off-heap memory. And that's basically it.
So, when you are learning LWJGL you are learning OpenGL.

Now on the topic of build systems: Using a build system has little to do with the complexity of your project. There are so many valuable benefits that Maven/Gradle will bring to you compared to a manual setup in Eclipse:
1. With a single click of a button or command line execution you can automatically retrieve the latest version of all LWJGL libraries you use
2. IDEs provide automatic setup of a Maven/Gradle project. You don't have to download the LWJGL and potentially other libraries from somewhere, unpack the zip into some folder, open some IDE like Eclipse and setup the libraries there properly. All of this is done automatically. So: Maven pom.xml or Gradle build.gradle file read? -> boom! IDE configuration auto-generated by the IDE when importing the project description.
3. Most of the benefits are for collaborative work, though: Being able to build a project WITHOUT people having to have an IDE (i.e. the same IDE) like Eclipse installed. This enables continuous build with a build server like Travis.

The bottom line is: Even simply using Maven/Gradle to setup your project is way simpler and requires faaar fewer steps than setup using a zip file you have to manually download, unpack and setup in your IDE.

Re: Installing lwjgl 3 for eclipse using gradle
« Reply #4 on: March 20, 2019, 23:34:17 »
Wow, you really make it sound amazing!  So yes, I would like to use gradle.  And so I've been looking around and trying to learn more about it.  Seems similar to make, which I've used in the past.  I'm unclear how to get it to work with eclipse though.  I try going to File -> Import -> Existing Gradle Project, point it to a directory where I put the build.gradle file, and I ultimately end up with the following error:

Code: [Select]
Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.8.1-bin.zip'.
Build file 'D:\Dev\lwjgl-3.2.1\build.gradle' line: 11
A problem occurred evaluating root project 'lwjgl-3.2.1'.
Could not find method implementation() for arguments [org.lwjgl:lwjgl:3.2.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Things are not seeming very intuitive, and I don't really know where to go exactly for answers.  It always seems like getting setup to program is always more difficult than actually programming.  Was true 20 years ago and appears to still be true today.  I am an experienced programmer, btw.  While new to Java and it's trappings, I have a lot of experience with C/C++, though I admit I've haven't really been active with it that recently.  I have worked with OpenGL before, with C++ through the SDL library, and I'm thinking that lwjgl is kind of similar in nature to what SDL is all about, which is why I wanted to utilize it.  I think I would be good to go if I could just figure out how to get eclipse and lwjgl working together in harmony.  If you can suggest any good starting points for learning gradle from the ground up, would be much appreciated.

*

Offline KaiHH

  • ****
  • 334
Re: Installing lwjgl 3 for eclipse using gradle
« Reply #5 on: March 21, 2019, 08:49:04 »
You are getting the error because the snippet generator on lwjgl.org/customize will only generate what is necessary to integrate LWJGL into your Gradle/Maven project file. It does not generate a complete build file as that will highly depend on your preferences or other configurations you chose for your project.
What you can do is first download Gradle (of course) and then cd into a directory where you want to initialize your project and then execute `gradle init` and answer its questions. This will generate a complete gradle setup for you.

Re: Installing lwjgl 3 for eclipse using gradle
« Reply #6 on: March 21, 2019, 14:08:30 »
Thank you for this information.  Quick question, though.  When you say project, are you referring to my project that I would be writing and compiling, or are you talking about the lwjgl library as a project (i.e. doing 'gradle init' in /lwjgl3).

*

Offline KaiHH

  • ****
  • 334
Re: Installing lwjgl 3 for eclipse using gradle
« Reply #7 on: March 21, 2019, 14:17:12 »
How likely is it that, with the three times I wrote "your [Gradle/Maven] project", I meant the lwjgl3 github repository source tree? I did mean YOUR project.
So, create an empty folder somewhere - that is to say NOT in the lwjgl3 source tree - and call `gradle init`.
« Last Edit: March 21, 2019, 14:23:07 by KaiHH »

Re: Installing lwjgl 3 for eclipse using gradle
« Reply #8 on: March 22, 2019, 00:13:54 »
FYI, I think your 1.2 install page is out of date with regards to manually installing via zip file.  Step 5 says to "Go to <lwjgl3> and select all *.jar files which do not have -javadoc or -sources in their names."  There are no *.jar files in this directory.  They are all in subdirectories.  I am guessing you'd need to repeat the add process for each subdirectory.  Just wanted to point this out, but I won't follow any further replies to this.  I've had enough abuse so I'll try and find answers elsewhere.