Entries by Erik Pragt

Gradle: renaming build.gradle to moduleName.gradle

When working with multimodule projects, having many build.gradle files with the same name can be confusing. Gradle provides a way to change this behaviour by using the settings.gradle file, which you can put in your project. An example settings.gradle file is listed below.

As you can see here, the buildFileName of the main project […]

Gradle: displaying artefact locations

Gradle’s output, unlike verbose build tools like Maven, is very terse. In my opinion, a bit too terse. For example, when running gradle jar, this is the output: :epub-organizer-core:compileJava UP-TO-DATE :epub-organizer-core:processResources UP-TO-DATE :epub-organizer-core:classes UP-TO-DATE :epub-organizer-core:jar UP-TO-DATE :epub-organizer-dropwizard:compileJava UP-TO-DATE :epub-organizer-dropwizard:processResources UP-TO-DATE :epub-organizer-dropwizard:classes UP-TO-DATE :epub-organizer-dropwizard:jar UP-TO-DATE BUILD SUCCESSFUL Total time: 13.752 secs Okay, that’s nice, looks good, […]

Gradle: creating executable jars for DropWizard

Some days ago, I created a Simple REST interface for my Open Source Epub organizer. I used the excellent DropWizard documentation, which guides you through the process. However, the DropWizard documentation uses Maven. While that’s not really a problem, I’m trying to switch to Gradle. For creating a executable jar in Gradle, there are some […]

Jacoco code coverage with Gradle

One of the new features of Gradle 1.6, the Groovy based build tool, is Jacoco support. Jacoco is one of the few (only?) Open Source code coverage tools still in active development, and starting from Gradle 1.6, it’s now a supported plugin. Enabling the task is easy, just add

to your build.gradle, and run […]

Creating projects with Gradle

Coming from a Maven background (Maven 1, 2, 3), I find it a bit strange that Gradle doesn’t provide archetypes like Maven does. There’s a template plugin, which helps a little, but besides that, you’re out of luck. Or are you? I found a pretty neat Gradle script in their Jira system, which can create […]

Reviving Groovy in Action

Some time ago, Dierk Koenig decided to write Groovy in Action, THE bible for learning the Groovy language and some libraries around it. The book was written for Groovy 1.0, and it was a great reference (I learned my first Groovy from that book), and though outdated, it still is a great book. Then, some […]

Adding an alarm to Android Alarm clock

If you need to set an alarm from within your application, you might be guided to the android AlarmManager. While it’s possible to use the AlarmManager to fire an alarm, sometimes you want to use the alarm application the user has installed himserver. To do so, you can use AlarmClock. This can be done in […]

Introduction to Hamcrest Collection Matchers

Another post in the series of Hamcrest Matchers, a framework for writing test matcher objects. This week we’ll dive into collections and iterables, and we’ll see how we can use Hamcrest for making those asserts even more readable. In many software projects I encounter code like the following:

Or, even worse:

The second […]

Introduction to Hamcrest String Matchers

Another week, another blogpost. For those catching on just now, or finding this post using a search engine; I’m writing a series of posts about Hamcrest, a framework for writing test matcher objects, and showing you how to use Hamcrest. While the previous post was about the Core Matchers, the topic of this week is […]

Generate a toString using Guava Objects.toStringhelper with IntelliJ

In IntelliJ it’s possible to generate a toString using Alt+Insert (Windows) or Ctrl+N (Mac). In this dialog, you can choose to use different implementations, like a StringBuffer, a StringBuilder, Apache Commons ToStringBuilder, and more. But if you’re using Google Guava, you can create your own template in IntelliJ. To do so, do the following: Open […]