Skip to content

Commit

Permalink
Switch build system to Gradle
Browse files Browse the repository at this point in the history
See #13930
  • Loading branch information
rjernst committed Oct 29, 2015
1 parent 1194cd0 commit c86100f
Show file tree
Hide file tree
Showing 80 changed files with 4,191 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ logs/
.DS_Store
build/
target/
*-execution-hints.log
**/.local*
docs/html/
docs/build.log
/tmp/
Expand Down
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ Contributing to the Elasticsearch codebase

**Repository:** [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch)

Make sure you have [Maven](http://maven.apache.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE by running `mvn eclipse:eclipse` and then importing the project into their workspace: `File > Import > Existing project into workspace` and make sure to select `Search for nested projects...` option as Elasticsearch is a multi-module maven project. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors. Please make sure the [m2e-connector](http://marketplace.eclipse.org/content/m2e-connector-maven-dependency-plugin) is not installed in your Eclipse distribution as it will interfere with setup performed by `mvn eclipse:eclipse`.

Elasticsearch also works perfectly with Eclipse's [m2e](http://www.eclipse.org/m2e/). Once you've installed m2e you can import Elasticsearch as an `Existing Maven Project`.
Make sure you have [Gradle](http://gradle.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE by running `gradle eclipse` and then importing the project into their workspace: `File > Import > Existing project into workspace` and make sure to select `Search for nested projects...` option as Elasticsearch is a multi-module maven project. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors.

Please follow these formatting guidelines:

Expand All @@ -92,15 +90,15 @@ To create a distribution from the source, simply run:

```sh
cd elasticsearch/
mvn clean package -DskipTests
gradle assemble
```

You will find the newly built packages under: `./target/releases/`.
You will find the newly built packages under: `./distribution/build/distributions/`.

Before submitting your changes, run the test suite to make sure that nothing is broken, with:

```sh
mvn clean test -Dtests.slow=true
gradle check
```

Source: [Contributing to elasticsearch](https://www.elastic.co/contributing-to-elasticsearch/)
5 changes: 2 additions & 3 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,9 @@ We have just covered a very small portion of what Elasticsearch is all about. Fo

h3. Building from Source

Elasticsearch uses "Maven":http://maven.apache.org for its build system.
Elasticsearch uses "Gradle":http://gradle.org for its build system. You'll need to have a modern version of Gradle installed - 2.6 should do.

In order to create a distribution, simply run the @mvn clean package
-DskipTests@ command in the cloned directory.
In order to create a distribution, simply run the @gradle build@ command in the cloned directory.

The distribution for each project will be created under the @target/releases@ directory in that project.

Expand Down
98 changes: 45 additions & 53 deletions TESTING.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To create a distribution without running the tests, simply run the
following:

-----------------------------
mvn clean package -DskipTests
gradle assemble
-----------------------------

== Other test options
Expand All @@ -35,7 +35,7 @@ Use local transport (default since 1.3):
Alternatively, you can set the `ES_TEST_LOCAL` environment variable:

-------------------------------------
export ES_TEST_LOCAL=true && mvn test
export ES_TEST_LOCAL=true && gradle test
-------------------------------------

=== Running Elasticsearch from a checkout
Expand All @@ -55,20 +55,20 @@ run it using Maven:
Run a single test case (variants)

----------------------------------------------------------
mvn test -Dtests.class=org.elasticsearch.package.ClassName
mvn test "-Dtests.class=*.ClassName"
gradle test -Dtests.class=org.elasticsearch.package.ClassName
gradle test "-Dtests.class=*.ClassName"
----------------------------------------------------------

Run all tests in a package and sub-packages

----------------------------------------------------
mvn test "-Dtests.class=org.elasticsearch.package.*"
gradle test "-Dtests.class=org.elasticsearch.package.*"
----------------------------------------------------

Run any test methods that contain 'esi' (like: ...r*esi*ze...).

-------------------------------
mvn test "-Dtests.method=*esi*"
gradle test "-Dtests.method=*esi*"
-------------------------------

You can also filter tests by certain annotations ie:
Expand All @@ -81,23 +81,23 @@ You can also filter tests by certain annotations ie:
Those annotation names can be combined into a filter expression like:

------------------------------------------------
mvn test -Dtests.filter="@nightly and not @backwards"
gradle test -Dtests.filter="@nightly and not @backwards"
------------------------------------------------

to run all nightly test but not the ones that are backwards tests. `tests.filter` supports
the boolean operators `and, or, not` and grouping ie:


---------------------------------------------------------------
mvn test -Dtests.filter="@nightly and not(@badapple or @backwards)"
gradle test -Dtests.filter="@nightly and not(@badapple or @backwards)"
---------------------------------------------------------------

=== Seed and repetitions.

Run with a given seed (seed is a hex-encoded long).

------------------------------
mvn test -Dtests.seed=DEADBEEF
gradle test -Dtests.seed=DEADBEEF
------------------------------

=== Repeats _all_ tests of ClassName N times.
Expand All @@ -106,7 +106,7 @@ Every test repetition will have a different method seed
(derived from a single random master seed).

--------------------------------------------------
mvn test -Dtests.iters=N -Dtests.class=*.ClassName
gradle test -Dtests.iters=N -Dtests.class=*.ClassName
--------------------------------------------------

=== Repeats _all_ tests of ClassName N times.
Expand All @@ -115,7 +115,7 @@ Every test repetition will have exactly the same master (0xdead) and
method-level (0xbeef) seed.

------------------------------------------------------------------------
mvn test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.seed=DEAD:BEEF
gradle test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.seed=DEAD:BEEF
------------------------------------------------------------------------

=== Repeats a given test N times
Expand All @@ -125,14 +125,14 @@ ie: testFoo[0], testFoo[1], etc... so using testmethod or tests.method
ending in a glob is necessary to ensure iterations are run).

-------------------------------------------------------------------------
mvn test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
gradle test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
-------------------------------------------------------------------------

Repeats N times but skips any tests after the first failure or M initial failures.

-------------------------------------------------------------
mvn test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
mvn test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
gradle test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
gradle test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
-------------------------------------------------------------

=== Test groups.
Expand All @@ -142,9 +142,9 @@ Test groups can be enabled or disabled (true/false).
Default value provided below in [brackets].

------------------------------------------------------------------
mvn test -Dtests.nightly=[false] - nightly test group (@Nightly)
mvn test -Dtests.weekly=[false] - weekly tests (@Weekly)
mvn test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
gradle test -Dtests.nightly=[false] - nightly test group (@Nightly)
gradle test -Dtests.weekly=[false] - weekly tests (@Weekly)
gradle test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
------------------------------------------------------------------

=== Load balancing and caches.
Expand All @@ -154,7 +154,7 @@ By default, the tests run sequentially on a single forked JVM.
To run with more forked JVMs than the default use:

----------------------------
mvn test -Dtests.jvms=8 test
gradle test -Dtests.jvms=8
----------------------------

Don't count hypercores for CPU-intense tests and leave some slack
Expand All @@ -167,7 +167,7 @@ It is possible to provide a version that allows to adapt the tests behaviour
to older features or bugs that have been changed or fixed in the meantime.

-----------------------------------------
mvn test -Dtests.compatibility=1.0.0
gradle test -Dtests.compatibility=1.0.0
-----------------------------------------


Expand All @@ -176,50 +176,50 @@ mvn test -Dtests.compatibility=1.0.0
Run all tests without stopping on errors (inspect log files).

-----------------------------------------
mvn test -Dtests.haltonfailure=false test
gradle test -Dtests.haltonfailure=false
-----------------------------------------

Run more verbose output (slave JVM parameters, etc.).

----------------------
mvn test -verbose test
gradle test -verbose
----------------------

Change the default suite timeout to 5 seconds for all
tests (note the exclamation mark).

---------------------------------------
mvn test -Dtests.timeoutSuite=5000! ...
gradle test -Dtests.timeoutSuite=5000! ...
---------------------------------------

Change the logging level of ES (not mvn)
Change the logging level of ES (not gradle)

--------------------------------
mvn test -Des.logger.level=DEBUG
gradle test -Des.logger.level=DEBUG
--------------------------------

Print all the logging output from the test runs to the commandline
even if tests are passing.

------------------------------
mvn test -Dtests.output=always
gradle test -Dtests.output=always
------------------------------

Configure the heap size.

------------------------------
mvn test -Dtests.heap.size=512m
gradle test -Dtests.heap.size=512m
------------------------------

Pass arbitrary jvm arguments.

------------------------------
# specify heap dump path
mvn test -Dtests.jvm.argline="-XX:HeapDumpPath=/path/to/heapdumps"
gradle test -Dtests.jvm.argline="-XX:HeapDumpPath=/path/to/heapdumps"
# enable gc logging
mvn test -Dtests.jvm.argline="-verbose:gc"
gradle test -Dtests.jvm.argline="-verbose:gc"
# enable security debugging
mvn test -Dtests.jvm.argline="-Djava.security.debug=access,failure"
gradle test -Dtests.jvm.argline="-Djava.security.debug=access,failure"
------------------------------

== Backwards Compatibility Tests
Expand All @@ -230,15 +230,15 @@ To run backwards compatibilty tests untar or unzip a release and run the tests
with the following command:

---------------------------------------------------------------------------
mvn test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch -Dtests.security.manager=false
gradle test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch -Dtests.security.manager=false
---------------------------------------------------------------------------

Note that backwards tests must be run with security manager disabled.
If the elasticsearch release is placed under `./backwards/elasticsearch-x.y.z` the path
can be omitted:

---------------------------------------------------------------------------
mvn test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.security.manager=false
gradle test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.security.manager=false
---------------------------------------------------------------------------

To setup the bwc test environment execute the following steps (provided you are
Expand All @@ -250,19 +250,25 @@ $ curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elastic
$ tar -xzf elasticsearch-1.2.1.tar.gz
---------------------------------------------------------------------------

== Running integration tests
== Running verification tasks

To run the integration tests:
To run all verification tasks, including static checks, unit tests, and integration tests:

---------------------------------------------------------------------------
mvn verify
gradle check
---------------------------------------------------------------------------

Note that this will also run the unit tests first. If you want to just
run the integration tests only (because you are debugging them):
Note that this will also run the unit tests and precommit tasks first. If you want to just
run the integration tests (because you are debugging them):

---------------------------------------------------------------------------
mvn verify -Dskip.unit.tests
gradle integTest
---------------------------------------------------------------------------

If you want to just run the precommit checks:

---------------------------------------------------------------------------
gradle precommit
---------------------------------------------------------------------------

== Testing the REST layer
Expand All @@ -278,7 +284,7 @@ The REST tests are run automatically when executing the maven test command. To r
REST tests use the following command:

---------------------------------------------------------------------------
mvn verify -Dtests.filter="@Rest" -Dskip.unit.tests=true
gradle integTest -Dtests.filter="@Rest"
---------------------------------------------------------------------------

`RestNIT` are the executable test classes that runs all the
Expand All @@ -303,20 +309,6 @@ comma separated list of nodes to connect to (e.g. localhost:9300). A transport c
be created based on that and used for all the before|after test operations, and to extract
the http addresses of the nodes so that REST requests can be sent to them.

== Skip validate

To disable validation step (forbidden API or `// NOCOMMIT`) use

---------------------------------------------------------------------------
mvn test -Dvalidate.skip=true
---------------------------------------------------------------------------

You can also skip this by using the "dev" profile:

---------------------------------------------------------------------------
mvn test -Pdev
---------------------------------------------------------------------------

== Testing scripts

The simplest way to test scripts and the packaged distributions is to use
Expand All @@ -334,7 +326,7 @@ vagrant plugin install vagrant-cachier
. Validate your installed dependencies:

-------------------------------------
mvn -Dtests.vagrant -pl qa/vagrant validate
gradle :qa:vagrant:validate
-------------------------------------

. Download the VMs. Since Maven or ant or something eats the progress reports
Expand Down
Loading

0 comments on commit c86100f

Please sign in to comment.