Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

217.1. josm-19613

Java OpenStreetMap editor: map data, GPS traces, imagery and validation (Java Swing)

Version 19613, release 1
Shelf gis — GIS, maps, projections, GPS, navigation and location
Phase 42_graphics (Graphics Stack), 106 of 189 in build order
Licence GPL-2.0-or-later
Homepage https://josm.openstreetmap.de/
Build time 1.5 SBU
Installed size 13.0 MiB in 24 files
Recipe ports/core/gis/josm/kpkgbuild

About

JOSM is the Java OpenStreetMap editor: it downloads map data from the OpenStreetMap API, edits it over aerial imagery and GPS traces, validates the result and uploads it. It is a Swing program, run on openjdk.

Upstream builds JOSM with Apache Ant, which fetches every library through Ivy at build time. Ant and Ivy are not ports and the build has no network, so build.sh does the same work with javac, java and jar alone: it builds JavaCC from its source, generates JOSM’s two grammars with it, compiles JOSM together with the source of every library it uses, and packs one jar. Each library is its own source = line, a -sources.jar from Maven Central (or the JOSM repository, for JMapViewer) or a tag archive from GitHub, pinned by a helper variable in the recipe; no upstream-compiled class reaches the package (see What is built from source). The tag2link index is the one exception, taken as data from its webjar (see Data with no other source form).

Sources

Dependencies

Depends on: openjdk, unzip.

Required by: no port names it.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install josm'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/gis/josm.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/gis/josm
echo '66a8530d9c380c05b539e1773bc45195a0ff1ea19a3393c3bd9cad331ad7b7f8  OpeningHoursParser-0.29.0-sources.jar' | sha256sum -c -
echo '8e9ff9d22782bc25cc6c241eac893bbf36f3de81f7fc7e28e9c162a75b34401b  adobe-xmp-core-6.1.10.tar.gz' | sha256sum -c -
echo '0590a3ec06b522b4aae684ddb63c063cd11bd547fd9baaa5e71f6b020e2a7df4  annotations-24.1.0-sources.jar' | sha256sum -c -
echo 'a60b7ec93ec278fff28ab8c6792a8fb738e0c7c0a9f8cab22dc3730b776adb36  biz.aQute.bnd.annotation-7.1.0-sources.jar' | sha256sum -c -
echo 'b0462142585d45fc15bc8091b7b02f1e3a85c83595068659548c82cac9cdc7a2  commons-codec-1.19.0-sources.jar' | sha256sum -c -
echo '6de9de4559f12bba6d41789c72f6a2a424514f2d2a3f7f49e2a3c52414db9632  commons-compress-1.28.0-sources.jar' | sha256sum -c -
echo '7a87277538cce40da6389a7163a4d9458bc7a9c39937a329881b91d144be8e0d  commons-io-2.20.0-sources.jar' | sha256sum -c -
echo 'fb252a6690f41d547bcbf32178301d98fb30a61ee397ac7facc30130aaa519af  commons-jcs3-core-3.2.1-sources.jar' | sha256sum -c -
echo 'b15732a13e40df7f07c30f2cb8572874798e8dde581f1398943d2ad3765bafaa  commons-lang3-3.18.0-sources.jar' | sha256sum -c -
echo 'f7f5b870d5f18bcdcd9d8dc44d6ae3593cc299d32f888aeb29fefe87661473d7  error_prone_annotations-2.50.0-sources.jar' | sha256sum -c -
echo '142dfd2343429df2aac3e1cfacfacc21c8393112c0e0280d3628648d9b612470  jakarta.annotation-api-3.0.0-sources.jar' | sha256sum -c -
echo '1b1f8585037ae1f34afd052013cc36788853bd4ad4ed566fe5f190b63c5008d2  jakarta.json-api-2.1.3-sources.jar' | sha256sum -c -
echo '3c062dd69ea40a8d2c93e2a62f6f3647cd611914abbf51bf2e4865c8d51e5427  javacc-7.0.13-sources.jar' | sha256sum -c -
echo '57f1917823a896138a9ab913331c31407ab75a57e64b2d56022cf4807eb03f29  jmapviewer-2.25-sources.jar' | sha256sum -c -
echo '71ad58ee5e5230ddd52fa88cf07e557b1233b906142500b6e92dd96926e023b9  josm-19613.tar.gz' | sha256sum -c -
echo '10d0c55cbfe150cf6dc4b0856cabc974a7c33f0c068383642dbeb0285d8125b0  jsvg-2.1.0.tar.gz' | sha256sum -c -
echo 'e1e1494b08e90da072d0c90ce3f807b181e3f0a1f0f464c11ec637612ae8eff1  metadata-extractor-2.19.0-sources.jar' | sha256sum -c -
echo 'bff6b8f778ee2ad0c53667ccdea907ec7f1715ed63b437a4d9b88028a68af849  org.osgi.namespace.extender-1.0.1-sources.jar' | sha256sum -c -
echo '4de0a3a5f81b5f9635bf8dcaac1227ba011ffedd33d3d3961038a55d98762042  org.osgi.resource-1.0.0-sources.jar' | sha256sum -c -
echo '7d4783b570cd118263bc6a807c0a7c183b1db451442ffcb8a36310ad24a91743  org.osgi.service.serviceloader-1.0.0-sources.jar' | sha256sum -c -
echo 'b1f418597a5029764973731d9e68835f13eb3bf4e7a69898e690ec50445a7a76  osgi.annotation-8.1.0-sources.jar' | sha256sum -c -
echo '713a473593782f3500e4fe829fb9b0d282e72cc67970ddbea4447fe93d045511  parsson-1.1.7-sources.jar' | sha256sum -c -
echo 'be4ac4e1a0be7e8740de72b623668ec4a89340f29ea5bf1f72f37c22a55eb3a3  tag2link-2026.6.26.jar' | sha256sum -c -
echo 'aab470d8c28e718859f9c1f333ed693f926cd44d8e55851c0dda27dd4a6d568c  xz-1.11-sources.jar' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/josm
SRC=$SRC_ROOT/josm-19613
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf josm-19613.tar.gz -C "$SRC" --strip-components=1
cp javacc-7.0.13-sources.jar "$SRC"
cp jmapviewer-2.25-sources.jar "$SRC"
cp jakarta.json-api-2.1.3-sources.jar "$SRC"
cp parsson-1.1.7-sources.jar "$SRC"
cp commons-jcs3-core-3.2.1-sources.jar "$SRC"
cp commons-compress-1.28.0-sources.jar "$SRC"
cp commons-io-2.20.0-sources.jar "$SRC"
cp commons-lang3-3.18.0-sources.jar "$SRC"
cp commons-codec-1.19.0-sources.jar "$SRC"
cp jakarta.annotation-api-3.0.0-sources.jar "$SRC"
cp xz-1.11-sources.jar "$SRC"
tar --no-same-permissions --warning=no-unknown-keyword -xf adobe-xmp-core-6.1.10.tar.gz -C "$SRC_ROOT"
cp metadata-extractor-2.19.0-sources.jar "$SRC"
tar --no-same-permissions --warning=no-unknown-keyword -xf jsvg-2.1.0.tar.gz -C "$SRC_ROOT"
cp error_prone_annotations-2.50.0-sources.jar "$SRC"
cp annotations-24.1.0-sources.jar "$SRC"
cp biz.aQute.bnd.annotation-7.1.0-sources.jar "$SRC"
cp osgi.annotation-8.1.0-sources.jar "$SRC"
cp org.osgi.namespace.extender-1.0.1-sources.jar "$SRC"
cp org.osgi.service.serviceloader-1.0.0-sources.jar "$SRC"
cp org.osgi.resource-1.0.0-sources.jar "$SRC"
cp OpeningHoursParser-0.29.0-sources.jar "$SRC"
cp tag2link-2026.6.26.jar "$SRC"

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _maven, _josmrepo, _javacc, _jmapviewer, _jsonapi, _parsson, _jcs, _compress, _io, _lang3, _codec, _annotation, _xz, _xmp, _metadata, _jsvg, _jbannot, _errorprone, _bnd, _osgiannot, _osgiext, _osgisl, _osgires, _ohp, _tag2link and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mkdir -p build/javacc-src build/javacc
unzip -q "javacc-$_javacc-sources.jar" -d build/javacc-src
find build/javacc-src -name '*.java' | LC_ALL=C sort > build/javacc.list
javac -encoding UTF-8 -nowarn -proc:none -d build/javacc @build/javacc.list
cp -r build/javacc-src/templates build/javacc-src/version.properties build/javacc/
_mapcss=src/org/openstreetmap/josm/gui/mappaint/mapcss
( cd "$_mapcss" && java -cp "$SRC/build/javacc" javacc \
	-DEBUG_PARSER=false -DEBUG_TOKEN_MANAGER=false -JDK_VERSION=1.11 \
	-GRAMMAR_ENCODING=UTF-8 -UNICODE_INPUT=true MapCSSParser.jj )

_dep=build/depsrc
mkdir -p "$_dep" build/classes
for _j in jmapviewer-$_jmapviewer jakarta.json-api-$_jsonapi parsson-$_parsson \
	commons-jcs3-core-$_jcs commons-compress-$_compress commons-io-$_io \
	commons-lang3-$_lang3 commons-codec-$_codec \
	jakarta.annotation-api-$_annotation xz-$_xz \
	metadata-extractor-$_metadata annotations-$_jbannot \
	error_prone_annotations-$_errorprone biz.aQute.bnd.annotation-$_bnd \
	osgi.annotation-$_osgiannot org.osgi.namespace.extender-$_osgiext \
	org.osgi.service.serviceloader-$_osgisl org.osgi.resource-$_osgires \
	OpeningHoursParser-$_ohp; do
	unzip -q -o "$_j-sources.jar" -d "$_dep"
done
cp -r "$SRC_ROOT/adobe-xmp-core-$_xmp/com" "$_dep/"
cp -r "$SRC_ROOT/jsvg-$_jsvg/jsvg/src/main/java/." "$SRC_ROOT/jsvg-$_jsvg/annotations/src/main/java/." "$_dep/"
( cd "$_dep/ch/poole/openinghoursparser" && java -cp "$SRC/build/javacc" javacc \
	-GRAMMAR_ENCODING=UTF-8 OpeningHoursParser.jj )
rm -rf "$_dep/META-INF/maven" "$_dep/META-INF/MANIFEST.MF" "$_dep/META-INF/versions"
find "$_dep" -name module-info.java -delete

_jcs=$_dep/org/apache/commons/jcs3
rm -rf "$_jcs/auxiliary/disk/jdbc" "$_jcs/auxiliary/remote/http" "$_jcs/utils/servlet" \
	"$_jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java" \
	"$_jcs"/log/Log4j2*.java
{
	find src -name '*.java' ! -name package-info.java ! -name module-info.java
	find "$_dep/org/eclipse/parsson" "$_jcs" -name '*.java' ! -name package-info.java
} | LC_ALL=C sort > build/sources.list
javac -encoding UTF-8 -nowarn -proc:none -implicit:class --release 21 \
	-d build/classes -sourcepath "$_dep:src" @build/sources.list

mkdir -p build/epsg resources/data/projection
: > resources/data/projection/custom-epsg
javac -encoding UTF-8 -nowarn -d build/epsg -cp build/classes scripts/BuildProjectionDefinitions.java
java -Djava.awt.headless=true -cp "resources:build/classes:build/epsg" BuildProjectionDefinitions .

_date=$(date -u -d "@$SOURCE_DATE_EPOCH" '+%Y-%m-%d %H:%M:%S')
printf 'Revision: %s\nBuild-Date: %s\n' "$version" "$_date" > resources/REVISION
cp CONTRIBUTION README LICENSE resources/

find resources/data -maxdepth 1 -name '*.lang' ! -name 'en*.lang' -delete

cp -r resources/. build/classes/
( cd "$_dep" && find . -type f ! -name '*.java' ! -name '*.jj' ! -name '*.html' \
	! -path './META-INF/LICENSE*' ! -path './META-INF/NOTICE*' \
	-exec cp --parents {} "$SRC/build/classes/" \; )
unzip -q -o "tag2link-$_tag2link.jar" 'META-INF/resources/webjars/tag2link/*/index.json' \
	-d build/classes

cat > build/manifest.txt <<MANIFEST
Main-Class: org.openstreetmap.josm.gui.MainApplication
Main-Version: $version SVN
Main-Date: $_date
Application-Name: JOSM - Java OpenStreetMap Editor
Add-Exports: java.base/sun.security.action java.desktop/com.sun.imageio.spi java.desktop/com.sun.imageio.plugins.jpeg
Add-Opens: java.base/java.lang java.base/java.nio java.base/jdk.internal.loader java.base/jdk.internal.ref java.desktop/javax.imageio.spi java.desktop/javax.swing.text.html java.prefs/java.util.prefs
MANIFEST
( cd build/classes && find . -type f | LC_ALL=C sort | sed 's/.*/"&"/' > ../classes.list )
( cd build/classes && jar --create --file ../josm.jar --manifest ../manifest.txt \
	--date="$(date -u -d "@$SOURCE_DATE_EPOCH" '+%Y-%m-%dT%H:%M:%SZ')" @../classes.list )

install -Dm644 build/josm.jar "$PKG/usr/share/josm/josm.jar"
install -d "$PKG/usr/bin"
cat > "$PKG/usr/bin/josm" <<'LAUNCHER'
#!/bin/sh
_first=$1
set -- java -XX:MaxRAMPercentage=75.0 -Djava.net.useSystemProxies=true \
	--add-modules java.scripting,java.sql \
	--add-exports=java.base/sun.security.action=ALL-UNNAMED \
	--add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED \
	--add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED \
	-jar /usr/share/josm/josm.jar "$@"
case $_first in
render|validate|project) exec "$@" ;;
esac
exec "$@" --offline=JOSM_WEBSITE
LAUNCHER
chmod 755 "$PKG/usr/bin/josm"

_n=native/linux/tested/usr/share
install -Dm644 "$_n/man/man1/josm.1" "$PKG/usr/share/man/man1/josm.1"
install -Dm644 "$_n/mime/packages/josm.xml" "$PKG/usr/share/mime/packages/josm.xml"
install -Dm644 "$_n/metainfo/org.openstreetmap.josm.appdata.xml" \
	"$PKG/usr/share/metainfo/org.openstreetmap.josm.appdata.xml"
for _i in "$_n"/icons/hicolor/*/apps/org.openstreetmap.josm.png; do
	_s=${_i#"$_n/icons/hicolor/"}
	install -Dm644 "$_i" "$PKG/usr/share/icons/hicolor/$_s"
done

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/org.openstreetmap.josm.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=JOSM
GenericName=OpenStreetMap Editor
Comment=Edit OpenStreetMap data, GPS traces and map imagery
Exec=josm %U
Icon=org.openstreetmap.josm
Terminal=false
StartupWMClass=org-openstreetmap-josm-gui-MainApplication
Categories=Education;Geography;Maps;
MimeType=application/vnd.openstreetmap.data+xml;application/x-josm-session+xml;application/x-josm-session+zip;
Keywords=openstreetmap;osm;map;editor;gps;gpx;
DESKTOP
chmod 644 "$PKG/usr/share/applications/org.openstreetmap.josm.desktop"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/josm, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf josm-19613-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/josm, and runs the triggers its paths call for.

Contents

Installed programs: josm.

Installed directories: /usr/share/josm, /usr/share/licenses/josm.

Short descriptions

josm Java OpenStreetMap Editor

Notes

The order inside build.sh matters. JavaCC must be compiled before either grammar is generated; its source archive carries its own generated parsers, so it compiles with javac alone. MapCSSParser.jj and OpeningHoursParser’s OpeningHoursParser.jj must be turned into Java before the main javac, which compiles the generated parsers with everything else. The empty resources/data/projection/custom-epsg must exist before BuildProjectionDefinitions runs: the generator loads the projection code from build/classes, and that code reads custom-epsg from the class path. With no file there, the generator creates an empty one and stops, asking to be run again, and the list is not written.

Two libraries are compiled explicitly rather than found through -implicit:class, because nothing in JOSM’s source names their classes: parsson, the jakarta.json implementation, which upstream’s ivy.xml lists as runtime-only and which is found through ServiceLoader, and commons-jcs3, which builds its caches from class names given as strings in its configuration. Parts of commons-jcs3 are deleted first: the JDBC disk cache (it needs commons-dbcp2), the HTTP remote cache and the servlet utilities (the servlet API), and the Log4j 2 logger (Log4j). None of those libraries is a port, and JOSM configures none of those parts. Every module-info.java is deleted: everything is compiled into one unnamed module, and a module descriptor on the source path would turn the whole compilation into that module. The libraries’ Maven metadata, manifests and multi-release META-INF/versions trees go too, so that none of them is copied into the jar beside JOSM’s own manifest.

jsvg and the Adobe XMP core come from GitHub tag archives rather than -sources.jar files; jsvg’s published sources lack its annotations module, which the release tree has.

Every translation except English is deleted from resources/data before the jar is packed. KDOS ships English only (see the size and language policy), and the package’s own pruning removes files in the package, not entries inside a jar.

The jar is reproducible: its file list is sorted, resources/REVISION and the manifest’s Main-Date come from SOURCE_DATE_EPOCH, and jar --date stamps every entry with the same time. The list has one quoted name per line, because some resource names contain spaces.

Swing is an X11 client under Xwayland, and its WM_CLASS is the main class with its dots turned into dashes, which is what the desktop entry’s StartupWMClass=org-openstreetmap-josm-gui-MainApplication matches.