Skip to content

Commit b7c4c31

Browse files
committed
Merge branch 'master' into feature/searchable-snapshots
2 parents 037a9be + 687c888 commit b7c4c31

File tree

645 files changed

+19723
-3972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

645 files changed

+19723
-3972
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
*.ipr
66
*.iws
77
build-idea/
8+
out/
9+
10+
# include shared intellij config
11+
!.idea/scopes/x_pack.xml
12+
!.idea/inspectionProfiles/Project_Default.xml
13+
814
# These files are generated in the main tree by IntelliJ
915
benchmarks/src/main/generated/*
1016

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/scopes/x_pack.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CONTRIBUTING.md

Lines changed: 25 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ using the wrapper via the `gradlew` script on Unix systems or `gradlew.bat`
111111
script on Windows in the root of the repository. The examples below show the
112112
usage on Unix.
113113

114-
We support development in the Eclipse and IntelliJ IDEs.
115-
For Eclipse, the minimum version that we support is [4.13][eclipse].
116-
For IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij].
114+
We support development in IntelliJ versions IntelliJ 2019.2 and
115+
onwards. We would like to support Eclipse, but few of us use it and has fallen
116+
into [disrepair][eclipse].
117117

118118
[Docker](https://docs.docker.com/install/) is required for building some Elasticsearch artifacts and executing certain test suites. You can run Elasticsearch without building all the artifacts with:
119119

@@ -123,48 +123,18 @@ You can access Elasticsearch with:
123123

124124
curl -u elastic:password localhost:9200
125125

126-
### Configuring IDEs And Running Tests
127-
128-
Eclipse users can automatically configure their IDE: `./gradlew eclipse`
129-
then `File: Import: Gradle : Existing Gradle Project`.
130-
Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying
131-
`eclipse.ini` accordingly to avoid GC overhead and OOM errors.
132-
133-
IntelliJ users can automatically configure their IDE: `./gradlew idea`
134-
then `File->New Project From Existing Sources`. Point to the root of
135-
the source directory, select
136-
`Import project from external model->Gradle`, enable
137-
`Use auto-import`. In order to run tests directly from
138-
IDEA 2017.2 and above, it is required to disable the IDEA run launcher in order to avoid
139-
`idea_rt.jar` causing "jar hell". This can be achieved by adding the
140-
`-Didea.no.launcher=true` [JVM
141-
option](https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties).
142-
Alternatively, `idea.no.launcher=true` can be set in the
143-
[`idea.properties`](https://www.jetbrains.com/help/idea/file-idea-properties.html)
144-
file which can be accessed under Help > Edit Custom Properties (this will require a
145-
restart of IDEA). For IDEA 2017.3 and above, in addition to the JVM option, you will need to go to
146-
`Run->Edit Configurations->...->Defaults->JUnit` and verify that the `Shorten command line` setting is set to
147-
`user-local default: none`. You may also need to [remove `ant-javafx.jar` from your
148-
classpath](https://github.com/elastic/elasticsearch/issues/14348) if that is
149-
reported as a source of jar hell.
150-
151-
To run an instance of elasticsearch from the source code run `./gradlew run`
152-
153-
The Elasticsearch codebase makes heavy use of Java `assert`s and the
154-
test runner requires that assertions be enabled within the JVM. This
155-
can be accomplished by passing the flag `-ea` to the JVM on startup.
156-
157-
For IntelliJ, go to
158-
`Run->Edit Configurations...->Defaults->JUnit->VM options` and input
159-
`-ea`.
160-
161-
For Eclipse, go to `Preferences->Java->Installed JREs` and add `-ea` to
162-
`VM Arguments`.
163-
164-
Some tests related to locale testing also require the flag
165-
`-Djava.locale.providers` to be set. Set the VM options/VM arguments for
166-
IntelliJ or Eclipse like describe above to use
167-
`-Djava.locale.providers=SPI,COMPAT`.
126+
### Importing the project into IntelliJ IDEA
127+
128+
Elasticsearch builds using Java 13. Before importing into IntelliJ you will need
129+
to define an appropriate SDK. The convention is that **this SDK should be named
130+
"13"** so that the project import will detect it automatically. For more details
131+
on defining an SDK in IntelliJ please refer to [their documentation](https://www.jetbrains.com/help/idea/sdk.html#define-sdk).
132+
133+
You can import the Elasticsearch project into IntelliJ IDEA via:
134+
135+
- Select **File > Open**
136+
- In the subsequent dialog navigate to the root `build.gradle` file
137+
- In the subsequent dialog select **Open as Project**
168138

169139
### REST Endpoint Conventions
170140

@@ -212,14 +182,7 @@ Please follow these formatting guidelines:
212182
part of a file. Please format such sections sympathetically with the rest
213183
of the code, while keeping lines to maximum length of 76 characters.
214184
* Wildcard imports (`import foo.bar.baz.*`) are forbidden and will cause
215-
the build to fail. This can be done automatically by your IDE:
216-
* Eclipse: `Preferences->Java->Code Style->Organize Imports`. There are
217-
two boxes labeled "`Number of (static )? imports needed for .*`". Set
218-
their values to 99999 or some other absurdly high value.
219-
* IntelliJ: `Preferences/Settings->Editor->Code Style->Java->Imports`.
220-
There are two configuration options: `Class count to use import with
221-
'*'` and `Names count to use static import with '*'`. Set their values
222-
to 99999 or some other absurdly high value.
185+
the build to fail.
223186
* If *absolutely* necessary, you can disable formatting for regions of code
224187
with the `// tag::NAME` and `// end::NAME` directives, but note that
225188
these are intended for use in documentation, so please make it clear what
@@ -234,9 +197,6 @@ Please follow these formatting guidelines:
234197

235198
#### Editor / IDE Support
236199

237-
Eclipse IDEs can import the file [.eclipseformat.xml]
238-
directly.
239-
240200
IntelliJ IDEs can
241201
[import](https://blog.jetbrains.com/idea/2014/01/intellij-idea-13-importing-code-formatter-settings-from-eclipse/)
242202
the same settings file, and / or use the [Eclipse Code
@@ -393,26 +353,9 @@ It is important that the only code covered by the Elastic licence is contained
393353
within the top-level `x-pack` directory. The build will fail its pre-commit
394354
checks if contributed code does not have the appropriate license headers.
395355

396-
You may find it helpful to configure your IDE to automatically insert the
397-
appropriate license header depending on the part of the project to which you are
398-
contributing.
399-
400-
#### IntelliJ: Copyright & Scope Profiles
401-
402-
To have IntelliJ insert the correct license, it is necessary to create to copyright profiles.
403-
These may potentially be called `apache2` and `commercial`. These can be created in
404-
`Preferences/Settings->Editor->Copyright->Copyright Profiles`. To associate these profiles to
405-
their respective directories, two "Scopes" will need to be created. These can be created in
406-
`Preferences/Settings->Appearances & Behavior->Scopes`. When creating scopes, be sure to choose
407-
the `shared` scope type. Create a scope, `apache2`, with
408-
the associated pattern of `!file[group:x-pack]:*/`. This pattern will exclude all the files contained in
409-
the `x-pack` directory. The other scope, `commercial`, will have the inverse pattern of `file[group:x-pack]:*/`.
410-
The two scopes, together, should account for all the files in the project. To associate the scopes
411-
with their copyright-profiles, go into `Preferences/Settings->Editor>Copyright` and use the `+` to add
412-
the associations `apache2/apache2` and `commercial/commercial`.
413-
414-
Configuring these options in IntelliJ can be quite buggy, so do not be alarmed if you have to open/close
415-
the settings window and/or restart IntelliJ to see your changes take effect.
356+
> **NOTE:** If you have imported the project into IntelliJ IDEA the project will
357+
> be automatically configured to add the correct license header to new source
358+
> files based on the source location.
416359
417360
### Creating A Distribution
418361

@@ -425,7 +368,7 @@ cd elasticsearch/
425368
To build a darwin-tar distribution, run this command:
426369

427370
```sh
428-
./gradlew -p distribution/archives/darwin-tar assemble --parallel
371+
./gradlew -p distribution/archives/darwin-tar assemble
429372
```
430373

431374
You will find the distribution under:
@@ -435,9 +378,12 @@ To create all build artifacts (e.g., plugins and Javadocs) as well as
435378
distributions in all formats, run this command:
436379

437380
```sh
438-
./gradlew assemble --parallel
381+
./gradlew assemble
439382
```
440383

384+
> **NOTE:** Running the task above will fail if you don't have a available
385+
> Docker installation.
386+
441387
The package distributions (Debian and RPM) can be found under:
442388
`./distribution/packages/(deb|rpm|oss-deb|oss-rpm)/build/distributions/`
443389

@@ -570,10 +516,6 @@ known as "transitive" dependencies".</dd>
570516
should not be shipped with the project because it is "provided" by the runtime
571517
somehow. Elasticsearch plugins use this configuration to include dependencies
572518
that are bundled with Elasticsearch's server.</dd>
573-
<dt>`bundle`</dt><dd>Only available in projects with the shadow plugin,
574-
dependencies with this configuration are bundled into the jar produced by the
575-
build. Since IDEs do not understand this configuration we rig them to treat
576-
dependencies in this configuration as `compile` dependencies.</dd>
577519
<dt>`testCompile`</dt><dd>Code that is on the classpath for compiling tests
578520
that are part of this project but not production code. The canonical example
579521
of this is `junit`.</dd>
@@ -608,6 +550,5 @@ Finally, we require that you run `./gradlew check` before submitting a
608550
non-documentation contribution. This is mentioned above, but it is worth
609551
repeating in this section because it has come up in this context.
610552

611-
[eclipse]: https://download.eclipse.org/eclipse/downloads/drops4/R-4.13-201909161045/
612553
[intellij]: https://blog.jetbrains.com/idea/2017/07/intellij-idea-2017-2-is-here-smart-sleek-and-snappy/
613-
[shadow-plugin]: https://github.com/johnrengelman/shadow
554+
[eclipse]: https://github.com/elastic/elasticsearch/issues/53664

TESTING.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ To create a platform-specific build including the x-pack modules, use the
2020
following depending on your operating system:
2121

2222
-----------------------------
23-
./gradlew :distribution:archives:linux-tar:assemble --parallel
24-
./gradlew :distribution:archives:darwin-tar:assemble --parallel
25-
./gradlew :distribution:archives:windows-zip:assemble --parallel
23+
./gradlew :distribution:archives:linux-tar:assemble
24+
./gradlew :distribution:archives:darwin-tar:assemble
25+
./gradlew :distribution:archives:windows-zip:assemble
2626
-----------------------------
2727

2828
=== Running Elasticsearch from a checkout
@@ -51,6 +51,10 @@ recommended to configure the IDE to initiate multiple listening attempts. In cas
5151
is called "Auto restart" and needs to be checked. In case of Eclipse, "Connection limit" setting
5252
needs to be configured with a greater value (ie 10 or more).
5353

54+
NOTE: If you have imported the project into IntelliJ according to the instructions in
55+
link:/CONTRIBUTING.md#importing-the-project-into-intellij-idea[CONTRIBUTING.md] then a debug run configuration
56+
named "Debug Elasticsearch" will be created for you and configured appropriately.
57+
5458
==== Distribution
5559

5660
By default a node is started with the zip distribution.

build.gradle

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
* under the License.
1818
*/
1919

20-
2120
import com.avast.gradle.dockercompose.tasks.ComposePull
2221
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
22+
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
2323
import org.apache.tools.ant.taskdefs.condition.Os
2424
import org.elasticsearch.gradle.BuildPlugin
2525
import org.elasticsearch.gradle.BwcVersions
2626
import org.elasticsearch.gradle.Version
2727
import org.elasticsearch.gradle.VersionProperties
2828
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
29+
import org.gradle.plugins.ide.eclipse.model.AccessRule
2930
import org.gradle.plugins.ide.eclipse.model.SourceFolder
3031
import org.gradle.util.DistributionLocator
3132
import org.gradle.util.GradleVersion
@@ -43,6 +44,7 @@ apply plugin: 'nebula.info-scm'
4344
apply from: 'gradle/build-scan.gradle'
4445
apply from: 'gradle/build-complete.gradle'
4546
apply from: 'gradle/runtime-jdk-provision.gradle'
47+
apply from: 'gradle/ide.gradle'
4648

4749
// common maven publishing configuration
4850
allprojects {
@@ -180,7 +182,6 @@ allprojects {
180182
System.getProperty("eclipse.application") != null || // Detects gradle launched from the Eclipse compiler server
181183
gradle.startParameter.taskNames.contains('eclipse') || // Detects gradle launched from the command line to do eclipse stuff
182184
gradle.startParameter.taskNames.contains('cleanEclipse')
183-
isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea')
184185

185186
// for BWC testing
186187
bwcVersions = versions
@@ -356,36 +357,6 @@ gradle.projectsEvaluated {
356357
}
357358
}
358359

359-
// intellij configuration
360-
allprojects {
361-
apply plugin: 'idea'
362-
363-
if (isIdea) {
364-
project.buildDir = file('build-idea')
365-
}
366-
idea {
367-
module {
368-
inheritOutputDirs = false
369-
outputDir = file('build-idea/classes/main')
370-
testOutputDir = file('build-idea/classes/test')
371-
372-
// also ignore other possible build dirs
373-
excludeDirs += file('build')
374-
excludeDirs += file('build-eclipse')
375-
}
376-
}
377-
378-
tasks.named('cleanIdea') {
379-
delete 'build-idea'
380-
}
381-
}
382-
383-
idea {
384-
project {
385-
vcs = 'Git'
386-
}
387-
}
388-
389360
// eclipse configuration
390361
allprojects {
391362
apply plugin: 'eclipse'
@@ -408,6 +379,21 @@ allprojects {
408379
}
409380
}
410381
}
382+
/*
383+
* Allow accessing com/sun/net/httpserver in projects that have
384+
* configured forbidden apis to allow it.
385+
*/
386+
plugins.withType(ForbiddenApisPlugin) {
387+
eclipse.classpath.file.whenMerged { classpath ->
388+
if (false == forbiddenApisTest.bundledSignatures.contains('jdk-non-portable')) {
389+
classpath.entries
390+
.findAll { it.kind == "con" && it.toString().contains("org.eclipse.jdt.launching.JRE_CONTAINER") }
391+
.each {
392+
it.accessRules.add(new AccessRule("accessible", "com/sun/net/httpserver/*"))
393+
}
394+
}
395+
}
396+
}
411397

412398
File licenseHeaderFile
413399
String prefix = ':x-pack'

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import org.gradle.api.artifacts.Dependency
4646
import org.gradle.api.artifacts.ModuleDependency
4747
import org.gradle.api.artifacts.ProjectDependency
4848
import org.gradle.api.artifacts.dsl.RepositoryHandler
49+
import org.gradle.api.artifacts.repositories.ExclusiveContentRepository
4950
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
5051
import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout
5152
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
@@ -327,10 +328,16 @@ class BuildPlugin implements Plugin<Project> {
327328
// extract the revision number from the version with a regex matcher
328329
List<String> matches = (luceneVersion =~ /\w+-snapshot-([a-z0-9]+)/).getAt(0) as List<String>
329330
String revision = matches.get(1)
330-
repos.maven { MavenArtifactRepository repo ->
331+
MavenArtifactRepository luceneRepo = repos.maven { MavenArtifactRepository repo ->
331332
repo.name = 'lucene-snapshots'
332333
repo.url = "https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/${revision}"
333334
}
335+
repos.exclusiveContent { ExclusiveContentRepository exclusiveRepo ->
336+
exclusiveRepo.filter {
337+
it.includeVersionByRegex(/org\.apache\.lucene/, '.*', ".*-snapshot-${revision}")
338+
}
339+
exclusiveRepo.forRepositories(luceneRepo)
340+
}
334341
}
335342
}
336343

buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestTestsTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void copy() {
114114
if (BuildParams.isInternal()) {
115115
getLogger().debug("Rest tests for project [{}] will be copied to the test resources.", project.getPath());
116116
project.copy(c -> {
117-
c.from(coreConfig.getSingleFile());
117+
c.from(coreConfig.getAsFileTree());
118118
c.into(getOutputDir());
119119
c.include(corePatternSet.getIncludes());
120120
});
@@ -138,7 +138,7 @@ void copy() {
138138
if (includeXpack.get().isEmpty() == false) {
139139
getLogger().debug("X-pack rest tests for project [{}] will be copied to the test resources.", project.getPath());
140140
project.copy(c -> {
141-
c.from(xpackConfig.getSingleFile());
141+
c.from(xpackConfig.getAsFileTree());
142142
c.into(getOutputDir());
143143
c.include(xpackPatternSet.getIncludes());
144144
});

0 commit comments

Comments
 (0)