Skip to content

Commit 5785245

Browse files
authored
add copyright/scope configuration for intellij to Contributing Guide (#29688)
* add copyright/scope configuration for intellij This commit introduces a section discussing the ability to define copyright rules in intellij for inserting the appropriate copyright headers into files across both apache2-Elasticsearch, as well as the commercial code under `x-pack`. Some other re-organization was made to create more sub-structure * update to reflect reviewer comments
1 parent 67c0cf1 commit 5785245

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ We support development in the Eclipse and IntelliJ IDEs. For Eclipse, the
107107
minimum version that we support is [Eclipse Oxygen][eclipse] (version 4.7). For
108108
IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij].
109109

110+
### Configuring IDEs And Running Tests
111+
110112
Eclipse users can automatically configure their IDE: `./gradlew eclipse`
111113
then `File: Import: Existing Projects into Workspace`. Select the
112114
option `Search for nested projects`. Additionally you will want to
@@ -144,6 +146,9 @@ For IntelliJ, go to
144146
For Eclipse, go to `Preferences->Java->Installed JREs` and add `-ea` to
145147
`VM Arguments`.
146148

149+
150+
### Java Language Formatting Guidelines
151+
147152
Please follow these formatting guidelines:
148153

149154
* Java indent is 4 spaces
@@ -155,6 +160,33 @@ Please follow these formatting guidelines:
155160
* IntelliJ: `Preferences/Settings->Editor->Code Style->Java->Imports`. There are two configuration options: `Class count to use import with '*'` and `Names count to use static import with '*'`. Set their values to 99999 or some other absurdly high value.
156161
* Don't worry too much about import order. Try not to change it but don't worry about fighting your IDE to stop it from doing so.
157162

163+
### License Headers
164+
165+
We require license headers on all Java files. You will notice that all the Java files in
166+
the top-level `x-pack` directory contain a separate license from the rest of the repository. This
167+
directory contains commercial code that is associated with a separate license. It can be helpful
168+
to have the IDE automatically insert the appropriate license header depending which part of the project
169+
contributions are made to.
170+
171+
#### IntelliJ: Copyright & Scope Profiles
172+
173+
To have IntelliJ insert the correct license, it is necessary to create to copyright profiles.
174+
These may potentially be called `apache2` and `commercial`. These can be created in
175+
`Preferences/Settings->Editor->Copyright->Copyright Profiles`. To associate these profiles to
176+
their respective directories, two "Scopes" will need to be created. These can be created in
177+
`Preferences/Settings->Appearances & Behavior->Scopes`. When creating scopes, be sure to choose
178+
the `shared` scope type. Create a scope, `apache2`, with
179+
the associated pattern of `!file[group:x-pack]:*/`. This pattern will exclude all the files contained in
180+
the `x-pack` directory. The other scope, `commercial`, will have the inverse pattern of `file[group:x-pack]:*/`.
181+
The two scopes, together, should account for all the files in the project. To associate the scopes
182+
with their copyright-profiles, go into `Preferences/Settings->Editor>Copyright` and use the `+` to add
183+
the associations `apache2/apache2` and `commercial/commercial`.
184+
185+
Configuring these options in IntelliJ can be quite buggy, so do not be alarmed if you have to open/close
186+
the settings window and/or restart IntelliJ to see your changes take effect.
187+
188+
### Creating A Distribution
189+
158190
To create a distribution from the source, simply run:
159191

160192
```sh
@@ -169,6 +201,8 @@ The archive distributions (tar and zip) can be found under:
169201
`./distribution/archives/(tar|zip)/build/distributions/`
170202

171203

204+
### Running The Full Test Suite
205+
172206
Before submitting your changes, run the test suite to make sure that nothing is broken, with:
173207

174208
```sh

0 commit comments

Comments
 (0)