wiki:DevelopersGuide/Compiling

Version 7 (modified by Don-vip, 8 years ago) ( diff )

simplify/update procedure tu run unit tests on command line

This page describes how to compile the Java source code in order to get a runnable josm-custom.jar file.

Getting the Source

Download#Source

Compiling using Ant

The easiest way to compile JOSM, provided Java JDK and Ant on your machine are properly set up, is to go to the josm directory and type:

ant

That will create a dist/josm-custom.jar file if successful.

Compiling using Eclipse

Download and install Eclipse: https://www.eclipse.org/

Use Eclipse and the provided .project and .classpath file. Just import project using the JOSM core folder as root directory.

You will have problems compiling, due to problems compiling Mappaint MapCSS with a fresh install of Eclipse. First you will need the JavaCC plugin for Eclipse. To install it in Eclipse, go to Help->New Software... then add the site http://eclipse-javacc.sourceforge.net/ as a source, and install the JavaCC Eclipse Plug-in. Then in the Package Explorer, expand org.openstreetmap.josm.gui.mappaint.mapcss, right-click on MapCSSParser.jj, and "Compile with JavaCC". This should put new java files in a package called org.openstreetmap.josm.gui.mappaint.mapcss.parsergen, but if it doesn't, you will have to create the package manually (right-click and create package), then drag the new files into the package you just created (they should be easy to identify based on the light gray text that denotes it was compiled from MapCSSParser.jj). This should resolve any import issues in MapCSSStyleSource.java, and you should now be able to compile JOSM.

If you try to compile the JOSM sources in Eclipse and get errors like "The method marktr(String) is undefined for the type SomeType" look at solution suggested at mailing list.

There are also two Videos available at youtube, which show how to checkout JOSM into Eclipse and how to checkout a JOSM plugin into Eclipse.

Compiling using Netbeans

  1. Download and install Netbeans: https://netbeans.org/
  2. File → Open Project
  3. Navigate to the JOSM source code (see #GettingtheSource), subdirectory netbeans/
  4. Use 1 to compile, 2 to clean and compile, and 3 to run JOSM:

Compiling using ​IntelliJ IDEA

DevelopersGuide/CompilingUsingIntelliJ

Unit Tests

It is most convenient, to run tests from an IDE like Eclipse or Netbeans. There is also an ant task to run all tests (but you cannot rerun individual tests).

All unit tests can be run in headless mode (i.e, without a graphic display), allowing them to be run in continuous integration projects.

Running Test from Command line

You can run tests from the command line, as well. Include all libraries in the class path like this:

export TESTCP=".:test/unit:test/functional:dist/josm-custom.jar:test/lib/fest/*:test/lib/junit/*:test/lib/*:test/lib/unitils-core/*"

Then run for example

javac -cp $TESTCP test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
java -cp $TESTCP org.junit.runner.JUnitCore org.openstreetmap.josm.data.projection.ProjectionRefTest

On Windows the syntax is almost the same:

set TESTCP=".;test/unit:test/functional;dist/josm-custom.jar;test/lib/fest/*;test/lib/junit/*;test/lib/*;test/lib/unitils-core/*"
javac -cp %TESTCP% test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
java -cp %TESTCP% org.junit.runner.JUnitCore org.openstreetmap.josm.data.projection.ProjectionRefTest

Attachments (3)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.