wiki:DevelopersGuide/CompilingUsingIntelliJ

Version 8 (modified by hiddewie, 5 years ago) ( diff )

Added many more steps on importing, building and running the project with IntelliJ

Compiling using ​IntelliJ IDEA

This describes how to develop and compile JOSM using 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: FileNewProject from Existing Sources. Follow the wizard:
    1. Navigate to the folder containing the project, and select it.
    2. Select Create Project from existing sources.
      No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
    3. Give the project a name, and click Next.
      No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
    4. IntelliJ auto-detects the folders which contain source code. Click Next.
      No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
    5. IntelliJ auto-detects the project libraries. Click Next.
      No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
    6. IntelliJ auto-detects a number of project modules. Click Next.
      No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
    7. Select a Java SDK, at least version 8. Click Next.
      No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
    8. Deselect OSGI automatic configuration. Click Next.
      No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ

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.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  2. IntelliJ will intex the project.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  3. Open the Ant tool window. It contains no configuration yet.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  4. Click the + button to add an Ant configuration file. Select the file build.xml
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  5. The Ant tool window should now list Ant tasks.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  6. Double click the dist task. It will build the project. The Messages tool window will show the progress and logging output.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  7. There should now be a built file: dist/josm-custom.jar.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ

Running the project

  1. There are no run configurations configured. Click Add configuration.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  2. Click the + button to add a new JAR Application configuration.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  3. Give the new configuration a name.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  4. In the field Path to JAR, choose the built Jar file.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  5. Add a Before launch configuration item, Run Ant target.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  6. A window will popup with all the available Ant tasks. Choose dist.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  7. The configuration should now be ready and selected in the project.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ
  8. Click the Run (play) button. The project should build again, and then run.
    No image "intellij-from--01.png" attached to DevelopersGuide/CompilingUsingIntelliJ

1.

  1. Run ant in the source directory to obtain a josm-custom.jarSource code#CompilingusingAnt
  2. In IntelliJ: File → New → Project from Existing Sources
    1. Navigate to the JOSM source code
  3. File → Project Structure
    • Modules → Sources: Exclude the directory src/org/apache
    • Modules → Dependencies: Make sure that josm-custom (i.e., the file generated by Ant is listed)
    • Modules → Dependencies: Add Groovy (you might need to configure that at "Global Libraries")
  4. Run → Edit Configuration
    • Add an "Application" configuration

Whenever presets, images, styles, or parser definitions change, re-run Ant in order to have those modifications included in josm-custom.jar.

This is a bit hackish, but works nicely. ☻

Additional settings

This section describes helpful additional settings for IntelliJ IDEA.

Link ticket references in commit messages

→ Ticket references in version control log are clickable

Search open issues

→ Tools → Tasks & Contexts → Open Task

Attachments (44)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.