Showing posts with label gradle. Show all posts
Showing posts with label gradle. Show all posts

Thursday, April 2, 2015

Pouring Java

I've spent most of today working on some in-house tools for increasing productivity. I got tired of writing out boilerplate code for my Java classes, and using an IDE's class wizards was annoying me to no end, so I ended up writing a little command line utility which I call pour. Get it? You pour java...anyway...

I developed my little tool using Ruby, since it is so great for string manipulation, and easy file handling. Pour is short on features, but works exactly as I expect it to, and only outputs exactly what I want, and is far faster than any class wizard I've found.

I can specify a local template file to pour, and it will use it to create the classes, or, I can create a template in my home directory to use the template globally, or I can use the built-in template. I can specify to generate an entry point function, and I can specify a package. These few features turned a task that normally takes about 3 minutes, and turns it into about a 5 second task.

In addition, I set up gradle and grunt for a very simple auto-build workflow that allows me to focus on the code editing, and not on having to build the project, run tests, build the jar, and execute the program. I can just edit the code, save it, and my auto-build setup does the rest. Very fast workflow. I like it a lot, and I'm going to have to find a similar solution for my C++ development now, because this kicks major ass.


Thursday, February 19, 2015

Testing libgdx projects on the desktop while using Android Studio

If you have tried to use libgdx with Android Studio and found that you are unable to run the Desktop build, I would like to inform you that it now indeed possible, just takes a few more steps than running the android build.

First in Android-Studio click on the Gradle tasks bar at the right side of the screen. Then click the little arrow on the left of your gradle project name under the All tasks category, scroll all the way down to the :desktop section and click on the right arrow on the left of :desktop, and again scroll down and find the run task and double-click on the run task.

This will attempt to run your desktop project. Provided you have no errors, you should see your libgdx game window appear just like it used to with the older style Eclipse based projects.

Now, once you have done this, you can click on the Run menu item in the main window menu bar and choose Edit Configurations.

You should now have a new Run/Debug Configuration under the Gradle section called yourprojectname:desktop [run]. You may use this new configuration to run your desktop project without needing to find the run task in the long list of tasks.

I hope that this little mini tutorial has helped you work more efficiently with libgdx and Android Studio. It certainly was a wonderful thing to find today for me, as I have been cursing out Android Studio for it's lack of desktop application support ever since I downloaded it.

I used to curse about libgdx adopting Gradle for it's projects, but now, I certainly agree that it was a good move, and that it makes things a lot simpler. It all needs better documentation though. Things like this should be available right in the setup docs, without having to dig into the software blindly and happen across the answer.