Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated parts of code-howtos/IntelliJ (and move good parts) #10400

Merged
merged 5 commits into from
Sep 19, 2023
Merged
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
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ docker run -p 4000:4000 -it --rm --volume="C:\git-repositories\jabref\docs":/srv
* With <kbd>Ctrl</kbd>+<kbd>C</kbd> you can stop the server (this is enabled by the `-it` switch).
* In case you get errors regarding `Gemfile.lock`, just delete `Gemfile.lock` and rerun.
* The current `Dockerfile` is based on <https://github.com/just-the-docs/just-the-docs/blob/main/Dockerfile>.
The [Jekyll Docker image](https://github.com/envygeeks/jekyll-docker#jekyll-docker) did not work end of 20222 (because Ruby was too new).
The [Jekyll Docker image](https://github.com/envygeeks/jekyll-docker#jekyll-docker) did not work end of 2022 (because Ruby was too new).
80 changes: 12 additions & 68 deletions docs/code-howtos/IntelliJ.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,71 +15,15 @@ Did you know that [IntelliJ allows for reformatting selected code](https://www.j
* <kbd>Alt</kbd>+<kbd>F1</kbd> and then <kbd>Enter</kbd>: Locate the file in the search bar on the left side.
* <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd>: Navigate from a class to the test class.

---
parent: Set up a local workspace
grand_parent: Getting into the code
nav_order: 49
---

## Other notes on IntelliJ

{: .note}
Here, some notes on IntelliJ setup are written down.
These are intended for pro users.

You should use IntelliJ IDEA's internal build system for compiling and running JabRef tests during development, because it is usually more responsive.
Essentially, you now have the best of both worlds:
You can run Gradle tasks using the Gradle Tool Window.
You can compile and run tests with IntelliJ's faster internal build system
(unless you haven't made changes to input files that generate sources).

{: .important}
When using IntelliJ's build system, **it is important** that you understand that JabRef relies on generated sources which are only built through Gradle.
Therefore, to build or update these dependencies you need to run the `run` (or `assemble`) Gradle task at least once.
When you followed this guide, you should have done it in the Gradle setup.

Running JabRef itself through IntelliJ's build system is **not** possible as we encounter difficulties when reading resources though `.class.getResource(...)`.
Although solutions are discussed in length [on stackoverflow](https://stackoverflow.com/q/26328040/873282), there is no "good" solution for us.

## Running JabRef using IntelliJ's build system

{ :note }
Maybe does not work

To run JabRef from IntelliJ, we let IntelliJ create a launch configuration:

Locate the class `Launcher`:
Press <kbd>Ctrl</kbd>+<kbd>N</kbd>.
Then, the "Search for classes dialog" pops up.
Enter `Launcher`.
Now, only one class should have been found:

{% figure caption:"IntelliJ search for class “Launcher”" %}
![IntelliJ search for class "Launcher"](../images/intellij-search-for-launcher.png)
{% endfigure %}

Press <kbd>Enter</kbd> to jump to that class.

Hover on the green play button.

{% figure caption:"However on green play" %}
![However on green play](../images/intellij-hover-on-play-button.png)
{% endfigure %}

Then, click on it.
A popup menu opens.
Choose the first entry and click on it.

{% figure caption:"Run JabRef via launcher" %}
![Popup menu - Run JabRef via launcher](../images/intellij-run-jabref-from-launcher.png)
{% endfigure %}

Then, JabRef starts.

You also have an entry in the Launch configurations to directly launch the JabRef GUI:

{% figure caption:"Launch menu contains “Launcher”" %}
![Launch menu contains launcher](../images/intellij-run-launcher.png)
{% endfigure %}

You can also click on the debug symbol next to it to enable stopping at breakpoints.
## Show variable values in IntelliJ

1. Go to a test case (example: [`org.jabref.model.entry.BibEntryTest#settingTypeToNullThrowsException`](https://github.com/JabRef/jabref/blob/refine-intellij-howto/src/test/java/org/jabref/model/entry/BibEntryTest.java#L52-L52)
2. Set the breakpoint to the first line
3. Execute the test
4. Go to the settings of the debugger and activate "Show Variable Values in Editor" and "Show Method Return Values"
<figure>
<img src="intellij-debugger-configuration.png" alt="Debugger Configuration">
<figcaption>Debugger Configuration</figcaption>
</figure>

<!-- markdownlint-disable-file MD033 -->
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nav_order: 12
Ensure you have a Java 20 SDK configured by navigating to **File > Project Structure... > Platform Settings > SDKs**.

{% figure caption:"JDKs 11, 14, and 15 shown in available SDKs. JDK 20 is missing." %}
![Plattform Settings - SDKs](../../images/intellij-choose-jdk-adoptopenjdk-on-windows-project-settings.png)
![Plattform Settings - SDKs](intellij-choose-jdk-adoptopenjdk-on-windows-project-settings.png)
{% endfigure %}

If there is another JDK than JDK 20 selected, click on the plus button and choose "Download JDK..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,28 @@ Due to [IDEA-119280](https://youtrack.jetbrains.com/issue/IDEA-119280), it is a
3. Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to mark them for copying
4. Select the folder `classes`
5. Press <kbd>Ctrl</kbd>+<kbd>V</kbd> to start the copy process
8. Locate the class `Launcher` (e.g., by <kbd>ctrl</kbd>+<kbd>N</kbd> and then typing `Launcher`)
8. Locate the class `Launcher` (e.g., by <kbd>ctrl</kbd>+<kbd>N</kbd> and then typing `Launcher`). Press <kbd>Enter</kbd> to jump to that class.
<figure>
<img src="intellij-search-for-launcher.png" alt="IntelliJ search for class “Launcher”">
<figcaption>IntelliJ search for class “Launcher”</figcaption>
</figure>
9. Click on the green play button next to the `main` method to create a Launch configuration. IntelliJ will fail in launching.
<figure>
<img src="intellij-hover-on-play-button.png" alt="However on green play">
<figcaption>However on green play</figcaption>
</figure>

<figure>
<img src="intellij-run-jabref-from-launcher.png" alt="Run JabRef via launcher">
<figcaption>Run JabRef via launcher</figcaption>
</figure>

10. On the top right of the IntelliJ window, next to the newly created launch configuration, click on the drop down
11. Click on "Edit Configurations..."
12. On the right, click on "Modify options"
13. Ensure that "Use classpath of module" is checked
14. Select "Add VM options"
15. In the newly appearing field for VM options, insert:

```text
--add-exports=javafx.controls/com.sun.javafx.scene.control=org.jabref
--add-opens=org.controlsfx.controls/org.controlsfx.control.textfield=org.jabref
Expand All @@ -53,6 +66,12 @@ Due to [IDEA-119280](https://youtrack.jetbrains.com/issue/IDEA-119280), it is a
--add-reads org.jabref=org.fxmisc.flowless
--add-reads org.jabref=org.apache.commons.csv
```
16. Click "Apply"
17. Click "Run". You can also click on the debug symbol next to it to enable stopping at breakpoints.
<figure>
<img src="intellij-run-launcher.png" alt="Launch menu contains “Launcher”">
<figcaption>Launch menu contains “Launcher”</figcaption>
</figure>

14. Click "Apply"
15. Click "Run"
<!-- MD031 is disabled, because otherwise the numbering does not work properly. MD029 and M032 are disabled as a consequence. -->
<!-- markdownlint-disable-file MD029 MD031 MD032 MD033 -->
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ In older IntelliJ setups, more things were necessary:

Ignore the Gradle project "buildSrc" by clicking the button **Select Project Data To Import** in the Gradle Tool Window and unchecking the folder "buildSrc".

![Ignore the Gradle project "buildSrc"](../../images/intellij-gradle-config-ignore-buildSrc.png)
![Ignore the Gradle project "buildSrc"](intellij-gradle-config-ignore-buildSrc.png)

Add `src-gen` as root:

Expand Down
Binary file removed docs/images/intellij-gradle-config.png
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The package `org.jabref.cli` is responsible for handling the command line option

During development, one can configure IntelliJ to pass command line parameters:

![IntelliJ-run-configuration](<images/intellij-run-configuration-command-line.png>)
![IntelliJ-run-configuration](images/intellij-run-configuration-command-line.png)

Passing command line arguments using gradle is currently not possible as all arguments (such as `-Dfile.encoding=windows-1252`) are passed to the application.

Expand Down
Loading