diff --git a/.vscode/settings.json b/.vscode/settings.json
index 3ae9e077a75..4c8bf8a483d 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -2,5 +2,6 @@
"java.configuration.updateBuildConfiguration": "interactive",
"java.format.settings.url": "/config/VSCode Code Style.xml",
"java.checkstyle.configuration": "${workspaceFolder}/config/checkstyle/checkstyle_reviewdog.xml",
- "java.checkstyle.version": "10.21.0"
+ "java.checkstyle.version": "10.21.0",
+ "java.completion.importOrder": ["#"]
}
diff --git a/build.gradle b/build.gradle
index 5336d5325c4..50aac8f4c4f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,6 +3,12 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jabref.build.xjc.XjcPlugin
import org.jabref.build.xjc.XjcTask
+buildscript {
+ dependencies {
+ classpath('com.palantir.javaformat:gradle-palantir-java-format:2.58.0')
+ }
+}
+
plugins {
id 'application'
@@ -24,23 +30,26 @@ plugins {
id 'jacoco'
id 'checkstyle'
+ id 'com.diffplug.spotless' version '6.22.0'
+ id 'org.openrewrite.rewrite' version '7.1.4'
id 'project-report'
id 'idea'
- id 'org.openrewrite.rewrite' version '7.1.4'
-
id "org.itsallcode.openfasttrace" version "3.0.1"
}
-// Enable following for debugging
-// gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.
+apply plugin: 'com.palantir.java-format'
+apply plugin: 'com.diffplug.spotless'
apply plugin: XjcPlugin
apply from: 'eclipse.gradle'
+// Enable following for debugging
+// gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.
+
group = "org.jabref"
version = project.findProperty('projVersion') ?: '100.0.0'
@@ -713,6 +722,12 @@ checkstyle {
sourceSets = []
}
+spotless {
+ java {
+ target 'src/main/java/**/*.java', 'src/main/test/**/*.java'
+ }
+}
+
rewrite {
activeRecipe(
'org.jabref.config.rewrite.cleanup'
diff --git a/config/IntelliJ Code Style.xml b/config/IntelliJ Code Style.xml
index 51aa18498d7..7dbf537a52a 100644
--- a/config/IntelliJ Code Style.xml
+++ b/config/IntelliJ Code Style.xml
@@ -11,28 +11,20 @@
+
-
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 59109471789..5813586de63 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -3,6 +3,8 @@
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.checkstyle.org/dtds/configuration_1_3.dtd">
+
+
@@ -53,6 +55,8 @@
+
+
@@ -68,12 +72,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -82,19 +86,53 @@
+ value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
+ STATIC_INIT, INSTANCE_INIT, CTOR_DEF, VARIABLE_DEF, RECORD_DEF,
+ COMPACT_CTOR_DEF"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -150,6 +188,7 @@
+
@@ -173,5 +212,11 @@
+
+
+
+
+
+
diff --git a/config/checkstyle/checkstyle_reviewdog.xml b/config/checkstyle/checkstyle_reviewdog.xml
index 996442b68fa..990fa1ef491 100644
--- a/config/checkstyle/checkstyle_reviewdog.xml
+++ b/config/checkstyle/checkstyle_reviewdog.xml
@@ -3,6 +3,8 @@
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.checkstyle.org/dtds/configuration_1_3.dtd">
+
+
@@ -15,7 +17,7 @@
-
+
@@ -53,6 +55,8 @@
+
+
@@ -68,12 +72,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -82,19 +86,53 @@
+ value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
+ STATIC_INIT, INSTANCE_INIT, CTOR_DEF, VARIABLE_DEF, RECORD_DEF,
+ COMPACT_CTOR_DEF"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -150,6 +188,7 @@
+
@@ -173,5 +212,11 @@
+
+
+
+
+
+
diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-enable.png b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-enable.png
new file mode 100644
index 00000000000..cc3a896357d
Binary files /dev/null and b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-enable.png differ
diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-install.png b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-install.png
new file mode 100644
index 00000000000..63784aeece8
Binary files /dev/null and b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-install.png differ
diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-restart.png b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-restart.png
new file mode 100644
index 00000000000..26752e210fe
Binary files /dev/null and b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/guidelines-intellij-palantir-plugin-restart.png differ
diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.md b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.md
index ab92a327599..7ceace86ae2 100644
--- a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.md
+++ b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.md
@@ -6,17 +6,22 @@ nav_order: 13
# Step 3: Set up JabRef's code style
-Contributions to JabRef's source code need to have a code formatting that is consistent with existing source code. For that purpose, JabRef provides code-style and check-style definitions.
+Contributions to JabRef's source code need to have a code formatting that is consistent with existing source code.
+For that purpose, JabRef relies on both the [palantir-java-format](https://github.com/palantir/palantir-java-format#palantir-java-format) and [checkstyle](https://checkstyle.sourceforge.io/).
+`palantir-java-format` is automatically configured by the [Gradle plugin](https://github.com/palantir/palantir-java-format#compalantirjava-format-gradle-plugin).
+While `palantir-java-format` ensures proper formatting, the configuration of imports needs to be done, too.
-Install the [CheckStyle-IDEA plugin](http://plugins.jetbrains.com/plugin/1065?pr=idea), it can be found via the plug-in repository:
+## Install checkstyle plugin
+
+Install the [Checkstyle-IDEA plugin](http://plugins.jetbrains.com/plugin/1065?pr=idea), it can be found via the plug-in repository:
Navigate to **File > Settings... > Plugins"**.
On the top, click on "Marketplace".
Then, search for "Checkstyle".
Click on "Install" choose "CheckStyle-IDEA".
**Note:** In some MacBooks, `Settings` can be found at the "IntelliJ" button of the app menu instead of at "File".
-{% figure caption:"Install CheckStyle" %}
-
+{% figure caption:"Install Checkstyle" %}
+
{% endfigure %}
After clicking, IntelliJ asks for confirmation:
@@ -37,6 +42,8 @@ Click on "Restart" to finally restart.
Wait for IntelliJ coming up again.
+## Active JabRef's code style
+
Go to **File > Settings... > Editor > Code Style**
Click on the settings wheel (next to the scheme chooser),
@@ -67,7 +74,7 @@ Click on "Apply" to store the preferences.
## Put JabRef's checkstyle configuration in place
-Now, put the checkstyle configuration file is in place:
+Now, we put the checkstyle configuration file is in place:
Go to **File > Settings... > Tools > Checkstyle > Configuration File**
@@ -115,16 +122,32 @@ Then, you can run a check on all modified files.

{% endfigure %}
-## Have auto format working properly in JavaDoc
+## Enable `palantir-java-format`
+
+Go to **File > Settings... > Plugins**.
+
+Go to "Marketplace"
+
+Enter "palantir-java-format" in the search box.
+
+Click on "Install"
+
+{% figure caption:"Marketplace result for planatgir-java-format" %}
+
+{% endfigure %}
+
+Afterwards, restart IntelliJ:
-To have auto format working properly in the context of JavaDoc and line wrapping, "Wrap at right margin" has to be disabled. Details are found in [IntelliJ issue 240517](https://youtrack.jetbrains.com/issue/IDEA-240517).
+{% figure caption:"Prompt for IntelliJ restart" %}
+
+{% endfigure %}
-Go to **File > Settings... > Editor > Code Style > Java > JavaDoc**.
+Finally, activate `planatir-java-format` in the settings:
-At "Other", disable "Wrap at right margin"
+Go to **File > Settings... > Other > **.
-{% figure caption:"”Wrap at right margin” disabled" %}
-
+{% figure caption:"Enable palantir-java-plugin" %}
+
{% endfigure %}
## Enable proper import cleanup
diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-89-run-with-intellij.md b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-80-run-with-intellij.md
similarity index 99%
rename from docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-89-run-with-intellij.md
rename to docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-80-run-with-intellij.md
index 1f728d63507..e095af2af5c 100644
--- a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-89-run-with-intellij.md
+++ b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-80-run-with-intellij.md
@@ -1,7 +1,7 @@
---
parent: Set up a local workspace
grand_parent: Getting into the code
-nav_order: 89
+nav_order: 80
---
# Advanced: Build and run using IntelliJ IDEA
diff --git a/gradle.properties b/gradle.properties
index d0df6eb37db..26e89281a6c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -11,3 +11,11 @@ org.gradle.jvmargs=-Xmx6096M
# hint by https://docs.gradle.org/current/userguide/performance.html#enable_the_build_cache
org.gradle.caching=true
+
+# jdk.compiler required because of https://github.com/diffplug/spotless/issues/834#issuecomment-819118761
+org.gradle.jvmargs=-Xmx4096M \
+ --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
+ --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
+ --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
+ --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
+ --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED