Skip to content

Commit 2b52ae2

Browse files
committed
HV-2077 Align content of CONTRIBUTING.md with what's in other projects
1 parent d269471 commit 2b52ae2

File tree

3 files changed

+254
-18
lines changed

3 files changed

+254
-18
lines changed

CONTRIBUTING.md

Lines changed: 251 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,134 @@ in the root directory of the repository.
1717
All contributions are subject to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
1818
The DCO text is also included verbatim in the [dco.txt](dco.txt) file in the root directory of the repository.
1919

20-
## Getting Started
20+
## Finding something to contribute
21+
22+
Our [JIRA instance](https://hibernate.atlassian.net/browse/HV) is where all tasks are reported and tracked.
23+
24+
In particular there is a [list of issues suitable for new contributors](https://hibernate.atlassian.net/issues/?filter=21199).
25+
26+
## Create a test case
27+
28+
If you have opened a JIRA issue but are not comfortable enough to contribute code directly, creating a self
29+
contained test case is a good first step towards contributing.
30+
31+
As part of our efforts to simplify access to new contributors, we provide [test case templates for the Hibernate family
32+
projects](https://github.com/hibernate/hibernate-test-case-templates).
33+
34+
Just fork this repository, build your test case and attach it as an archive to a JIRA issue.
35+
36+
## <a id="setup"></a> Setting up a development environment
37+
38+
### <a id="setup-build-tools"></a> Build tools
39+
40+
You will need JDK 21 or above for the build.
41+
42+
A maven wrapper script is provided at the root of the repository (`./mvnw`),
43+
so you can use that and don't need to care about the required version of Maven
44+
(it will be downloaded automatically).
45+
46+
### <a id="setup-develocity"></a> Develocity build cache and build scans
47+
48+
Hibernate Validator relies on a [Develocity](https://gradle.com/develocity/) instance
49+
at [https://ge.hibernate.org](https://ge.hibernate.org/scans?search.rootProjectNames=Hibernate%20Validator)
50+
to speed up its build through a build cache and provide better reports.
51+
52+
By default, only [continuous integration](#ci) builds will write to the remote build cache or publish build scans.
53+
54+
Local builds of Hibernate Validator will:
55+
56+
* write to a local build cache;
57+
* read from both a local and a remote build cache to speed up builds;
58+
* not write to the remote build cache;
59+
* not publish any build scans.
60+
61+
To opt out from build caches for a particular build (e.g. to debug flaky tests),
62+
pass `-Dno-build-cache` to Maven.
63+
64+
To publish build scans for your local builds,
65+
[reach out to the team](https://hibernate.org/community/#contribute) to set up an account,
66+
and once you have one, run this from the root of your local clone of Hibernate Validator:
67+
68+
```shell
69+
./mvnw com.gradle:develocity-maven-extension:provision-access-key
70+
```
71+
72+
To opt out from build scans for a particular build (e.g. when working on a security vulnerability),
73+
pass `-Dscan=false` to Maven.
74+
75+
### <a id="setup-ide"></a> IDE
76+
77+
#### <a id="setup-ide-intellij-idea"></a> IntelliJ IDEA
78+
79+
**WARNING**: Avoid running `./mvnw` while IntelliJ IDEA is importing/building,
80+
and ideally avoid using Maven from the command line at all while IntelliJ IDEA is open.
81+
IntelliJ IDEA's own build might conflict with the Maven build, leaving your working directory in an undetermined state
82+
(some classes being generated twice, ...).
83+
If you already did that, close IntelliJ IDEA, run `./mvnw clean`, and open IntelliJ IDEA again.
84+
85+
You will need to change some settings:
86+
87+
* `Build, Execution, Deployment > Build Tools > Maven`: set `Maven home path` to `Use Maven wrapper`
88+
* In `Project structure`, make sure the project JDK is JDK 21.
89+
* Set up [formatting rules and code style](#setup-ide-formatting).
90+
91+
Then a few steps will initialize your workspace:
92+
93+
* In the "Maven" side panel, click "Reload all Maven projects".
94+
* To check your setup, click `Build > Rebuild Project`.
95+
If the build has no errors, your workspace is correctly set up.
96+
* If you encounter any problem, that might be caused by the project being half-built before you started.
97+
Try again from a clean state: close IntelliJ IDEA, run `./mvnw clean`, open IntelliJ IDEA again,
98+
and go back to the first step.
99+
100+
#### <a id="setup-ide-eclipse"></a> Eclipse
101+
102+
Eclipse shouldn't require any particular setup besides
103+
[formatting rules and code style](#setup-ide-formatting).
104+
105+
#### <a id="setup-ide-formatting"></a> Formatting rules and style conventions
106+
107+
Hibernate Validator has a strictly enforced code style. Code formatting is done by the Eclipse code formatter,
108+
using the config files found in the `build/build-config/src/main/resources` directory.
109+
By default, when you run `mvn install`, the code will be formatted automatically.
110+
When submitting a pull request the CI build will fail if running the formatter results in any code changes,
111+
so it is recommended that you always run a full Maven build before submitting a pull request.
112+
113+
The [Adapter for Eclipse Code Formatter](https://plugins.jetbrains.com/plugin/6546-adapter-for-eclipse-code-formatter) plugin
114+
can be used by IntelliJ IDEA users to apply formatting while within the IDE. Additionally, contributors might need to
115+
increase import counts to prevent star imports, as this setting is not exportable and star imports will lead to
116+
a build failure.
117+
118+
## Contributing code
119+
120+
### Prerequisites
21121

22122
If you are just getting started with Git, GitHub and/or contributing to Hibernate Validator there are a
23123
few prerequisite steps:
24124

25125
* Make sure you have a [Hibernate JIRA account](https://hibernate.atlassian.net)
26126
* Make sure you have a [GitHub account](https://github.com/signup/free)
27127
* [Fork](https://help.github.com/articles/fork-a-repo/) the Hibernate Validator [repository](https://github.com/hibernate/hibernate-validator).
28-
As discussed in the linked page, this also includes:
29-
* [Setting](https://help.github.com/articles/set-up-git/) up your local git install
30-
* Cloning your fork
128+
As discussed in the linked page, this also includes:
129+
* [Setting](https://help.github.com/articles/set-up-git/) up your local git install
130+
* Cloning your fork
31131
* Instruct git to ignore certain commits when using `git blame`:
32132
```
33133
git config blame.ignoreRevsFile .git-blame-ignore-revs
34134
```
35135

36-
## Create a test case
136+
### Development environment
37137

38-
If you have opened a JIRA issue but are not comfortable enough to contribute code directly, creating a self
39-
contained test case is a good first step towards contributing.
138+
Make sure to [set up your development environment](#setup) correctly.
40139

41-
As part of our efforts to simplify access to new contributors, we provide [test case templates for the Hibernate family
42-
projects](https://github.com/hibernate/hibernate-test-case-templates).
140+
Be especially careful about setting up the [formatting rules and code style](#setup-ide-formatting).
141+
142+
If you built the project at least once (`./mvnw clean install`),
143+
you can very quickly check that you have respected the formatting rules by running Checkstyle:
144+
```bash
145+
./mvnw spotless:check checkstyle:check -fn
146+
```
43147

44-
Just fork this repository, build your test case and attach it as an archive to a JIRA issue.
45148

46149
## Create a topic branch
47150

@@ -86,6 +189,15 @@ The project comes with formatting files located in:
86189

87190
These files can be used in the IDE if applying formatting as-you-code within the IDE is something you'd prefer.
88191

192+
### Javadoc
193+
Additionally, keep in mind the following Javadoc conventions, when working on the Hibernate Validator code base:
194+
195+
* Use `{@code}` instead of `<code>`, because it is more readable and `{@code}` also escapes meta characters
196+
* `@param`, `@return` and `@throw` don’t end with a `.`; the first word starts with a lower-case letter
197+
* If referring to other classes and methods of the library, use `{@link}`
198+
* `{@link}` might be use for external classes, `{@code}` is accepted, too
199+
* Use `<ul/>` for enumerations (not `-`)
200+
89201
## Commit
90202

91203
* Make commits of logical units.
@@ -113,8 +225,136 @@ If you want to rebase your branch on top of the main branch, you can use the fol
113225
git pull --rebase upstream main
114226
```
115227

228+
### Check and test your work
229+
230+
Before submitting a pull requests, check your contribution:
231+
232+
* Make sure you have added the necessary tests for your changes.
233+
* If relevant, make sure you have updated the documentation to match your changes.
234+
* Run the relevant tests once again to check that your changes work as expected.
235+
No need to run the whole test suite, the Continuous Integration will take care of that.
236+
116237
## Submit
117238

118239
* Push your changes to a topic branch in your fork of the repository.
119240
* Initiate a [pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
120-
* Update the JIRA issue, adding a comment including a link to the created pull request.
241+
* Jira automation should link your pull request to the corresponding JIRA issue and update its status.
242+
243+
## <a id="source-code-structure"></a> Source code structure
244+
245+
The project is split in several Maven modules:
246+
247+
* `build`: Various modules that are mostly useful for the build itself. Some of the submodules:
248+
* `build-config`: Code-related artifacts like [checkstyle](https://checkstyle.org/) and
249+
[forbiddenapis](https://github.com/policeman-tools/forbidden-apis) rules.
250+
* `enforcer`: Contains custom enforcer rules used in the project build.
251+
* `annotation-processor`: The HV annotation processor for checking correctness of constraints at compile time.
252+
* `cdi`: the CDI portable extension
253+
* `distribution`: Builds the distribution package.
254+
* `documentation`: The project documentation.
255+
* `engine`: The Hibernate Validator engine.
256+
This module handles all the validation work.
257+
* `integrationtest`: Integration tests for Hibernate Validator.
258+
Here are some notable sub-directories:
259+
* `wildfly`: WildFly based integration tests.
260+
* `java`: a set of JPMS-based integration tests.
261+
* `performance`: performance tests.
262+
* `tck-runner`: The Hibernate Validator TCK Runner. See [README.md](tck-runner/README.md) for more details on how to run the TCK tests.
263+
* `test-util`: Various util classes, both for runtime and for tests. Contains a handy utility to perform assertions on constraint violations.
264+
265+
## <a id="building-from-source"></a> Building from source
266+
267+
### Basic build from the commandline
268+
269+
First, make sure your [development environment is correctly set up](#setup).
270+
271+
The following command will build Hibernate Validator, install it in your local Maven repository,
272+
and run unit and integration tests.
273+
274+
```bash
275+
./mvnw clean install
276+
```
277+
278+
Note: the produced JARs are compatible with Java 17 and later,
279+
regardless of the JDK used to build Hibernate Validator.
280+
281+
**WARNING:** Avoid using other goals unless you know what you're doing, because they may leave your workspace
282+
in an undetermined state and lead to strange errors.
283+
In particular, `./mvnw compile` will not build tests and may skip some post-processing of classes,
284+
and `./mvnw package` will not install the JARs into your local Maven repository
285+
which might be a problem for some of the Maven plugins used in the build.
286+
If you did run those commands and are facing strange errors,
287+
you'll have to close your IDE then use `./mvnw clean` to get back to a clean state.
288+
289+
### Building without running tests
290+
291+
To only build Hibernate Validator, without running tests, use the following command:
292+
293+
```bash
294+
./mvnw clean install -DskipTests
295+
```
296+
297+
### Documentation
298+
299+
The documentation is based on [Asciidoctor](http://asciidoctor.org/).
300+
301+
To generate the documentation only, without running tests, use:
302+
303+
```bash
304+
./mvnw clean install -pl documentation -am -DskipTests
305+
```
306+
307+
You can then find the freshly built documentation at the following location:
308+
309+
```
310+
./documentation/target/dist/
311+
```
312+
313+
By default, only the HTML output is enabled; to also generate the PDF output, enable the `documentation-pdf` profile:
314+
315+
```bash
316+
./mvnw clean install -pl documentation -am -DskipTests -Pdocumentation-pdf
317+
```
318+
319+
### Distribution
320+
321+
To build the distribution bundle, enable the `documentation-pdf` and `dist` profiles:
322+
323+
```bash
324+
./mvnw clean install -Pdocumentation-pdf,dist
325+
```
326+
327+
Or if you don't want to run tests:
328+
329+
```bash
330+
./mvnw clean install -Pdocumentation-pdf,dist -DskipTests
331+
```
332+
333+
### <a id="other-jdks"></a> Other JDKs
334+
335+
To test Hibernate Validator against another JDK
336+
than [the one required for the build](#setup-build-tools),
337+
you will need to have both JDKs installed,
338+
and then you will need to pass additional properties to Maven.
339+
340+
To test Hibernate Validator against the JDK 17:
341+
342+
```bash
343+
./mvnw clean install
344+
```
345+
346+
To test Hibernate Validator against JDKs other than 17:
347+
348+
```bash
349+
./mvnw clean install -Djava-version.test.release=21 -Djava-version.test.compiler.java_home=/path/to/jdk21
350+
```
351+
352+
Or more simply, if the JDK you want to test against is newer than 21 and is your default JDK:
353+
354+
```bash
355+
./mvnw clean install -Djava-version.test.release=18
356+
```
357+
358+
### <a id="tck"></a> TCK
359+
360+
See [README.md](tck-runner/README.md) for more details on how to run the TCK tests.

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,7 @@ the Apache Software License 2.0. Refer to license.txt for more information.
7474

7575
## Build from Source
7676

77-
You can build Hibernate Validator from source by cloning the git repository `git://github.com/hibernate/hibernate-validator.git`.
78-
You will also need a JDK 21+ and Maven 3 (>= 3.9.9). With these prerequisites in place you can compile the source via:
79-
80-
mvn clean install
81-
82-
There are more build options available as well. For more information refer to [Contributing to Hibernate Validator](https://hibernate.org/validator/contribute/).
77+
You can build Hibernate Validator from source. Refer to the [Contributing to Hibernate Validator](https://hibernate.org/validator/contribute/) guide for more information.
8378

8479
## Continuous Integration
8580

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@
313313
Set statically, independently of the current JDK: we want our code to comply with this version
314314
315315
Note: when updating this version, consider reviewing the list of JDKs the forbidden API plugin is targeting.
316+
Adjust the contributing guide when changing the release Java version.
316317
-->
317318
<java-version.main.release>17</java-version.main.release>
318319
<java-version.main.compiler.java_home>${java.home}</java-version.main.compiler.java_home>
@@ -403,7 +404,7 @@
403404
<arquillian.wildfly.jvm.args>-Duser.language=en -Duser.country=US ${arquillian.wildfly.jvm.args.add-opens} ${arquillian.wildfly.jvm.args.add-modules} ${arquillian.jvm.args.java-version}</arquillian.wildfly.jvm.args>
404405

405406
<!-- JDK version required for the build -->
406-
<!-- Remember to update README when changing the version here. -->
407+
<!-- Remember to update README/CONTRIBUTING when changing the version here. -->
407408
<jdk.min.version>21</jdk.min.version>
408409
<!-- Maven version required for the build -->
409410
<!--

0 commit comments

Comments
 (0)