Skip to content

Commit 456ba74

Browse files
committed
HV-2077 Align content of CONTRIBUTING.md with what's in other projects
1 parent b14c620 commit 456ba74

File tree

2 files changed

+251
-17
lines changed

2 files changed

+251
-17
lines changed

CONTRIBUTING.md

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

0 commit comments

Comments
 (0)