Gradle Build System

rapodaca

New Member
Contributor
I've just sent a pull request that changes the build system to Gradle. If you're not familiar with this system, this short video does a good job of showing how easy it is to get started:

http://www.youtube.com/watch?v=wN8bFn9Yp8Q

There are a number of reasons to make the switch:

1) Gradle is easy - for reals! :)
2) No XML
3) Pure Groovy
4) Excellent documentation: http://gradle.org/
5) There's a company behind this software and it's getting updated regularly.
6) There's a growing community behind this system.
7) The new build system works almost identically to the old one in terms of output directory layout.
8) The project structure was not changed (although some files made obsolete were removed).
9) We can take advantage of Maven repositories without having to use Maven.
10) First-class IDE support. Import projects into Eclipse, IntelliJ, or Netbeans.

There is one downside:

1) You'll need to install Gradle:

http://gradle.org/installation

Fortunately, this is as easy as installing Ant.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Bump - more activity on the pull request. Works great now, but we also have a potential dilemma on picking between out-of-the-box run from source without Gradle vs having the full power in effect with a mandatory Gradle setup
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Done! Tested the latest changes and accepted the Pull request into Develop.

Pro: It works! Comes with new spiffy features, including all the predefined Gradle plugins

Con: Cloning a fresh local source setup leavings you without an IDE setup. Running "gradle idea" sets you up with IntelliJ but you'll have to set up JDK, Run config, Git, etc.

I'm not totally on top of figuring that out myself yet, was able to get Terasology running just fine, and the changes means for instance that T3's audio changes (that change out some lib jars) run right out of the box (well, other than a conflict, anyway) while normally it would also need Gant tweaks.

But I haven't gotten Git integration set again yet :)

Richard - it looks like you can do some configuration with the idea plugin, I wonder if that includes Git prep, run config, or something else? Does the gradle eclipse set up config for some of the tool integration?

The develop branch in Jenkins is now building via Gradle :)

http://www.movingblocks.net:8080/jenkins/job/Terasology

Note, Terasology.zip still got listed for build #104 as it hung out in the output dir. I deleted it manually and ran #105 which only links to Terasology-0.5.0.zip. The versioning ties to a property in build.gradle we should probably look to change / automate.

Everybody - please review, and backup your local .idea dir if you want to keep it. You may be able to run normally if you don't delete it, but Gradle does tinker with dependencies some so you'll need to run "gradle idea" at least once.

If Gradle is too tricky to deal with solo we can probably re-introduce the normal .idea and Gant pieces. You might want to not update right away if you don't want to tinker with IDE reconfig.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Addendum - just merged in immortius' refactoring too, and aaiiieee am I feeling helpless without Git integration in IntelliJ.

https://github.com/MovingBlocks/Terasol ... e727f658aa

Somehow I managed it, even screwing up the command line commit message so I had to edit it in VIM - which was about the scariest thing I've done since I blew up the develop branch (VIM is the DwarfFortress version of Notepad, I swear!) :p

Yet to my surprise it seems to have worked. My commit message got messed up a bit (I guess trying to use special characters did something funny in VIM...) but it looks to have pushed correctly AND associated it with the open pull request magically, closing it.

It even built and plays OK! Well, with broken shaders, but that's independent :)

http://www.movingblocks.net:8080/jenkin ... ology/106/

Ooookay, not going to push my luck any more tonight.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Bump - anybody looked at the Gradle stuff yet, or tweaks for getting IntelliJ back up to speed?
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Works perfectly here using IntelliJ! Like it! :geek:
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Okay, did a pile of Gradle talk in IRC tonight, immortius even started tinkering with adding guava to the build file, and after cleaning some workspaces it sounds like most of us are on track to run with the new stuff :)

Thanks for the new shinies, rapodaca!

We can make it a little fancier when we get a chance, and we (or at least I) need to remember to enable it when we push to the master branch next.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
More Gradle stuffs added: https://github.com/MovingBlocks/Terasology/issues/68 with a branch for testing at https://github.com/MovingBlocks/Terasol ... 8fea514a45

Could somebody test it please?

1) Pull branch to clean dir (clone fresh or whatever)
2) Run "gradlew idea" (should work on either Windows or via bash shell)
3) Open IntelliJ, set GRADLE_HOME under Settings / Gradle
4) Restart IntelliJ
5) See if the Gradle GUI sidebar thingie pops up (you may have to install it as an IntelliJ plugin)
6) Try command line tab there with command "dist" (can add to favorites) and see if it works
7) If you hit a JAVA_HOME issue set the env var IDEA_HOME to a normal JDK and restart
8) Possibly set "Use custom Gradle Executor" on the setup tab of the GUI

There's a bit of a chicken & egg situation at hand here. Gradle GUI the sidebar thingie doesn't pop up until you set GRADLE_HOME under project settings, but after you get the GUI you have the option to instead use the gradlew now in the source tree.... to bypass having a GRADLE_HOME in the first place

I wonder if you can use gradlew idea to custom-install the plugin + set it to use gradlew - argh ;)

Probably should be using my time more constructively, but... puzzles!

On the plus side anybody just wanting to run from source should be able to do so now without installing Gradle, just won't get the nice Gradle GUI unless that puzzle can be solved.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps

soren renner

New Member
on linux : gradlew eclipse claims to succeed but where are the generated project files?


sr@aptosidbox:~/dev/Terasology$ ./gradlew idea
:ideaModule
:ideaProject
:ideaWorkspace
:idea

BUILD SUCCESSFUL

Total time: 6.692 secs
sr@aptosidbox:~/dev/Terasology$ ls
applet gradlew libs out SAVED_WORLDS Terasology.ipr
blender_addons gradlew.bat LICENSE.txt protobuf scripts Terasology.iws
build.gradle groovy logs rawMesh src tests
gradle integration natives README.markdown Terasology.iml

sr@aptosidbox:~/dev/Terasology$ ./gradlew eclipse
:eclipseClasspath
:eclipseJdt
:eclipseProject
:eclipse

BUILD SUCCESSFUL

Total time: 6.258 secs
sr@aptosidbox:~/dev/Terasology$ ls
applet gradlew libs out SAVED_WORLDS Terasology.ipr
blender_addons gradlew.bat LICENSE.txt protobuf scripts Terasology.iws
build.gradle groovy logs rawMesh src tests
gradle integration natives README.markdown Terasology.iml
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
I believe the generated project files for eclipse are all hidden under linux (start with a '.' - e.g. '.project').
I could be wrong though.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
In theory you should be able to

1) Open Eclipse
2) Enter the path to the Terasology directory as your workspace
3) Profit. And a magically working workspace.

At least that's how I remember Eclipse - you're wanting to load the predefined workspace which should be as simple as just picking the Terasology dir, then Eclipse looks for that .project directory

If that doesn't work - then likely the .project dir or Eclipse's reading of it is borked somehow, possibly specific to your OS / env config / settings / etc?
 

ironchefpython

Member
Contributor
Architecture
In practice, the steps I followed were as follows.

  1. Install the Gradle-Eclipse plugin as described here: http://static.springsource.org/sts/docs ... index.html
  2. Check out Terasology from github.
  3. Add it to Eclipse as a Gradle project.
  4. Profit. (there's no ??? step)
At this point you can right-click on build.gradle, and invoke a build target.

== EDIT ==

And I did not execute gradlew eclipse. No point.
 
Top