Version 42 (modified by 32 hours ago) ( diff ) | ,
---|
Table of Contents
Compiling JOSM using IDE
This page describes how to compile the Java source code in IDE in order to get a runnable josm-custom.jar
file.
Getting the Source
Compiling
Compiling using Ant
The easiest way to compile JOSM
→ Source code#CompilingusingAnt
Compiling using Eclipse + Maven
Download and install Eclipse: https://www.eclipse.org/
If you were previously using the .project
and .classpath
file that were in source control, you must first remove the old project (right-click -> Delete
-> OK
-- DO NOT check Delete project contents on dist (cannot be undone)
).
You will want to use File
-> Import...
-> Existing Maven Projects
-> root source directory -> leave all Projects
checked.
Once the import finishes, you may want to run Update Project...
(right click on a project -> Maven
-> Update Project...
-> Select All
-> OK
) since that will regenerate various Eclipse files.
Compiling using Netbeans
- Download and install Netbeans: https://netbeans.org/
- File → Open Project
- Navigate to the JOSM source code (see #GettingtheSource), subdirectory
ide/netbeans/
- Use
1
to compile,2
to clean and compile, and3
to run JOSM:
- Note that the build needs to be run twice! (The first build will write ivy.classpath in project.properties, second build will read it.)
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
Prerequisites
Here are some of the tools you will need for installing under most linux operating systems. Tools: ant, java jdk/jre 8, junit Example install for Ubuntu Linux:
sudo apt-get install ant openjdk-8-jdk junit # please install these ahead, you definitely need them
All tests
The quickest way to run the tests is done using the 'ant' build system.
ant clean test # this will run through all 200+ tests marking them sucessful, failure, in error, or skipped.
Individual tests
You can run individual tests from the command line, as well. For instance, to run ProjectionRefTest
only:
ant test '-Ddefault-junit-includes=**/ProjectionRefTest.class'
Individual tests (complex variant)
You can run individual 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/commons-testing/*:test/lib/fest/*:test/lib/junit/*:test/lib/*:test/lib/unitils-core/*" export TESTCP=$TESTCP:"tools/*:tools/spotbugs/*:test/lib/reflections/*:tools/pmd/*" # added these missing directories. Without it will fail to run.
Here are a few build and run instructions for some example tests:
# Projections Reference Test 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 # Download GPS Task Test javac -cp $TESTCP test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTaskTest.java java -cp $TESTCP org.junit.runner.JUnitCore org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTaskTest
On Windows the syntax is almost the same:
set TESTCP=".;test/unit;test/functional;dist/josm-custom.jar;test/lib/commons-testing/*;test/lib/fest/*;test/lib/junit/*;test/lib/*;test/lib/unitils-core/*;tools/*;tools/spotbugs/*" 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 # and similar for the Download GPS Task Test javac -cp %TESTCP% test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTaskTest.java java -cp %TESTCP% org.junit.runner.JUnitCore org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTaskTest
Data validator tests
The data validator tests are run within JOSM.
Enable advanced preferences and set validator.check_assert_local_rules
to true
. Then, go to data validator tag checker rules, and locate the entry with the file containing the tests you would like to run. Set its path to the local copy you are editing. Once your changes are confirmed, all the assertions in that file are run. Any failures are printed to the console as warnings.
Whenever you update the file on disk, JOSM will automatically rerun the assertions and print failures to the console again.
Attachments (3)
- netbean-open.png (17.4 KB ) - added by 9 years ago.
- netbeans-compile-run.png (21.8 KB ) - added by 9 years ago.
- netbean-open2.png (31.8 KB ) - added by 5 years ago.
Download all attachments as: .zip