= Compiling using ​IntelliJ IDEA = This describes how to develop and [wiki:DevelopersGuide/Compiling compile] JOSM using [https://www.jetbrains.com/idea/ IntelliJ IDEA] == Getting the source code == 1. Follow the steps in [[Source code#Getthesource]] to get the source code from Subversion. For this guide, assume it is located in a folder `josm-svn`. == Import the project into IntelliJ == 1. Import the project into IntelliJ using the menu: `File` → `New` → `Project from Existing Sources`. Follow the wizard: 1. Navigate to the folder containing the project, and select it. 1. Select `Create Project from existing sources`. [[BR]] [[Image(intellij-start-from-sources (2).png, 400)]] 1. Give the project a name, and click `Next`. [[BR]] [[Image(intellij-start-from-sources (3).png, 400)]] 1. IntelliJ auto-detects the folders which contain source code. Click `Next`. [[BR]] [[Image(intellij-start-from-sources (4).png, 400)]] 1. IntelliJ auto-detects the project libraries. Click `Next`. [[BR]] [[Image(intellij-start-from-sources (5).png, 400)]] 1. IntelliJ auto-detects a number of project modules. Click `Next`. [[BR]] [[Image(intellij-start-from-sources (6).png, 400)]] 1. Select a Java SDK, at least version 8. Click `Next`. [[BR]] [[Image(intellij-start-from-sources (7).png, 400)]] 1. Deselect OSGI automatic configuration. Click `Next`. [[BR]] [[Image(intellij-start-from-sources (8).png, 400)]] == Building the project == 1. When you are prompted to add IntelliJ project configuration to Subversion, check the box `Don't ask again`, and click `Cancel`. [[BR]] [[Image(intellij-start-from-sources (9).png, 400)]] 1. IntelliJ will index the project. [[BR]] [[Image(intellij-start-from-sources (10).png, 400)]] 1. Open the `Ant` tool window. It contains no configuration yet. [[BR]] [[Image(intellij-start-from-sources (11).png, 400)]] 1. Click the `+` button to add an Ant configuration file. Select the file `build.xml` [[BR]] [[Image(intellij-start-from-sources (12).png, 400)]] 1. The Ant tool window should now list Ant tasks. [[BR]] [[Image(intellij-start-from-sources (13).png, 400)]] 1. Double click the `dist` task. It will build the project. The `Messages` tool window will show the progress and logging output. [[BR]] [[Image(intellij-start-from-sources (14).png, 400)]] 1. There should now be a built file: `dist/josm-custom.jar`. [[BR]] [[Image(intellij-start-from-sources (15).png, 400)]] == Running the project == 1. There are no run configurations configured. Click `Add configuration`. [[BR]] [[Image(intellij-start-from-sources (16).png, 400)]] 1. Click the `+` button to add a new `JAR Application` configuration. [[BR]] [[Image(intellij-start-from-sources (17).png, 400)]] 1. Give the new configuration a name. [[BR]] [[Image(intellij-start-from-sources (18).png, 400)]] 1. In the field `Path to JAR`, choose the built Jar file. [[BR]] [[Image(intellij-start-from-sources (19).png, 400)]] 1. Add a `Before launch` configuration item, `Run Ant target`. [[BR]] [[Image(intellij-start-from-sources (20).png, 400)]] 1. A window will popup with all the available Ant tasks. Choose `dist`. [[BR]] [[Image(intellij-start-from-sources (21).png, 400)]] 1. The configuration should now be ready and selected in the project. [[BR]] [[Image(intellij-start-from-sources (22).png, 400)]] 1. Click the `Run` (play) button. The project should build again, and then run. [[BR]] [[Image(intellij-start-from-sources (23).png, 400)]] == Running the tests == 1. Open the `Ant` tool window. Run the `test` task. [[BR]] [[Image(intellij-test.png.png, 400)]] = Additional settings = This section describes helpful additional settings for IntelliJ IDEA. == Link ticket references in commit messages == Make ticket references in the code of the form `ticket 1234` or `#1234` clickable as a link to the Trac ticket. 1. Open the `Issue Navigation` settings page. [[BR]] [[Image(ticket-integration (1).png, 400)]] 2. Add a new `Issue Navigation` item, with: - `Issue ID`: `(ticket\s*|#)(\d+)` - `Issue link`: `https://josm.openstreetmap.de/ticket/$2` [[BR]] [[Image(ticket-integration (2).png, 400)]] == Search open issues == [[Image(intellij-task-search.png)]] → Tools → Tasks & Contexts → Open Task