Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
fvarrui committed Feb 8, 2023
2 parents 22839cd + d08cf4f commit 5bb5a85
Show file tree
Hide file tree
Showing 39 changed files with 549 additions and 209 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,24 @@ target
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
src/main/resources/windows/winrun4j-launcher.jar

# Log file
*.log

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# IntelliJ
**/.idea/
**.iml

# Eclipse
**/.settings/

# Maven
**/target/
**/*.xml.releaseBackup
/release.properties

## More
.DS_Store
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
[![Maven Central](http://img.shields.io/maven-central/v/io.github.fvarrui/javapackager)](https://search.maven.org/artifact/io.github.fvarrui/javapackager)
[![GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-%250778B9.svg)](https://www.gnu.org/licenses/gpl-3.0.html)

JavaPackager is a hybrid plugin for **Maven** and **Gradle** which provides an easy way to package Java applications in native Windows, Mac OS X or GNU/Linux executables, and generate installers for them.
JavaPackager is a hybrid plugin for **Maven** and **Gradle** which provides an easy way to package Java applications in native Windows, MacOS or GNU/Linux executables, and generate installers for them.

> SNAPSHOT version is not released to Maven Central, so you have to [install it manually](#how-to-build-and-install-the-plugin).
> SNAPSHOT version (available in `devel` branch) is not released to Maven Central, so you have to [install it manually](#how-to-build-and-install-the-plugin).
> :eyes: See [JavaPackager changes and fixes](https://github.com/fvarrui/JavaPackager/releases).
## History

It was born while teaching to my students how to build and distribute their Java apps, and after seeing that a chain of several plugins was needed to achieve this task, I decided to develop a plugin :ring: to govern them all.
It was born while teaching to my students how to build and distribute their Java apps, and after seeing that a chain of several plugins was needed to achieve this task, I decided to develop a plugin :ring: to rule them all.

## Apps packaged with JavaPackager

- [Spektar Design Lab](https://spektar.io/)
- [AstroImageJ](http://astroimagej.com/)
- [Astro Pixel Processor](https://www.astropixelprocessor.com/)
- [GistFX](https://github.com/RedmondSims/GistFX)
- [AstroImageJ](http://astroimagej.com/)
- [Spektar Design Lab](https://spektar.io/)

## How to use this plugin

Expand All @@ -30,7 +30,7 @@ Add the following `plugin` tag to your `pom.xml`:
<plugin>
<groupId>io.github.fvarrui</groupId>
<artifactId>javapackager</artifactId>
<version>1.6.7</version>
<version>{latest.version}</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -78,7 +78,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'io.github.fvarrui:javapackager:1.6.7'
classpath 'io.github.fvarrui:javapackager:{latest.version}'
}
}
Expand Down Expand Up @@ -132,8 +132,8 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
| `${name}_${version}.exe` | Setup file. | Windows | [Inno Setup](http://www.jrsoftware.org/isinfo.php) |
| `${name}_${version}.msi` | MSI installer file. | Windows | [WiX Toolset](https://wixtoolset.org/) |
| `${name}_${version}.msm` | MSI merge module file. | Windows | [WiX Toolset](https://wixtoolset.org/) |
| `${name}_${version}.dmg` | Disk image file (uses **hdiutil**). | Mac OS | |
| `${name}_${version}.pkg` | PKG installer file (uses **pkgbuild**). | Mac OS | |
| `${name}_${version}.dmg` | Disk image file (uses **hdiutil**). | MacOS | |
| `${name}_${version}.pkg` | PKG installer file (uses **pkgbuild**). | MacOS | |
| `${name}-${version}-${platform}.zip` | Zipball containing generated directory `${name}`. | All | |
| `${name}-${version}-${platform}.tar.gz` | Compressed tarball containing generated directory `${name}`. | All | |
| `assets` | Directory with all intermediate files generated by JavaPackager. | All | |
Expand All @@ -157,7 +157,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
| `customizedJre` | :x: | `true` | Generates a customized JRE, including only identified or specified modules. Otherwise, all modules will be included. |
| `description` | :x: | `${project.description}` or `${displayName}` | Project description. |
| `displayName` | :x: | `${project.name}` or `${name}` | App name to show. |
| `envPath` | :x: | | Defines PATH environment variable in GNU/Linux and Mac OS X startup scripts. |
| `envPath` | :x: | | Defines PATH environment variable in GNU/Linux and MacOS startup scripts. |
| `extra` | :x: | | Map with extra properties to be used in customized Velocity templates, accesible through `$info.extra` variable. |
| `fileAssociations` | :x: | [`FileAssociation[]`](https://github.com/fvarrui/JavaPackager/blob/master/src/main/java/io/github/fvarrui/javapackager/model/FileAssociation.java) | Associate file extensions or MIME types to the app. |
| `forceInstaller` | :x: | `false` | If `true`, skips operating system check when generating installers. |
Expand All @@ -180,7 +180,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
| `runnableJar` | :x: | | Defines your own JAR file to be bundled. If it's ommited, the plugin packages your code in a runnable JAR and bundle it with the app. |
| `scripts` | :x: | | Specify bootstrap script. **Pre and post-install scripts comming soon!** |
| `url` | :x: | | App website URL. |
| `useResourcesAsWorkingDir` | :x: | `true` | Uses app resources folder as default working directory (always `true` on Mac OS). |
| `useResourcesAsWorkingDir` | :x: | `true` | Uses app resources folder as default working directory (always `true` on MacOS). |
| `version` | :x: | `${project.version}` | App version. |
| `vmArgs` | :x: | `[]` | VM arguments. |

Expand All @@ -191,7 +191,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
| Property | Mandatory | Description |
| ------------- | --------- | ------------------------------------------------------------------- |
| `linuxConfig` | :x: | [GNU/Linux specific properties](docs/linux-specific-properties.md). |
| `macConfig` | :x: | [Mac OS X specific properties](docs/macosx-specific-properties.md). |
| `macConfig` | :x: | [MacOS specific properties](docs/macosx-specific-properties.md). |
| `winConfig` | :x: | [Windows specific properties](docs/windows-specific-properties.md). |

> :warning: Be careful when using the `platform` property if your project uses platform dependent libraries, so the libraries of the current platform will be copied, not those required for the target platform. You can solve this problem using `classifiers`.
Expand All @@ -216,7 +216,7 @@ ${assetsDir}/
├── linux/
│ └── ${name}.png # on GNU/Linux it has to be a PNG file
├── mac/
│ └── ${name}.icns # on Mac OS X it has to be a ICNS file
│ └── ${name}.icns # on MacOS it has to be a ICNS file
└── windows/
└── ${name}.ico # on Windows it has to be a ICO file
```
Expand All @@ -239,7 +239,7 @@ ${assetsDir}/
| ├── mime.xml.vtl # MIME.XML template
│ └── startup.sh.vtl # Startup script template
├── mac/
| ├── assembly.xml.vtl # maven-assembly-plugin template to generate ZIP/TGZ bundles for Mac OS X
| ├── assembly.xml.vtl # maven-assembly-plugin template to generate ZIP/TGZ bundles for MacOS
| ├── customize-dmg.applescript.vtl # DMG customization Applescript template
| ├── Info.plist.vtl # Info.plist template
│ └── startup.vtl # Startup script template
Expand All @@ -262,7 +262,7 @@ You can use [default templates](https://github.com/fvarrui/JavaPackager/tree/mas

When you build your app, all configuration details are hardcoded into the executable and cannot be changed without recreating it or hacking with a resource editor. JavaPackager introduces a feature that allows to pass additional JVM options at runtime from an `.l4j.ini` file (like [Launch4j](http://launch4j.sourceforge.net/docs.html) does, but available for all platforms in the same way). So, you can specify these options in the packager's configuration (packaging time), in INI file (runtime) or in both.

The INI file's name must correspond to `${name}.l4j.ini` and it has to be located next to the executable on Windows and GNU/Linux, and in `Resources` folder on Mac OS X.
The INI file's name must correspond to `${name}.l4j.ini` and it has to be located next to the executable on Windows and GNU/Linux, and in `Resources` folder on MacOS.

The options should be separated with spaces or new lines:

Expand Down Expand Up @@ -294,12 +294,10 @@ Execute next commands in BASH (GNU/Linux or macOS) or CMD (Windows):
1. Download source code and change to the project directory:

```bash
git clone https://github.com/fvarrui/JavaPackager.git [--branch x]
git clone https://github.com/fvarrui/JavaPackager.git [--branch devel]
cd JavaPackager
```

> where `x` is branch name (e.g. `devel`)
2. Compile, package and install the plugin in your local repository (ommit `./` on Windows):

```bash
Expand Down
34 changes: 25 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gradlePlugin {
pluginBundle {
website = 'http://github.com/fvarrui/JavaPackager'
vcsUrl = 'http://github.com/fvarrui/JavaPackager.git'
description = 'Packages Java applications as native Windows, Mac OS X or GNU/Linux executables and creates installers for them'
description = 'Packages Java applications as native Windows, MacOS or GNU/Linux executables and creates installers for them'
tags = ['java', 'packager', 'gradle-plugin', 'maven-plugin', 'native', 'installer', 'debian-packages', 'rpm-packages', 'dmg', 'maven', 'gradle', 'distribution', 'javapackager', 'linux-executables', 'deb', 'rpm', 'native-windows', 'java-applications', 'pkg', 'msi']
plugins {
javaPackagerPlugin {
Expand All @@ -46,7 +46,7 @@ dependencies {
implementation 'org.apache.maven:maven-plugin-api:3.6.0'
implementation 'org.codehaus.plexus:plexus-utils:3.1.1'
implementation 'org.twdata.maven:mojo-executor:2.3.0'
implementation 'commons-io:commons-io:2.6'
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'org.apache.commons:commons-collections4:4.1'
implementation 'org.apache.commons:commons-compress:1.21'
Expand All @@ -70,7 +70,7 @@ dependencies {
}

group = 'io.github.fvarrui'
version = '1.6.7'
version = '1.7.0'
description = 'Hybrid Maven/Gradle plugin to package Java applications as native Windows, Mac OS X or GNU/Linux executables and create installers for them'

sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -86,6 +86,11 @@ publishing {
}
}

java {
withSourcesJar()
// and/or analogously use "withJavadocJar()" to get a "javadocJar" task
}

install.repositories.mavenInstaller.pom.with {
groupId = project.group
artifactId = project.name
Expand Down Expand Up @@ -128,7 +133,7 @@ task generatePluginDescriptor(type: JavaExec, dependsOn: compileJava) {
.with {
appendNode('id', 'gradle')
appendNode('name', 'Gradle Plugin Portal')
appendNode('url', 'https://plugins.gradle.org/m2/')
appendNode('url', 'https://plugins.gradle.org/m2/')
}
asNode().appendNode('build')
.with {
Expand Down Expand Up @@ -156,18 +161,18 @@ if (project.hasProperty('release')) {
apply plugin: 'signing'
apply plugin: 'maven'

task javadocJar(type: Jar) {
task deployingJavadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar) {
task deployingSourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives javadocJar, sourcesJar
archives deployingJavadocJar, deployingSourcesJar
}

// Signature of artifacts
Expand Down Expand Up @@ -227,8 +232,8 @@ nexusStaging {

task updateUniversalJavaApplicationStub(type : Download) {
def version = '20220410.162252'
group 'Update universalJavaApplicationStub'
description 'Downloads and ovewrites compiled and scripted versions of universalJavaApplicationStub to src/main/resources/mac and overrides the existing ones.'
group 'Update assets'
description 'Downloads compiled and scripted versions of universalJavaApplicationStub to src/main/resources/mac overriding the existing ones.'
src([
"https://github.com/fvarrui/universalJavaApplicationStub/releases/download/${version}/universalJavaApplicationStub.sh",
"https://github.com/fvarrui/universalJavaApplicationStub/releases/download/${version}/universalJavaApplicationStub.x86_64",
Expand All @@ -239,3 +244,14 @@ task updateUniversalJavaApplicationStub(type : Download) {
overwrite true
}

task updateWhyJavaLauncher(type : Download) {
def version = '1.1.2'
group 'Update assets'
description 'Downloads JavaLauncher.exe to src/main/resources/windows and overwrites the existing one.'
src([
"https://github.com/AstroImageJ/Why/releases/download/${version}/JavaLauncher.exe"
])
dest file('src/main/resources/windows')
overwrite true
}

4 changes: 2 additions & 2 deletions docs/gradle/plugin-configuration-samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ task packageMyApp(dependsOn: [ 'packageMyAppForLinux', 'packageMyAppForMac', 'pa
E.g. on Windows, running `packageMyApp` task will generate next artifacts:

* `${name}_${version}-linux.tar.gz` with the GNU/Linux application including a customized JRE.
* `${name}_${version}-mac.tar.gz` with the Mac OS X application including a customized JRE.
* `${name}_${version}-mac.tar.gz` with the MacOS application including a customized JRE.
* `${name}_${version}-windows.zip` with the Windows application including a customized JRE.

As last sample is running on Windows, it's not necessary to specify a JDK when bundling for Windows (it uses current JDK by default). Otherwise, if running on GNU/Linux or Mac OS X, you have to specify a JDK for Windows.
As last sample is running on Windows, it's not necessary to specify a JDK when bundling for Windows (it uses current JDK by default). Otherwise, if running on GNU/Linux or MacOS, you have to specify a JDK for Windows.
Loading

0 comments on commit 5bb5a85

Please sign in to comment.