Skip to content

Commit

Permalink
Remove outdated parts of code-howtos/IntelliJ (and move good parts)
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Sep 19, 2023
1 parent 2837778 commit 907bdb8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 72 deletions.
69 changes: 0 additions & 69 deletions docs/code-howtos/IntelliJ.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,72 +14,3 @@ Did you know that [IntelliJ allows for reformatting selected code](https://www.j
* <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>F</kbd>: Search everywhere in the code base.
* <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.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ 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 caption:"IntelliJ search for class “Launcher”" %}
![IntelliJ search for class "Launcher"](../images/intellij-search-for-launcher.png)
{% endfigure %}
9. Click on the green play button next to the `main` method to create a Launch configuration. IntelliJ will fail in launching.
{% figure caption:"However on green play" %}
![However on green play](../images/intellij-hover-on-play-button.png)
{% endfigure %}

{% figure caption:"Run JabRef via launcher" %}
![Popup menu - Run JabRef via launcher](../images/intellij-run-jabref-from-launcher.png)
{% endfigure %}
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"
Expand Down Expand Up @@ -54,5 +64,8 @@ Due to [IDEA-119280](https://youtrack.jetbrains.com/issue/IDEA-119280), it is a
--add-reads org.jabref=org.apache.commons.csv
```

14. Click "Apply"
15. Click "Run"
16. Click "Apply"
17. Click "Run". You can also click on the debug symbol next to it to enable stopping at breakpoints.
{% figure caption:"Launch menu contains “Launcher”" %}
![Launch menu contains launcher](../images/intellij-run-launcher.png)
{% endfigure %}

0 comments on commit 907bdb8

Please sign in to comment.