Skip to content

Commit 6fd6895

Browse files
nik9000Christoph Büscher
and
Christoph Büscher
authored
Add new instruction for Eclipse (#54894)
These work *much* better. Co-authored-by: Christoph Büscher <[email protected]>
1 parent 7d8cf1c commit 6fd6895

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

CONTRIBUTING.md

+57-3
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ script on Windows in the root of the repository. The examples below show the
109109
usage on Unix.
110110

111111
We support development in IntelliJ versions IntelliJ 2019.2 and
112-
onwards. We would like to support Eclipse, but few of us use it and has fallen
113-
into [disrepair][eclipse].
112+
onwards and Eclipse 2020-3 and onwards.
114113

115114
[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:
116115

@@ -136,6 +135,62 @@ You can import the Elasticsearch project into IntelliJ IDEA via:
136135
- In the subsequent dialog navigate to the root `build.gradle` file
137136
- In the subsequent dialog select **Open as Project**
138137

138+
### Importing the project into Eclipse
139+
140+
Elasticsearch builds using Gradle and Java 13. When importing into Eclipse you
141+
will either need to use an appropriate JDK to run Eclipse itself (e.g. by
142+
specifying the VM in [eclipse.ini](https://wiki.eclipse.org/Eclipse.ini) or by
143+
defining the JDK Gradle uses by setting **Prefercences** > **Gradle** >
144+
**Advanced Options** > **Java home** to an appropriate version.
145+
146+
IMPORTANT: If you have previously imported the project by running `./gradlew eclipse`
147+
then you must build an entirely new workspace and `git clean -xdf` to
148+
blow away *everything* that the gradle eclipse plugin made.
149+
150+
- Select **File > Import...**
151+
- Select **Existing Gradle Project**
152+
- Select **Next** then **Next** again
153+
- Set the **Project root directory** to the root of your elasticsearch clone
154+
- Click **Finish**
155+
156+
This will spin for a long, long time but you'll see many errors about circular
157+
dependencies. Fix them:
158+
159+
- Select **Window > Preferences**
160+
- Select **Java > Compiler > Building**
161+
- Look under **Build Path Problems**
162+
- Set **Circular dependencies** to **Warning**
163+
- Apply that and let the build spin away for a while
164+
165+
Next you'll want to import our auto-formatter:
166+
167+
- Select **Window > Preferences**
168+
- Select **Java > Code Style > Formater**
169+
- Click **Import**
170+
- Import the file at **buildSrc/formatterConfig.xml**
171+
- Make sure it is the **Active profile**
172+
173+
Finally, set up import order:
174+
175+
- Select **Window > Preferences**
176+
- Select **Java > Code Style > Organize Imports**
177+
- Click **Import...**
178+
- Import the file at **buildSrc/elastic.importorder**
179+
- Set the **Number of imports needed for `.*`** to ***9999***
180+
- Set the **Number of static imports needed for `.*`** to ***9999*** as well
181+
- Apply that
182+
183+
IMPORTANT: There is an option in **Gradle** for **Automatic Project Synchronization**.
184+
As convenient as it'd be for the projects to always be perfect this
185+
tends to add many many seconds to every branch change. Instead, you
186+
should manually right click on a project and
187+
**Gradle > Refresh Gradle Project** if the configuration is out of
188+
date.
189+
190+
As we add more subprojects you might have to re-import the gradle project (the
191+
first step) again. There is no need to blow away the existing projects before
192+
doing that.
193+
139194
### REST Endpoint Conventions
140195

141196
Elasticsearch typically uses singular nouns rather than plurals in URLs.
@@ -551,4 +606,3 @@ non-documentation contribution. This is mentioned above, but it is worth
551606
repeating in this section because it has come up in this context.
552607

553608
[intellij]: https://blog.jetbrains.com/idea/2017/07/intellij-idea-2017-2-is-here-smart-sleek-and-snappy/
554-
[eclipse]: https://github.com/elastic/elasticsearch/issues/53664

buildSrc/elastic.importorder

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Eclipse configuration for import order for Elasticsearch
2+
0=
3+
1=com
4+
2=org
5+
3=java
6+
4=javax
7+
5=\#

0 commit comments

Comments
 (0)