Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions community/contribute/eclipse-ide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,33 @@ Use "Build Path" -> "Use as Source Folder" on each of these.

Finally, you will have to manually add the ANT and JBoss Logger dependencies.

== Code formatting
== Code style

From the Eclipse menu: "Window" -> "Preferences", select "Java" -> "Code Style" -> "Formatter".
Download https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/eclipse/hibernate-java-formatting.xml[hibernate-java-formatting.xml]
from GitHub
and import it into Eclipse to apply the style the Hibernate team uses consistently across the codebase.
Each Hibernate project includes a set of build plugins to format and verify the code style of the sources.
Please refer to the particular project contributing guide for more details.

[NOTE]
====
Please avoid re-formatting large sections of code, especially when providing a patch:
we would love to have the diffs highlight the changes which matter.

If you feel the need to fix formatting on an existing source file,
make sure to isolate your formatting fixes in a separate commit
that contains exclusively formatting changes (avoid any functional change in that commit)
and make sure the commit message mentions this.
If the project build does not define a fully automated code formatter,
please avoid reformatting large sections of code, especially when providing a patch:
we would love to have the diffs highlight the changes that matter.
====

== Code templates

In the same "Window" -> "Preferences" menu, select "Java" -> "Code Style" -> "Code Templates"
and import the appropriate file downloaded from our GitHub repository:

* For Hibernate ORM: https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/eclipse/hibernate-code-template-orm.xml[`hibernate-code-templates-orm.xml`].
* For Hibernate Search: https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/eclipse/hibernate-code-template-search.xml[`hibernate-code-templates-search.xml`].
* For Hibernate OGM: https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/eclipse/hibernate-code-template-ogm.xml[`hibernate-code-templates-ogm.xml`].
* For Hibernate Validator: https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/eclipse/hibernate-code-template-validator.xml[`hibernate-code-templates-validator.xml`].
All top-level Hibernate projects are Apache 2.0 licensed and use the following header format:

With these templates, newly created files will automatically have the proper copyright/license headers.
Feel free to add your nick or full name as author of new files, and optionally provide an email.
The copyright/license header is a requirement.
[source,java]
----
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
----

You can also use the https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/eclipse/hibernate-auto-cleanup.xml[`hibernate-auto-cleanup.xml`],
to be imported into "Java" -> "Code Style" -> "Clean Up".
Note that each project has a license build plugin configured to check for the correct license header formatting.
At the same time, such a plugin provides options to add the missing headers.
Please refer to the particular project build for more details.

== Running tests in Eclipse

Expand Down
72 changes: 19 additions & 53 deletions community/contribute/intellij-idea.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,65 +43,31 @@ See the Annotation processor section for more info.

== Code style

Download the settings from our GitHub repository:
Each Hibernate project includes a set of build plugins to format and verify the code style of the sources.
Please refer to the particular project contributing guide for more details.
Comment on lines +46 to +47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, okay, but Hibernate ORM for example redirects here:

https://github.com/hibernate/hibernate-orm/blob/main/CONTRIBUTING.md#guidelines

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭 😖 infinite loop

though I have some slight doubts that everyone follows these instructions...
otherwise we'd be getting all new PRs with the old LGPL headers 😕

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really care about instructions for the headers since they're checked automatically on build, but the code style, IIRC, is not always checked in Hibernate ORM, and anyway it's convenient to have instructions on how to set up the IDE...

But those instructions would definitely be better to have in CONTRIBUTING.md, that I can agree with. The question is... what should those instructions be, if we archive hibernate-ide-codestyles :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hibernate/hibernate-orm#11361

how about something like ^
we tell to run the checks (and if someone doesn't CI should catch it, right?) and we give the links to the IDE pages, but we don't say that they have the styles .... 🫣 🙂


* For Hibernate ORM: https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/intellij-14/hibernate_orm.xml[`hibernate_orm.xml`].
* For Hibernate Search, Validator, OGM: https://raw.githubusercontent.com/hibernate/hibernate-ide-codestyles/master/intellij-14/hibernate_noorm.xml[`intellij-14/hibernate_noorm.xmlhibernate-code-templates-search.xml`].

Here is http://musingsofaprogrammingaddict.blogspot.com/2010/03/import-code-style-settings-into.html[an article on how to set it up in IntelliJ IDEA].

The authoritative code style is defined by the CheckStyle checks file associated with the project;
be sure to check against those prior to pushing.
[NOTE]
====
If the project build does not define a fully automated code formatter,
please avoid reformatting large sections of code, especially when providing a patch:
we would love to have the diffs highlight the changes that matter.
====

== Code templates

The best approach to automatically apply the proper copyright/license headers to newly created files
is to leverage the Copyright plugin (now a bundled plugin).

Set up on profile per Hibernate project you want to deal with in the Copyright configuration ("Settings" -> "Copyright")
and then select the one to use for your IntelliJ IDEA project.

Note you can define the profiles once and for all if you go through
"Other settings" -> "Settings for new projects" -> "Copyright":
they will be made available automatically in every new IntelliJ IDEA project.

Here are the standard license headers for each project:

* Hibernate ORM:

/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/

* Hibernate Search:

/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/

* Hibernate Validator:

/*
* Hibernate Validator, declare and validate application constraints
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
All top-level Hibernate projects are Apache 2.0 licensed and use the following header format:

* Hibernate OGM:
[source,java]
----
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
Comment on lines +62 to +65
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

----

/*
* Hibernate OGM, Domain model persistence for NoSQL datastores
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
Note that each project has a license build plugin configured to check for the correct license header formatting.
At the same time, such a plugin provides options to add the missing headers.
Please refer to the particular project build for more details.

== Debugging

Expand Down