Elffuss BraidHub

kikocis/java-driver public

51433ff5ddfe · 3.5 KiBRenderedRawPermalink
1# Contributing guidelines
2
3## Working on an issue
4
5Before starting to work on something, please comment in JIRA or ask on the mailing list
6to make sure nobody else is working on it.
7
8If a fix applies to 2.0, 2.1 and 2.2, work on the 2.0 branch, your commit will eventually
9get merged in 2.1 then in 2.2.
10
11Before you send your pull request, make sure that:
12
13- you have a unit test that failed before the fix and succeeds after.
14- the fix is mentioned in `driver-core/CHANGELOG.rst`.
15- the commit message include the reference of the JIRA ticket for automatic linking
16 (example: `Fix NPE when a connection fails during pool construction (JAVA-503).`).
17
18As long as your pull request is not merged, it's OK to rebase your branch and push with
19`--force`.
20
21If you want to contribute but don't have a specific issue in mind, the [lhf](https://datastax-oss.atlassian.net/secure/IssueNavigator.jspa?reset=true&mode=hide&jqlQuery=project%20%3D%20JAVA%20AND%20status%20in%20(Open%2C%20Reopened)%20AND%20labels%20%3D%20lhf)
22label in JIRA is a good place to start: it marks "low hanging fruits" that don't require
23in-depth knowledge of the codebase.
24
25## Editor configuration
26
27### General
28
29We consider automatic formatting as a help, not a crutch. Sometimes it makes sense to
30break the rules to make the code more readable, for instance aligning columns (see the
31constant declarations in `DataType.Name` for an example of this).
32
33**Please do not reformat whole files, only the lines that you have added or modified**.
34
35
36### Eclipse
37
38Formatter:
39
40- Preferences > Java > Code Style > Formatter.
41- Click "Import".
42- Select `src/main/config/ide/eclipse-formatter.xml`.
43
44Import order:
45
46- Preferences > Java > Code Style > Organize imports.
47- Click "Import".
48- Select `src/main/config/ide/eclipse.importorder`.
49
50Prevent trailing whitespaces:
51
52- Preferences > Java > Editor > Save Actions.
53- Check "Perform the selected actions on save".
54- Ensure "Format source code" and "Organize imports" are unchecked.
55- Check "Additional actions".
56- Click "Configure".
57- In the "Code Organizing" tab, check "Remove trailing whitespace" and "All lines".
58- Click "OK" (the text area should only have one action "Remove trailing white spaces").
59
60
61### IntelliJ IDEA
62
63- File > Import Settings...
64- Select `src/main/config/ide/intellij-code-style.jar`.
65
66This should add a new Code Style scheme called "java-driver".
67
68## Running the tests
69
70We use TestNG. There are 3 test categories:
71
72- "unit": pure Java unit tests.
73- "short" and "long": integration tests that launch Cassandra instances.
74
75The Maven build uses profiles named after the categories to choose which tests to run:
76
77```
78mvn test -Pshort
79```
80
81The default is "unit". Each profile runs the ones before it ("short" runs unit, etc.)
82
83Integration tests use [CCM](https://github.com/pcmanus/ccm) to bootstrap Cassandra instances.
84Two Maven properties control its execution:
85
86- `cassandra.version`: the Cassandra version. This has a default value in the root POM,
87 you can override it on the command line (`-Dcassandra.version=...`).
88- `ipprefix`: the prefix of the IP addresses that the Cassandra instances will bind to (see
89 below). This defaults to `127.0.1.`.
90
91
92CCM launches multiple Cassandra instances on localhost by binding to different addresses. The
93driver uses up to 6 different instances (127.0.1.1 to 127.0.1.6 with the default prefix).
94You'll need to define loopback aliases for this to work, on Mac OS X your can do it with:
95
96```
97sudo ifconfig lo0 alias 127.0.1.1 up
98sudo ifconfig lo0 alias 127.0.1.2 up
99...
100```