diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d7071bc..050840d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest] + os: [macos-latest, ubuntu-latest, windows-latest] steps: - name: Checkout Code @@ -61,6 +61,7 @@ jobs: files: | artifacts/*.dmg artifacts/*.deb + artifacts/*.msi body: "Automatic build of ${{ github.ref_name }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 249acd3..5eb3b76 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ # NativeJavaApp Scaffold for creating double-clickable apps using Java -This project uses Apache Ant and JDK 25 to compile, bundle, and package a Java application into native installers (.dmg for macOS and .deb for Ubuntu). +This project uses Apache Ant and JDK 25 to compile, bundle, and package a Java application into native installers (.dmg for macOS, .deb for Ubuntu, and .msi for Windows). ## Common Requirements (All Systems) Before running the build, ensure the following are installed and configured: -- JDK 21 or 25: Must be installed. jpackage was introduced in JDK 14, but JDK 21+ is recommended for modern macOS/Linux support. +- JDK 21 or 25: Must be installed. Although jpackage was introduced in JDK 14, JDK 21+ is recommended for modern macOS/Linux/Windows support. - Apache Ant: Installed and available in your PATH. -- JAVA_HOME: This environment variable must point to your JDK installation directory. - - Check via: ant -version and java -version +- `JAVA_HOME`: This environment variable must point to your JDK installation directory. + - Check via: `ant -version` and `java -version` ## macOS Setup To build the .dmg installer, your Mac needs the following: - Xcode Command Line Tools: Required for various build utilities. - - Install via: xcode-select --install + - Install via: `xcode-select --install` - Icon Asset: A file named icon.icns must be in the project root. - Note on Security: Since the app is not "Signed" with an Apple Developer Certificate, users may need to Right-Click > Open the app the first time to bypass the "Unidentified Developer" warning. ## Ubuntu / Debian Setup @@ -27,24 +27,35 @@ sudo apt install ant fakeroot dpkg-dev - fakeroot: Allows the package to be built with correct file permissions without requiring root access. - dpkg-dev: Provides the core utilities to create Debian packages. - Icon Asset: A file named icon.png (512x512 recommended) must be in the project root. +## Windows Setup +To build the .msi installer on Windows, ensure the following: +- JDK 21 or 25: Must be installed with JAVA_HOME configured. +- Apache Ant: Installed and available in your PATH. +- WiX Toolset: Required by jpackage to create MSI installers. + - Download and install from: https://wixtoolset.org/releases/ + - Version 3.11 or higher is recommended. + - After installation, verify WiX is in your PATH by running: `candle -?` +- Icon Asset: A file named icon.ico must be in the project root. +- Note on Security: Windows may show a SmartScreen warning for unsigned installers. Users will need to click "More info" > "Run anyway" to install the app. ## Project Directory Structure Ensure your project looks like this for the build.xml to find all resources: ```Plaintext -MyAntApp/ +MyAppName/ ├── src/ │ └── Main.java # Your source code ├── icon.icns # Required for macOS DMG ├── icon.png # Required for Ubuntu DEB +├── icon.ico # Required for Windows MSI └── build.xml # The Ant build script ``` ## Usage Commands -Open your terminal in the project root and use the following targets: +Open a terminal in the project root and use the following targets: | Command | Description | |-----|-----| | ant | The default; runs the package target. | -| ant package | Automatically detects OS and builds .dmg (Mac) or .deb (Linux). | +| ant package | Automatically detects OS and builds .dmg (Mac), .deb (Linux), or .msi (Windows). | | ant run | Compiles and launches the app immediately for testing. | | ant clean | Deletes the build/ and dist/ folders to start fresh. | | ant -p | Displays a help menu of all available targets. | @@ -58,6 +69,10 @@ Open your terminal in the project root and use the following targets: Linux Icon Error: If the Linux build fails, ensure icon.png is not just a renamed .icns or .jpg. It must be a valid PNG file. + + Windows "candle.exe not found": + Install WiX Toolset 3.11+ and ensure it's in your PATH. jpackage uses WiX to create MSI installers on Windows. + Permissions: If the generated .app or .deb won't execute, ensure you have the necessary write permissions in the dist/ directory. @@ -69,15 +84,15 @@ This project uses GitHub Actions to automatically build and distribute native in ### The Build Phase (Continuous Integration) Every time you push code to the main branch or open a Pull Request: -- GitHub starts a macOS runner and an Ubuntu runner. -- Both systems compile the code and create their respective installers (.dmg and .deb). +- GitHub starts a macOS runner, an Ubuntu runner, and a Windows runner. +- All systems compile the code and create their respective installers (.dmg, .deb, and .msi). - The installers are saved as Artifacts in the GitHub Actions run summary for 90 days. ### The Release Phase (Continuous Deployment) A formal GitHub Release is only triggered when you push a version tag. -This creates a permanent download page for your users. +This creates a permanent download page for users. #### How to trigger a new release: -To release a new version (e.g., version 1.0.1), run the following commands in your terminal: +To release a new version (e.g., version 1.0.1), run the following commands in a terminal: ```Bash # 1. Tag the current commit @@ -92,8 +107,9 @@ git push origin v1.0.1 - Under Assets, you will find: - MyAntApp-Installer.dmg (for macOS) - MyAntApp-Linux.deb (for Ubuntu/Debian) + - MyAntApp-Windows.msi (for Windows) -### Pro-Tip: Changing the Version Number -When you're ready to bump the version, remember to update the version number in two places to keep everything in sync: +### Changing the Version Number +When ready to bump the version, remember to update the version number in **two** places to keep everything in sync: - The Git Tag (the v1.0.1 above). -- The app.version property at the top of your build.xml. This ensures that when the user installs the app, the OS sees the correct version number in the "About" or "Get Info" screens. +- The **app.version** property at the top of `build.xml`. This ensures that when the user installs the app, the OS sees the correct version number in the "About" or "Get Info" screens. diff --git a/build.xml b/build.xml index 964515b..0b3314d 100644 --- a/build.xml +++ b/build.xml @@ -21,6 +21,31 @@ + + + + + + + + + + + + + @@ -33,9 +58,22 @@ - + + + + + + + + + + + + + + @@ -72,31 +110,20 @@ - - - - - - - - - + + - + + + + + + + + @@ -148,4 +175,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000..740c427 Binary files /dev/null and b/icon.ico differ diff --git a/src/Main.java b/src/Main.java index 4bda850..a86c44f 100644 --- a/src/Main.java +++ b/src/Main.java @@ -2,8 +2,13 @@ /** * Main class with main method invoked on app start. + * @version 1.0.0 + * @author Dr. Jody Paul */ public class Main { + /** Private constructor to prevent instantiation of entry point class. */ + private Main() { } + /** * Invoked on start. * @param args ignored