diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 0775823..bf3239a 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,12 +1,14 @@
version: 2
updates:
-- package-ecosystem: maven
- directory: "/"
- schedule:
- interval: daily
- time: "04:00"
- open-pull-requests-limit: 10
- ignore:
- - dependency-name: org.apache.maven:maven-compat
- versions:
- - 3.8.1
+ - package-ecosystem: "maven"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ ignore:
+ - dependency-name: org.apache.maven:maven-compat
+ versions:
+ - 3.8.1
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index bd234af..4aaa819 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -15,33 +15,32 @@
name: Java CI
-on: [push, pull_request]
+on:
+ pull_request:
+ push:
+ branches:
+ - master
jobs:
build:
-
runs-on: ubuntu-latest
- continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
- java: [ 8, 11, 16 ]
- experimental: [false]
- include:
- - java: 17-ea
- experimental: true
-
+ java: [ 8, 11, 17 ]
steps:
- - uses: actions/checkout@v2.3.4
- - uses: actions/cache@v2.1.4
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@v2
- with:
- distribution: adopt
- java-version: ${{ matrix.java }}
- - name: Build with Maven
- run: mvn -V test -Ddoclint=all --file pom.xml --no-transfer-progress
+ - name: Checkout code
+ uses: actions/checkout@v3.0.2
+ - name: Set up cache
+ uses: actions/cache@v3.0.10
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+ - name: Set up JDK ${{ matrix.java }}
+ uses: actions/setup-java@v3
+ with:
+ distribution: adopt
+ java-version: ${{ matrix.java }}
+ - name: Build with Maven on Java ${{ matrix.java }}
+ run: mvn -V test -Ddoclint=all --file pom.xml --no-transfer-progress
diff --git a/README.md b/README.md
index 5379962..b95e524 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,9 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/
# Documentation
-Please check [this](src/main/resources/README.adoc) document for more detailed info on how to use the plugin. Please also check [Launch4j's Configuration file](http://launch4j.sourceforge.net/docs.html#Configuration_file) page.
+Please check [this](src/main/resources/README.adoc) document for more detailed info on how to use the plugin.
+Please also check [Launch4j's Configuration file](http://launch4j.sourceforge.net/docs.html#Configuration_file) page.
+The full list of all the parameters is available [here](src/main/resources/MOJO.md)
**NOTE**: Since version 2.0.x this plugin requires to be used with Maven 3.6.x at least.
@@ -179,3 +181,9 @@ A: Yes but you will have to install these libs to avoid problems:
- bzip2-libs.i686
See [#4](../../issues/4) for more details.
+
+Q: How can I skip execution of the plugin?
+
+A: You can either use `true` configuration option or provide `-DskipLaunch4j` property to JVM
+
+See PR [#190](../../pull/190) for more details.
diff --git a/pom.xml b/pom.xml
index 913c0cf..c4caafa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -158,6 +158,26 @@
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.9.0
+
+ false
+
+
+
+ org.apache.maven.doxia
+ doxia-core
+ 1.9.1
+
+
+ org.apache.maven.doxia
+ doxia-module-markdown
+ 1.9.1
+
+
+
@@ -215,21 +235,22 @@
index
summary
- license
+ licenses
dependencies
+ plugins
org.apache.maven.plugins
- maven-javadoc-plugin
- 3.4.1
+ maven-plugin-plugin
+ 3.6.4
org.apache.maven.plugins
- maven-surefire-report-plugin
- 2.22.2
+ maven-javadoc-plugin
+ 3.4.1
diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
index b8b0fa3..e175243 100644
--- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
+++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
@@ -18,21 +18,11 @@
*/
package com.akathist.maven.plugins.launch4j;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
+import net.sf.launch4j.Builder;
+import net.sf.launch4j.BuilderException;
+import net.sf.launch4j.config.Config;
+import net.sf.launch4j.config.ConfigPersister;
+import net.sf.launch4j.config.ConfigPersisterException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
@@ -50,20 +40,29 @@
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
-import net.sf.launch4j.Builder;
-import net.sf.launch4j.BuilderException;
-import net.sf.launch4j.config.Config;
-import net.sf.launch4j.config.ConfigPersister;
-import net.sf.launch4j.config.ConfigPersisterException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
/**
* Wraps a jar in a Windows executable.
*/
@Mojo(
- name = "launch4j",
- defaultPhase = LifecyclePhase.PACKAGE,
- requiresDependencyResolution = ResolutionScope.RUNTIME,
- threadSafe = true
+ name = "launch4j",
+ defaultPhase = LifecyclePhase.PACKAGE,
+ requiresDependencyResolution = ResolutionScope.RUNTIME,
+ threadSafe = true
)
public class Launch4jMojo extends AbstractMojo {
@@ -74,7 +73,7 @@ public class Launch4jMojo extends AbstractMojo {
/**
* Maven Session.
*/
- @Parameter (defaultValue = "${session}", required = true, readonly = true)
+ @Parameter(defaultValue = "${session}", required = true, readonly = true)
private MavenSession session;
/**
@@ -118,7 +117,7 @@ public class Launch4jMojo extends AbstractMojo {
* Used to get the Launch4j artifact version.
*/
@Parameter(defaultValue = "${plugin.artifacts}")
- private java.util.List pluginArtifacts;
+ private List pluginArtifacts;
/**
* The base of the current project.
@@ -314,6 +313,12 @@ public class Launch4jMojo extends AbstractMojo {
@Parameter(defaultValue = "false")
private boolean parallelExecution = false;
+ /**
+ * If set to true, execution of the plugin will be skipped
+ */
+ @Parameter(defaultValue = "false")
+ private boolean skip = false;
+
private File getJar() {
return new File(jar);
}
@@ -330,6 +335,11 @@ public void execute() throws MojoExecutionException {
}
private void doExecute() throws MojoExecutionException {
+ if (this.skipExecution()) {
+ getLog().debug("Skipping execution of the plugin");
+ return;
+ }
+
final File workDir = setupBuildEnvironment();
if (infile != null) {
if (infile.exists()) {
@@ -337,13 +347,13 @@ private void doExecute() throws MojoExecutionException {
if (getLog().isDebugEnabled()) {
getLog().debug("Trying to load Launch4j native configuration using file=" + infile.getAbsolutePath());
}
- // load launch4j configfile from
+ // load launch4j config file from
ConfigPersister.getInstance().load(infile);
// overwrite several properties analogous to the ANT task
// https://sourceforge.net/p/launch4j/git/ci/master/tree/src/net/sf/launch4j/ant/Launch4jTask.java#l84
- // retreive the loaded configuration for manipulation
+ // retrieve the loaded configuration for manipulation
Config c = ConfigPersister.getInstance().getConfig();
String jarDefaultValue = project.getBuild().getDirectory() + "/" + project.getBuild().getFinalName() + ".jar";
@@ -500,7 +510,7 @@ private void createParentFolder() {
* Writes a marker file to prevent unzipping more than once.
*/
private File unpackWorkDir(Artifact artifact) throws MojoExecutionException {
- Artifact localArtifact= localRepository.find(artifact);
+ Artifact localArtifact = localRepository.find(artifact);
if (localArtifact == null || localArtifact.getFile() == null) {
throw new MojoExecutionException("Cannot obtain file path to " + artifact);
}
@@ -520,7 +530,7 @@ private File unpackWorkDir(Artifact artifact) throws MojoExecutionException {
getLog().info("Platform-specific work directory already exists: " + workdir.getAbsolutePath());
} else {
// trying to use plexus-archiver here is a miserable waste of time:
- try(JarFile jf = new JarFile(platJar)){
+ try (JarFile jf = new JarFile(platJar)) {
Enumeration en = jf.entries();
while (en.hasMoreElements()) {
JarEntry je = en.nextElement();
@@ -533,8 +543,8 @@ private File unpackWorkDir(Artifact artifact) throws MojoExecutionException {
if (je.isDirectory()) {
outFile.mkdirs();
} else {
- try(InputStream in = jf.getInputStream(je)){
- try (FileOutputStream fout = new FileOutputStream(outFile)){
+ try (InputStream in = jf.getInputStream(je)) {
+ try (FileOutputStream fout = new FileOutputStream(outFile)) {
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) >= 0) {
@@ -658,7 +668,7 @@ private Artifact chooseBinaryBits() throws MojoExecutionException {
}
return factory.createArtifactWithClassifier(LAUNCH4J_GROUP_ID, LAUNCH4J_ARTIFACT_ID,
- getLaunch4jVersion(), "jar", "workdir-" + plat);
+ getLaunch4jVersion(), "jar", "workdir-" + plat);
}
private File getBaseDir() {
@@ -755,20 +765,20 @@ private void printState() {
}
/**
- * The Launch4j version used by the plugin.
+ * A version of the Launch4j used by the plugin.
* We want to download the platform-specific bundle whose version matches the Launch4j version,
* so we have to figure out what version the plugin is using.
*
- * @return
- * @throws MojoExecutionException
+ * @return version of Launch4j
+ * @throws MojoExecutionException when version is null
*/
private String getLaunch4jVersion() throws MojoExecutionException {
String version = null;
for (Artifact artifact : pluginArtifacts) {
if (LAUNCH4J_GROUP_ID.equals(artifact.getGroupId()) &&
- LAUNCH4J_ARTIFACT_ID.equals(artifact.getArtifactId())
- && "core".equals(artifact.getClassifier())) {
+ LAUNCH4J_ARTIFACT_ID.equals(artifact.getArtifactId())
+ && "core".equals(artifact.getClassifier())) {
version = artifact.getVersion();
getLog().debug("Found launch4j version " + version);
@@ -782,4 +792,16 @@ private String getLaunch4jVersion() throws MojoExecutionException {
return version;
}
+
+ /**
+ * Checks if execution of the plugin should be skipped
+ *
+ * @return true to skip execution
+ */
+ private boolean skipExecution() {
+ getLog().debug("skip = " + this.skip);
+ getLog().debug("skipLaunch4j = " + System.getProperty("skipLaunch4j"));
+ return skip || System.getProperty("skipLaunch4j") != null;
+ }
+
}
diff --git a/src/main/resources/MOJO.md b/src/main/resources/MOJO.md
new file mode 100644
index 0000000..89ff68e
--- /dev/null
+++ b/src/main/resources/MOJO.md
@@ -0,0 +1,284 @@
+# Launch4j Maven plugin – launch4j:launch4j
+
+**Description**:
+
+Wraps a jar in a Windows executable.
+
+**Attributes**:
+
+* Requires a Maven project to be executed.
+* Requires dependency resolution of artifacts in scope: `runtime`.
+* The goal is thread-safe and supports parallel builds.
+* Binds by default to the [lifecycle phase](http://maven.apache.org/ref/current/maven-core/lifecycles.html): `package`.
+
+### Parameter Details
+
+#### ****
+
+Changes to the given directory, relative to the executable, before running your jar. If set to `.` the current directory will be where the executable is. If omitted, the directory will not be changed.
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Details about the classpath your application should have. This is required if you are not wrapping a jar.
+
+* **Type**: `com.akathist.maven.plugins.launch4j.ClassPath`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Constant command line arguments to pass to your program's main method. Actual command line arguments entered by the user will appear after these.
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+If `saveConfig` is set to true, config will be written to this file
+
+* **Type**: `java.io.File`
+* **Required**: `No`
+* **Default**: `${project.build.directory}/launch4j-config.xml`
+
+* * *
+
+#### ****
+
+Whether the executable should wrap the jar or not.
+
+* **Type**: `boolean`
+* **Required**: `No`
+* **Default**: `false`
+
+* * *
+
+#### ****
+
+downloadUrl (?).
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+The title of the error popup if something goes wrong trying to run your program, like if java can't be found. If this is a console app and not a gui, then this value is used to prefix any error messages, as in ${errTitle}: ${errorMessage}.
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Whether you want a gui or console app. Valid values are "gui" and "console." If you say gui, then launch4j will run your app from javaw instead of java in order to avoid opening a DOS window. Choosing gui also enables other options like taskbar icon and a splash screen.
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+The icon to use in the taskbar. Must be in ico format.
+
+* **Type**: `java.io.File`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+The name of the Launch4j native configuration file The path, if relative, is relative to the pom.xml.
+
+* **Type**: `java.io.File`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+The jar to bundle inside the executable. The path, if relative, is relative to the pom.xml. If you don't want to wrap the jar, then this value should be the runtime path to the jar relative to the executable. You should also set dontWrapJar to true. You can only bundle a single jar. Therefore, you should either create a jar that contains your own code plus all your dependencies, or you should distribute your dependencies alongside the executable.
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+* **Default**: `${project.build.directory}/${project.build.finalName}.jar`
+
+* * *
+
+#### ****
+
+Details about the supported jres.
+
+* **Type**: `com.akathist.maven.plugins.launch4j.Jre`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Win32 libraries to include. Used for custom headers only.
+
+* **Type**: `java.util.List`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Windows manifest file (a XML file) with the same name as .exe file (myapp.exe.manifest)
+
+* **Type**: `java.io.File`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Various messages you can display.
+
+* **Type**: `com.akathist.maven.plugins.launch4j.Messages`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Object files to include. Used for custom headers only.
+
+* **Type**: `java.util.List`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+The name of the executable you want launch4j to produce. The path, if relative, is relative to the pom.xml.
+
+* **Type**: `java.io.File`
+* **Required**: `No`
+* **Default**: `${project.build.directory}/${project.artifactId}.exe`
+
+* * *
+
+#### ****
+
+If set to true, a synchronized block will be used to protect resources
+
+* **Type**: `boolean`
+* **Required**: `No`
+* **Default**: `false`
+
+* * *
+
+#### ****
+
+The dependencies of this plugin. Used to get the Launch4j artifact version.
+
+* **Type**: `java.util.List`
+* **Required**: `No`
+* **Default**: `${plugin.artifacts}`
+
+* * *
+
+#### ****
+
+Priority class of windows process. Valid values are "normal" (default), "idle" and "high".
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+* **Default**: `normal`
+
+* * *
+
+#### ****
+
+If true, when the application exits, any exit code other than 0 is considered a crash and the application will be started again.
+
+* **Type**: `boolean`
+* **Required**: `No`
+* **Default**: `false`
+
+* * *
+
+#### ****
+
+If set to true it will save final config into a XML file
+
+* **Type**: `boolean`
+* **Required**: `No`
+* **Default**: `false`
+
+* * *
+
+#### ****
+
+Details about whether to run as a single instance.
+
+* **Type**: `com.akathist.maven.plugins.launch4j.SingleInstance`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+If set to true, execution of the plugin will be skipped
+
+* **Type**: `boolean`
+* **Required**: `No`
+* **Default**: `false`
+
+* * *
+
+#### ****
+
+Details about the splash screen.
+
+* **Type**: `com.akathist.maven.plugins.launch4j.Splash`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+If true, the executable waits for the java application to finish before returning its exit code. Defaults to false for gui applications. Has no effect for console applications, which always wait.
+
+* **Type**: `boolean`
+* **Required**: `No`
+* **Default**: `false`
+
+* * *
+
+#### ****
+
+supportUrl (?).
+
+* **Type**: `java.lang.String`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Variables to set.
+
+* **Type**: `java.util.List`
+* **Required**: `No`
+
+* * *
+
+#### ****
+
+Lots of information you can attach to the windows process.
+
+* **Type**: `com.akathist.maven.plugins.launch4j.VersionInfo`
+* **Required**: `No`
diff --git a/src/site/site.xml b/src/site/site.xml
new file mode 100644
index 0000000..eb87c84
--- /dev/null
+++ b/src/site/site.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+