# Need help grokking gradle build

**URL:** <https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927>\
**Category:** Elasticsearch\
**Created:** [October 13, 2017, 4:09pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927 "2017-10-13T16:09:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 13, 2017, 4:09pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/1 "2017-10-13T16:09:35Z")

</div>

I am adding a test fixture to a plugin of mine and I am using the  
elasticsearch build tools defined in the build plugin. I am using the  
example-fixture as a guide:

> <https://github.com/elastic/elasticsearch/blob/5.4/test/fixtures/example-fixture/build.gradle>

The plugin is recognized correctly and things work well until the Forbidden  
APIs check:

> Task :test/fixtures/db-fixture:forbiddenApisMain  
> [snip]  
> build-tools/5.4.1/f18e5d8b1efc699ab21ec3863bf8fae24a5b93e8/build-tools-5.4.1.jar!/forbidden/es-all-signatures.txt

FAILURE: Build failed with an exception.

- What went wrong:  
Execution failed for task ':test/fixtures/db-fixture:forbiddenApisMain'.

> Parsing signatures failed: Class 'org.apache.lucene.index.IndexReader'  
> not found on classpath while parsing signature:  
> org.apache.lucene.index.IndexReader#getCombinedCoreAndDeletesKey()

Obviously the classpath is not defined correctly for the fixture. Since the  
gradle build process in elasticsearch is top-down, the example-fixture is  
meaningless outside of the entire elasticsearch gradle build context. I am  
no gradle maven (pun intended), but this step should be easy enough to  
figure out. 🙂 Trying to figure out where in build.gradle the dependencies  
are being set for the dependencies. Perhaps it is inside one of the  
plugins. Does anyone knowledgable of the build process have an idea? Basing  
things off of 5.4 for now.

Cheers,

Ivan

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [October 13, 2017, 5:52pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/2 "2017-10-13T17:52:53Z")

</div>

We actually have forbidden apis, among other things, disabled for fixtures. You can see this in `test/build.gradle`.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 13, 2017, 7:30pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/3 "2017-10-13T19:30:50Z")

</div>

Thanks Ryan. I was hoping you would chime in since you provided some good  
input last time (finally have a chance to revisit this project).

Totally missed the fact that :test was a sub-project. I see the fixtures  
getting included in settings.gradle, but not :test. Since I am learning  
about the build, where is that done? In the end, I disabled many tasks:

dependencyLicenses.enabled = false  
forbiddenApisMain.enabled = false  
jarHell.enabled = false  
licenseHeaders.enabled = false  
test.enabled = false  
thirdPartyAudit.enabled = false

Now comes the fun part of kicking off the fixture before running the tests!  
I'll try to compile my notes on how to create a minimal plugin/fixture  
outside of the elasticsearch build context. Of course, things might change  
with 6.x.

Cheers,

Ivan

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [October 13, 2017, 11:11pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/4 "2017-10-13T23:11:58Z")

</div>

> [@Ivan](#):
>
> Now comes the fun part of kicking off the fixture before running the tests!
> 
> I'll try to compile my notes on how to create a minimal plugin/fixture
> 
> outside of the elasticsearch build context.

You're one of the first people I've heard of doing this. so we would greatly value your feedback on the process when you have it all working. I would love to have a more complete section in the docs for plugin authors, especially in regards to how to test.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 19, 2017, 5:15am UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/5 "2017-10-19T05:15:54Z")

</div>

I will gladly play the role of the guinea pig. At least this time there is  
a team to answer questions, although things were easier when it was only  
Shay. 🙂 Hopefully you are still on the line.

Trying to create a minimalist fixture. Come to find out that the pid and  
ports files are required when using an AntFixture. The pid file I can  
understand, but the ports file is not always necessary. I guess one task I  
can document is what is expected by AntFixture. The plugins are dependent  
on the fixtures to create the files, which is a weird dependency. What if  
there are no fixtures, or more than one?

Even starting off with a near empty fixture causes failures. Either the  
fixture stalls during Thread.sleep with no integration tests run, or the  
integration cluster fails to start. Occasionally the code runs without any  
modifications.

Setting system properties in integTestRunner has no effect, unlike the  
elasticsearch plugins, which means the task is not run. The closure seems  
to have run. Something is being set by the parent build, but I cannot find  
it.

Upgraded to elasticsearch 5.5.2 for the jstack debugging output, but not to  
5.6 since I do not want to deal with another check (license). Very strange  
that the code will alternate between stalling on the task, failing to start  
the cluster, and just working (the rare event). The fixture does not need  
the elasticsearch build plugin since it should be simply a Java program.

[https://gist.github.com/brusic/c312b5aa708e564d100a8b1fa60b3388](https://gist.github.com/brusic/c312b5aa708e564d100a8b1fa60b3388)

Any insights?

---

<div class="post-metadata">

**Author:** ![Itamar\_Syn\_Hershko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamar_syn_hershko/32/725_2.png) [@Itamar\_Syn\_Hershko](https://discuss.elastic.co/u/Itamar_Syn_Hershko)\
**Post date:** [November 7, 2017, 7:52pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/6 "2017-11-07T19:52:05Z")

</div>

I'm playing quite a lot with plugins myself and there are some undocumented prerequisites.

It's been a while but iirc for integTests to run and pass you have to put some yml files declaring at least one REST API test (under resources/rest-api-spec/test/) e.g. [https://github.com/BigDataBoutique/elasticsearch-repository-swift/tree/master/src/test/resources/rest-api-spec/test](https://github.com/BigDataBoutique/elasticsearch-repository-swift/tree/master/src/test/resources/rest-api-spec/test). And you have to have at least one IT and the IntegTest class, see here: [https://github.com/BigDataBoutique/elasticsearch-repository-swift/tree/master/src/test/java/org/wikimedia/elasticsearch/swift](https://github.com/BigDataBoutique/elasticsearch-repository-swift/tree/master/src/test/java/org/wikimedia/elasticsearch/swift)

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 7, 2017, 11:41pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/7 "2017-11-07T23:41:57Z")

</div>

Thanks Itamar for responding to this somewhat old thread.

I was able to get almost everything running, the only thing that I have but  
figured out is integration testing and jar hell. I wrote up my findings  
here: [https://github.com/brusic/plugin-with-fixture-skeleton](https://github.com/brusic/plugin-with-fixture-skeleton)

I came across the testing requirements, but did not need any REST test, but  
that is perhaps I did not create new REST endpoints in this example.

With the plugin gradle plugin, there is a call to the jar task that I  
cannot seem to override in order to create an uber jar.

Cheers,

Ivan

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 5, 2017, 11:42pm UTC](https://discuss.elastic.co/t/need-help-grokking-gradle-build/103927/8 "2017-12-05T23:42:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
