@@ -21,22 +21,18 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
2121
2222/**
2323 * The rest client is a shaded jar. It contains the source of the rest client, as well as all the dependencies,
24- * shaded to the `org.elasticsearch.client` package. 3 artifacts come out of this build process. The shading process only
25- * modifies the imports and class names and locations. It does not do any processing on the files. The classes used to
26- * interact with the rest client are no different from the dependencies in the shade configuration, besides in name.
24+ * shaded to the `org.elasticsearch.client` package. 2 artifacts come out of this build process. The shading process
25+ * only modifies the imports and class names and locations. It does not do any processing on the files. The classes used
26+ * to interact with the rest client are no different from the dependencies in the shade configuration, besides in name.
2727 *
2828 * IDEs do not like removing artifacts and changing configurations on the fly, so the bits that make the build use the
29- * actual shaded jar (3 ) are only executed on the cli. Tests run in an IDE rely on the deps (1) and nodeps (2) jars .
29+ * actual shaded jar (2 ) are only executed on the cli. Tests run in an IDE rely on the deps (1) jar .
3030 *
31- * 1) A jar that contains *only* the `org.elasticsearch.client` dependencies. This is a jar that is built before the src
32- * is compiled. This jar is only used by the rest client so its compilable. There exists a chicken-egg situation where
33- * the src needs compilation and depends on `org.elasticsearch.client` classes, so an intermediary jar needs to exist
34- * to satisfy the compile. The `deps` classifier is added to this jar.
35- * 2) The original src/ contents, using the `org.elasticsearch.client` packages, but without the `org.elasticsearch.client`
36- * code also in the jar. The reason this jar was not overwritten was because gradle knows what its inputs and outputs
37- * are for a given task and we should not alter that by overwriting the original jar. What we do is add a `nodeps`
38- * classifier to it instead.
39- * 3) The *actual* jar that will be used by clients. This has no classifier, contains the rest client src and
31+ * 1) A jar that contains *only* the `org.elasticsearch.client` shaded dependencies. This is a jar that is built before
32+ * the src is compiled. This jar is only used by the rest client so will compile. There exists a chicken-egg
33+ * situation where the src needs compilation and depends on `org.elasticsearch.client` shaded classes, so an
34+ * intermediary jar needs to exist to satisfy the compile. The `deps` classifier is added to this jar.
35+ * 2) The *actual* jar that will be used by clients. This has no classifier, contains the rest client src and
4036 * `org.elasticsearch.client`. This jar is the only actual output artifact of this job.
4137 */
4238plugins {
@@ -84,28 +80,18 @@ task shadeDeps(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar)
8480 }
8581}
8682
87- // builds the actual shaded jar that is being distributed
88- shadowJar {
89- configurations = [project. configurations. shade]
90- classifier = null
91- relocate ' org.apache' , ' org.elasticsearch.client'
92- }
93-
9483jar {
95- // move the default jar to another classifier so the jar with the shaded dependencies can have the empty classifier
96- classifier = ' nodeps '
84+ from zipTree(shadeDeps . outputs . files . singleFile)
85+ dependsOn shadeDeps
9786}
9887
99- // Mangle this build so it outputs the correct artifacts
100- // readds the shadowJar output (the actual uber jar) but only from the cli
88+ // remove the deps jar from the classpath to avoid jarHell
10189if (isIdea == false && isEclipse == false ) {
102- // removes the -nodeps jar
103- configurations. runtime. artifacts. removeAll { it. archiveTask. is jar }
104-
105- // removes the runtime configuration inheritance from compile
106- configurations. runtime. extendsFrom - = [configurations. compile]
107- artifacts {
108- runtime project. tasks. shadowJar
90+ // cleanup to remove the deps jar from the classpath
91+ if (gradle. gradleVersion == " 3.3" ) {
92+ configurations. runtime. extendsFrom - = [configurations. compile]
93+ } else if (gradle. gradleVersion > " 3.3" ) {
94+ configurations. runtimeElements. extendsFrom = []
10995 }
11096}
11197
0 commit comments