How to learn about build systems. (Gradle, LibGDX)

Hello, I’m new here. I’ve been programming a game using LibGDX. However, unlike a lot of my previous games, I’ve been trying to be a lot more professional this time. Therefore, aside from very carefully examining and organizing my code, I’ve made a git repository that I’ve been pushing to. However, I’ve just been using Egit with Eclipse to do this, since I figured that it would be easier to use than the git console. The problem here is that I’m committing my code directly from the Eclipse project, and LibGDX uses linked resources for the asset folder. While this feature is very useful, it confuses Egit.

From what research I’ve done, it seems like it would be a much smarter idea to just push the source code as a build system and include instructions for building in the README in my repository. This would solve my linked resources problem, as well as allow my code to be built for multiple IDEs. However, while I THINK that I understand building code/what a build system is, I’ve no idea how to do it. I understand that LibGDX project files are built using Gradle. How do I “un-build” them, so as to upload to a repository, and then rebuild from that code? I’ve tried googling this, but the Gradle tutorials are very difficult to understand. Even a link to a beginner’s guide to build systems that assumes no knowledge of the subject would probably be helpful at this point. I hope someone can help me, and thank you in advance.

DaGamesta

You may be confusing several different things:

  • a build scripting system (e.g. Ant, Gradle, …)
  • a code repository (e.g. a SVN or GIT repository such as BitBucket or GitHub)
  • a compile environment (e.g. JDK)

The building is done by the compiler, such as the JDK, for example by calling javac.exe. Building means that the java files are compiled to class files and perhaps placed in a jar file.

To automate the building, typically build scripting systems such as Gradle are used. A build script describes what to compile and build. A build script could for example call javac on your java files and then place them in a runnable jar.

And finally you can store your source code, along with the build scripts, in a code repository. Typically you upload (“commit”) only the source files and the build script, and not the built class and jar files generated by the build script, but that is up to you.

So if you want to learn about build systems, for example Gradle in combination with LibGDX:

  • read more about how java applications are compiled
  • read the Gradle tutorials and docs
  • make a simple java project (for example a couple of classes with no libraries or natives) which you try to compile using a gradle build script you wrote yourself from scratch
  • take a close look at the libgdx gradle script, and try to see if you can figure out what it does (this may be a bit hard, though)

So, if I take the Gradle build settings and the source code, and upload them to my (bitbucket) repository, then anyone with Gradle and the proper libraries and such on their system can build the necessary project for their IDE? Thank you for the clarification, I’ll try taking a look at the Gradle setting files when I get home later.

Yes but you might have to add some files to the gitIgnore list as different IDEs create different files inside the project. Most of the files are ignored by default (.gitignore).