gradle.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sat, 18 Feb 2017 16:02:47 +0200
changeset 2094 33c10259cb4d
parent 2086 c07317dca036
child 2095 b9bf144836b8
permissions -rw-r--r--
Running build on specific subproject.


========
 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
  $ gradle -Pmodile=$SUB clean

https://docs.gradle.org/current/userguide/intro_multi_project_builds.html
http://stackoverflow.com/questions/16976214/gradle-build-only-one-module

Getting list of supported 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

Build sources
=============
::

  $ gradle compileJava
  $ gradle compileTestJava

Run main class
==============
::

  $ gradle run

Run tests
=========
::

  $ gradle test

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