sportrum-deploy/lib.build/README.md

65 lines
3.6 KiB
Markdown
Raw Permalink Normal View History

Add Ant deploy target, mirroring xzpect-timer's build.xml pattern install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/ tomcat_ctl.sh/restart.sh to the server so it never runs a stale hand-copied version; deploy(@host) runs that first, then sshexecs upgrade.sh itself, then checks the site responds. Reuses the sportrum webapp project's own account (sportrum@host:2222, same key as its release-all target) rather than a separate dedicated deploy user like xzpect-timer's xztimer - upgrade.sh needs real privilege (Tomcat control, pg_dump, DB migrations via the container's NOPASSWD sudo), so a second account would need the same rights anyway. This project's build.xml never builds or uploads sportrum.war/ manager.zip itself; that's release-all's job in the webapp project - this one only does the actual deploy once those are already staged. Uses the -lib lib.build / checked-in jsch jar approach for the JSch classpath gotcha, same as xzpect-timer, rather than the webapp project's ant-classloadertask trick - that one's JDK-8-only, and this build isn't guaranteed to run under the same JDK as the webapp's. Verified end-to-end short of an actual server: ant -p and ant help both hit the documented pre-flight failures correctly (missing key, missing JSch on classpath) before -lib is added, succeed after; with a real generated key, sshexec correctly gets past key-parsing and attempts a real connection. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
# lib.build/
Third-party jars needed by `build.xml`, checked in so a fresh clone on any
machine can run `ant -lib lib.build "deploy(@local.sportrum.se)"` with
nothing to download. See the comment above `<path id="deploy.classpath">`
in `build.xml` for why a plain `classpathref` isn't always enough on its
own (short version: Ant always loads its own `Scp`/`SSHExec` classes from
whatever's already on Ant's own classpath — and if something else, like
Debian/Ubuntu's `ant-optional` apt package, already put a different/older
jsch there first, this project's own copy in `lib.build/` becomes invisible
to it no matter what the project's own classpath says).
**Command line: always use `-lib lib.build`.** Confirmed this is required
whenever a system `ant-optional` package (or similar) is installed — that's
the case for a plain apt-installed Ubuntu/Debian `ant`. Leaving it off fails
fast with a clear message pointing back here, rather than a cryptic
`NoClassDefFoundError`.
**Eclipse: try it with no extra configuration first.** Whether this is
needed in Eclipse depends entirely on whether that particular Eclipse
install's bundled Ant distribution ships its own conflicting `ant-jsch.jar`.
If yours hits `taskdef ... cannot be found: com/jcraft/jsch/Logger`, add
`lib.build/jsch-*.jar` under Window -> Preferences -> Ant -> Runtime ->
Classpath -> Ant Home Entries (same underlying fix as `-lib`, just via
Eclipse's UI instead of a flag).
Currently just:
- `jsch-2.28.7.jar` — [com.github.mwiede/jsch](https://mvnrepository.com/artifact/com.github.mwiede/jsch),
a maintained fork of the original com.jcraft:jsch (same package name,
drop-in). Ant's `<scp>`/`<sshexec>` tasks need this on the classpath; the
original jcraft version predates modern SSH key-exchange algorithms and
fails against current OpenSSH defaults. Direct download:
https://repo1.maven.org/maven2/com/github/mwiede/jsch/2.28.7/jsch-2.28.7.jar
Same jar `xzpect-timer/lib.build/` uses — copied over rather than
re-resolved, so both projects are pinned to an identical, already-tested
version. If this ever needs a version bump, replace the jar here (and
probably there too, for consistency) and update the filename/link above —
nothing else in `build.xml` references the version number directly (it
just loads every `*.jar` under this folder).
## Why not `ant-classloadertask`, like the sportrum webapp project?
The sportrum webapp's own `build.xml` (its `release-all` target scps
`sportrum.war`/`manager.zip` to the server) avoids needing `-lib` at all,
via a third-party `<classloader loader="project" classpath="...">` task
that injects the jsch jar directly into Ant's own running core classloader.
That trick only works on JDK 8 — it reflectively pokes
`URLClassLoader.addURL()`, which stopped being how the JVM's application
classloader works from JDK 9 onward. The webapp project gets away with it
only because it's still built on JDK 8; xzpect-timer's `build.xml` tested
this same approach directly against JDK 21 and confirmed it's a hard dead
end there (see xzpect-timer's `lib.build/README.md` for the exact
exceptions).
This project (`sportrum-deploy`) deliberately follows xzpect-timer's
`-lib`-based approach instead of the webapp's, even though it's deployed
right alongside that JDK-8 webapp project: `ant deploy(@host)` here is a
separate Ant invocation, and there's no guarantee it always runs under the
same JDK as the webapp build — someone could easily run it from a newer
default `ant` on their machine. The `-lib` approach works on any JDK, so
it's the safer default here rather than inheriting an assumption tied to a
different project's toolchain.