From 5496fd34077a3d4bf753e4ccf3fcef3558df7457 Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Wed, 18 May 2016 14:14:25 -0400 Subject: [PATCH] Adding more Gradle cheatsheet info Original commit: elastic/x-pack-elasticsearch@4439769da6f64d70de9ee35bea79d0f968ecf97e --- GRADLE.CHEATSHEET.asciidoc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/GRADLE.CHEATSHEET.asciidoc b/GRADLE.CHEATSHEET.asciidoc index 0e0003bd3d0..dae39da38a7 100644 --- a/GRADLE.CHEATSHEET.asciidoc +++ b/GRADLE.CHEATSHEET.asciidoc @@ -6,9 +6,11 @@ $ mkdir elastic $ cd elastic $ git clone git@github.com:elastic/elasticsearch.git $ git clone git@github.com:elastic/x-plugins.git +$ git clone git@github.com:elastic/kibana.git <1> ---- +<1> For anyone doing UI development, it's also useful to have Kibana at the same level. -Once cloned, any command should be issused from the **elasticsearch** directory. +Once cloned, any command should be executed from the **elasticsearch** directory. This ensures that the full dependency tree is available. [source,bash] ---- @@ -17,6 +19,14 @@ $ gradle clean test check <1> ---- <1> This will run the `clean` task, `test` task, and then the `check` task on _every_ project that has it. However, `check` requires that `test` be run, so it won't _rerun_ `test`. `clean` is unnecessary here, but people often use it anyway. +If this command were run in a different order, then it would still follow the same rules, but the behavior would change: + +[source,bash] +---- +$ gradle check test clean <1> +---- +<1> It would run every task that `check` requires (e.g., `test` and `integTest`), skips `test` because it has already been run (indirectly by `check`), and then finally it would _wastefully_ delete every project output. + As a quick helper, below are the equivalent commands from `maven` to `gradle`. You can also run `gradle tasks` to see all tasks that are available to run. [cols="3*", options="header"] @@ -24,7 +34,7 @@ As a quick helper, below are the equivalent commands from `maven` to `gradle`. Y | Maven | Gradle | Description | `clean` | `clean` | Delete anything that exists already. You do _not_ generally need to run `clean` with Gradle for any task that _Gradle_ manages the inputs/outputs (in other words, it knows when it needs to rebuild versus reuse). | `test` | `test` | Run all unit tests. -| `verify` | `check` | Run all tests, plus extra checks (e.g., line length). +| `verify` | `check` | Run all tests, plus extra checks (e.g., `checkStyle`, `forbiddenApis`, etc.). | `verify -Dskip.unit.tests` | `integTest` | Run only integration tests. | `package -DskipTests` | `assemble` | Output is in `${project.projectDir}/build/distributions` | `install -DskipTests` | `install` | Build jars and place them into the local _Maven_ repository (yes, even with Gradle). @@ -32,6 +42,15 @@ As a quick helper, below are the equivalent commands from `maven` to `gradle`. Y This should be unnecessary with the unified build! |==== +The full task list, with a minor breakout as a graph of dependencies can be seen with: + +[source,bash] +---- +$ gradle tasks --all +---- + +Given that we currently have 80 projects, this can be extremely verbose. + With Gradle, you can easily target specific `projects` to run commands against, and it will build all necessary dependencies to make it happen. For example, if you make a change to a specific test in the `x-pack` subproject, then you can specifically invoke its `test` task. [source,bash]