|
| 1 | +# Architecture |
| 2 | + |
| 3 | +## Flow |
| 4 | + |
| 5 | +``` |
| 6 | +PackageMojo (Maven) | PackagePlugin + PackageTask (Gradle) |
| 7 | + → Context.setContext(MavenContext | GradleContext) |
| 8 | + → PackagerFactory.createPackager(platform) + fluent settings |
| 9 | + → packager.createApp() → packager.generateInstallers() → packager.createBundles() |
| 10 | +``` |
| 11 | + |
| 12 | +## Key pieces |
| 13 | + |
| 14 | +- `packagers/Context` — static singleton hiding the build tool. Declares tool-specific operations (runnable JAR, copy dependencies, tarball, zipball, license, Launch4j EXE) and registers installer generators per platform. |
| 15 | +- `maven/MavenContext` — implements them by running other Maven plugins through `mojo-executor` (`maven/*` classes). |
| 16 | +- `gradle/GradleContext` — implements them with Gradle tasks (`gradle/*` classes with the same names). |
| 17 | +- `PackagerSettings` — every configuration property, with fluent setters. Also the base of the Gradle extension `PackagePluginExtension`. |
| 18 | +- `Packager` — shared pipeline: init, resolve resources/icons/license, app folder structure, bundle JRE, run installer generators. Subclasses `WindowsPackager`, `MacPackager`, `LinuxPackager` implement `doInit`, `doCreateAppStructure`, `doCreateApp`. |
| 19 | +- `ArtifactGenerator<T>` — unit of work: `skip(packager)` decides, `doApply(packager)` produces a `File`. Installers (`GenerateDeb`, `GenerateDmg`, `GenerateMsi`, ...), `BundleJre` and the Windows EXE creators are generators. |
| 20 | +- `utils/VelocityUtils` — renders `.vtl` templates, first from the user's `assetsDir`, then from the classpath. The packager is exposed as `$info` (plus `$StringUtils`, `$GUID`, `$features`). |
| 21 | +- `utils/CommandUtils` — runs external tools (`jlink`, `jdeps`, `iscc`, `candle`/`light`, `hdiutil`, `pkgbuild`, `codesign`, `rcedit`). |
| 22 | +- `utils/Logger` — wraps the Maven or Gradle logger, with indentation helpers. |
| 23 | +- `net/jsign/WindowsSigner` — Windows code signing on top of `jsign-core`. |
| 24 | + |
| 25 | +## Windows launcher |
| 26 | + |
| 27 | +`WindowsConfig.exeCreationTool` picks how the EXE is built: `launch4j` (via the context), `winrun4j` (`CreateWindowsExeWinRun4j`) or `why` (`CreateWindowsExeWhy`). |
| 28 | + |
| 29 | +## WiX version |
| 30 | + |
| 31 | +`GenerateMsm` detects the WiX major version (`wix -version`, falling back to `candle`/`light` as v3) and stores it in the packager. `GenerateMsi` relies on that, so MSM must stay registered before MSI in `Context`. v3 uses `candle` + `light`; v4+ uses `wix build`. |
| 32 | + |
| 33 | +## Folder map |
| 34 | + |
| 35 | +- `src/main/java/.../javapackager/maven/` — Maven mojo and Maven-based operations. |
| 36 | +- `src/main/java/.../javapackager/gradle/` — Gradle plugin, task, extension and Gradle-based operations. |
| 37 | +- `src/main/java/.../javapackager/packagers/` — build-tool-independent pipeline and generators. |
| 38 | +- `src/main/java/.../javapackager/model/` — configuration model (`WindowsConfig`, `MacConfig`, `LinuxConfig`, `FileAssociation`, ...). |
| 39 | +- `src/main/java/.../javapackager/utils/` — helpers (files, commands, Velocity, JDK, icons, XML). |
| 40 | +- `src/main/resources/{linux,mac,windows}/` — Velocity templates, default icons and bundled native binaries (WinRun4J, `JavaLauncher.exe`, `rcedit-x64.exe`, `nativeJavaApplicationStub*`, `universalJavaApplicationStub.sh`). |
| 41 | +- `docs/` — user documentation for platform-specific properties and samples. |
0 commit comments