Ant usage in Gradle projects, with XMLBeans as an example

Porjects, which are running on Ant today, can also think about a movement to Gradle. This is of course the point of view in the Gradle community. Gradle deliver an Ant and Maven integration. That is one reason, why you get the current Ant version installed on your machine, when running the commandgradle -v.

------------------------------------------------------------
Gradle 1.4
------------------------------------------------------------

Gradle build time: Montag, 28. Januar 2013 03:42 Uhr UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_17 (Oracle Corporation 23.7-b01)
OS: Mac OS X 10.8.3 x86_64

In Gradle scripts you can link Ant tasks, or you can call Ant commands. Here now an example, how to use Ant taskdef within Gradle, and as exmaple the Apache XML Beans lib is used. XML Beans is a JAXB implementation.
Ant usage in Gradle projects, with XMLBeans as an example weiterlesen

Create Eclipse projects with the usage of Gradle

Why using a build tool, to create Eclipse projects files, which are only created once? When you are working in a distributed team, with multiple developers on different platforms (like Linux, Windows or Mac OS X), you want them to create their own Eclipse project files, in their environment – and you don’t want these files to be shared in your version control system. But you really want, that the use the same folder and project structure, with the same external libs (in maybe different locations).

It could also make sense, to recreate the project files, when you’ve added some new libs to your project – which you not want to share via your VCS system.

What do you need to do, to get Gradle to support you.
Create Eclipse projects with the usage of Gradle weiterlesen

Create Java projects with Gradle

So far Ant was my preferred tool, to create and build Java projects. But in the last days, I’ve looked into the next gen – Gradle.

It is a matter of taste, if you prefer XML or a DSL document. At the moment, I think XML is a little bit more user friendly, because you can validate the structure before you run it. I don’t see that for Gradle at the moment (maybe, the Eclipse plugin created by the Spring team is such a solution).

Gradle is, like I’ve read it in a book, the next evolution step after Ant and Maven. The reason for that is, because Gradle is different, and it makes some parts „easier“, as the old Java build tools. But to make it easier, you always need to define some requirements, which were not so defined in Ant. In an Ant project, you as the creator of the project, were responsible for the project folder structure. You’ve defined, where the sources and the classes are stored. Gradle out of the box, does this for you. So you need to follow this requirements.
Benefit is, if you know one Gradle project, you know them all, from the structure perspective. I don’t need to think about, where are the sources, I will always find them under src/main/java, same for the compiled classes, they are always under build/classes/main. With this pre defined structure, I need only one line, to create a build script for my simple project.
Create Java projects with Gradle weiterlesen