Cygwin documentation.
========
Gradle
========
.. contents::
:local:
Getting help
============
::
$ gradle --help
Working with subprojects
========================
Getting list of subprojects::
$ gradle projects
Running build on specific subproject::
$ gradle :$SUB:clean
$ gradle -p $SUB clean
If subproject lies in hierarchy::
$ gradle :$SUB/$SUBSUB:clean
$ gradle -p $SUB/$SUBSUB clean
Skip building dependent modules, build just current module::
$ gradle -a build
$ gradle --no-rebuild build
$ gradle -a :client:build
Creating multilevel project::
$ mkdir $PRJROOT
$ cd $PRJROOT
$ mkdir lvl1 lvl1/lvl2
$ touch build.gradle lvl1/build.gradle lvl1/lvl2/build.gradle
$ { echo include "'lvl1'"; echo include "'lvl1/lvl2'"; } >settings.gradle
$ gradle projects
``settings.gradle`` can include per line or a list of subprojects::
include 'sub1', 'sub2', 'sub2'
include 'lvl1'
include 'lvl1/lvl2'
https://docs.gradle.org/current/userguide/intro_multi_project_builds.html
http://stackoverflow.com/questions/16976214/gradle-build-only-one-module
Managing tasks
==============
List tasks::
$ gradle tasks
Getting list of supported tasks in each subproject::
$ gradle tasks --all
Getting help on task::
$ gradle -q help --task build
Similar but to each task::
$ gradle model
Skip task during build with ``-x`` option::
$ gradle -x test build
$ gradle -x :core:build :client:build
Build sources
=============
::
$ gradle compileJava
$ gradle compileTestJava
Run main class
==============
::
$ gradle run
Run tests
=========
To run test::
$ gradle test
To skip tests in build::
$ gradle -x test build
Better solution involves passing system property with ``build.gradle``::
test.onlyIf { ! Boolean.getBoolean('skip.tests') }
To run tests with additional registered checks::
$ gradle check
.. note::
``--rerun-tasks`` option *specifies that any task optimization is ignored*.
In that way you may rerun tests even if there are no changed files::
$ gradle test --rerun-tasks
Stopping server
===============
::
$ gradle --stop
List project dependencies
=========================
List of project execution dependencies (it also download dependencies)::
$ gradle dependencies
$ gradle dependencies --configuration compile
$ gradle dependencies -p $SUBPROJ
$ gradle :$SUBPROJ:dependencies
$ gradle :$SUBPROJ:dependencies --configuration testCompile
List of project plugin dependencies::
$ gradle buildEnvironment
$ gradle buildEnvironment -p $SUBPROJ
$ gradle :$SUBPROJ:buildEnvironment
Paths to dependencies can be printed via task::
task printDepPaths {
doLast { configurations.runtime.each { println it } }
}
All dependencies can be copied to single directory via task::
task copyRuntimeLibs(type: Copy) {
into "lib"
from configurations.runtime
// from configurations.testRuntime - configurations.runtime
}
List project properties
=======================
::
$ gradle properties
$ gradle :$SUBPROJ:properties
$ gradle properties -p $SUBPROJ
Dry tun
=======
``-m`` option allow parsing build scripts without actually executing them::
$ gradle -m clean compile