Monday, March 04, 2013

Gradle

Gradle is my new build tool favourite. I love the groovy syntax, and built in libraries, and find it a huge improvements on maven and ant.

gradle tasks   // This will list all tasks that build file supports
To exclude a task -x

e.g. to exclude tests from a build

gradle build -x test 

Gradle comes with a series of plugins which can be used for commonly executed builds, e.g. java, groovy, also ones for IDE's such as idea and eclipse. These provide tasks commonly used with these.

e.g.
apply plugin: 'java'   // Provides build compile test testCompile
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin:'application'



Running gradle tasks on this gives
C:\svn>gradle tasks
:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Application tasks
-----------------
distTar - Bundles the project as a JVM application with libs and OS specific scripts.
distZip - Bundles the project as a JVM application with libs and OS specific scripts.
installApp - Installs the project as a JVM application along with libs and OS specific scripts.
run - Runs this project as a JVM application

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles the main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles the test classes.

Documentation tasks
-------------------
groovydoc - Generates Groovydoc API documentation for the main source code.
javadoc - Generates Javadoc API documentation for the main source code.

Help tasks
----------
dependencies - Displays all dependencies declared in root project 'myproj'.
dependencyInsight - Displays the insight into a specific dependency in root project 'myproj'.
help - Displays a help message
projects - Displays the sub-projects of root project 'colline'.
properties - Displays the properties of root project 'colline'.
tasks - Displays the tasks runnable from root project 'colline' (some of the displayed tasks may belong to subprojects).

IDE tasks
---------
cleanEclipse - Cleans all Eclipse files.
cleanIdea - Cleans IDEA project files (IML, IPR)
eclipse - Generates all Eclipse files.
idea - Generates IDEA project files (IML, IPR, IWS)

Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

Other tasks
-----------
cleanIdeaWorkspace
dist
wrapper

Rules
-----
Pattern: build: Assembles the artifacts of a configuration.
Pattern: upload: Assembles and uploads the artifacts belongin
g to a configuration.
Pattern: clean: Cleans the output files of a task.

To see all tasks and more detail, run with --all.

BUILD SUCCESSFUL

No comments: