runtimeDependencies) {
net.sf.launch4j.config.ClassPath ret = new net.sf.launch4j.config.ClassPath();
ret.setMainClass(mainClass);
@@ -92,14 +88,13 @@ net.sf.launch4j.config.ClassPath toL4j(Set dependencies, List runtimeDependencie
// Add all runtime dependencies as we need them to run the wrapped jar
dependencies.addAll(runtimeDependencies);
- for (Object dependency : dependencies) {
- Artifact dep = (Artifact) dependency;
- if (Artifact.SCOPE_COMPILE.equals(dep.getScope()) ||
- Artifact.SCOPE_RUNTIME.equals(dep.getScope())) {
+ for (Artifact dependency : dependencies) {
+ if (Artifact.SCOPE_COMPILE.equals(dependency.getScope()) ||
+ Artifact.SCOPE_RUNTIME.equals(dependency.getScope())) {
String depFilename;
- depFilename = dep.getFile().getName();
- // System.out.println("dep = " + depFilename);
+ depFilename = dependency.getFile().getName();
+ // System.out.println("dependency = " + depFilename);
cp.add(jarLocation + depFilename);
}
}
diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java
index bc0dab6..279815c 100644
--- a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java
+++ b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java
@@ -20,6 +20,8 @@
import java.util.List;
+import org.apache.maven.plugins.annotations.Parameter;
+
/**
* Details about which jre the executable should call.
*/
@@ -79,9 +81,8 @@ public class Jre {
* Always use a private JDK runtime (fails if there is no JDK installed) |
*
*
- *
- * @parameter default-value="preferJre"
*/
+ @Parameter(defaultValue="preferJre")
String jdkPreference;
/**
@@ -120,9 +121,8 @@ public class Jre {
* Sets JVM version to use: 32 bits, 64 bits or 64/32 bits
* Possible values: 32, 64, 64/32 - it will fallback to default value if different option was used
* Default value is: 64/32
- *
- * @parameter default-value="64/32"
*/
+ @Parameter(defaultValue="64/32")
String runtimeBits;
net.sf.launch4j.config.Jre toL4j() {
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 099330d..4651804 100644
--- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
+++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
@@ -42,15 +42,17 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
/**
* Wraps a jar in a Windows executable.
- *
- * @goal launch4j
- * @phase package
- * @requiresDependencyResolution compile
*/
+@Mojo(name="launch4j",defaultPhase=LifecyclePhase.PACKAGE,requiresDependencyResolution=ResolutionScope.COMPILE)
public class Launch4jMojo extends AbstractMojo {
private static final String LAUNCH4J_ARTIFACT_ID = "launch4j";
@@ -59,71 +61,51 @@ public class Launch4jMojo extends AbstractMojo {
/**
* The dependencies required by the project.
- *
- * @parameter default-value="${project.artifacts}"
- * @required
- * @readonly
*/
- private Set dependencies;
+ @Parameter(defaultValue="${project.artifacts}",required=true,readonly=true)
+ private Set dependencies;
/**
* The user's current project.
- *
- * @parameter default-value="${project}"
- * @required
- * @readonly
*/
+ @Parameter(defaultValue="${project}",required=true,readonly=true)
private MavenProject project;
/**
* The user's plugins (including, I hope, this one).
- *
- * @parameter default-value="${project.build.plugins}"
- * @required
- * @readonly
*/
- private List plugins;
+ @Parameter(defaultValue="${project.build.plugins}",required=true,readonly=true)
+ private List plugins;
/**
* Used to look up Artifacts in the remote repository.
- *
- * @@@parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
- * @component
- * @required
- * @readonly
*/
+ @Component(role=ArtifactFactory.class)
private ArtifactFactory factory;
/**
- * The user's local repository
- *
- * @parameter default-value="${localRepository}"
- * @required
- * @readonly
+ * The user's local repository.
*/
+ @Parameter(defaultValue="${localRepository}",required=true,readonly=true)
private ArtifactRepository localRepository;
/**
* The artifact resolver used to grab the binary bits that launch4j needs.
- *
- * @component
*/
+ @Component(role=ArtifactResolver.class)
private ArtifactResolver resolver;
/**
* The dependencies of this plugin.
* Used to get the Launch4j artifact version.
- *
- * @parameter default-value="${plugin.artifacts}" */
+ */
+ @Parameter(defaultValue="${plugin.artifacts}")
private java.util.List pluginArtifacts;
/**
* The base of the current project.
- *
- * @parameter default-value="${basedir}"
- * @required
- * @readonly
*/
+ @Parameter(defaultValue="${project.basedir}",required=true,readonly=true)
private File basedir;
/**
@@ -132,18 +114,15 @@ public class Launch4jMojo extends AbstractMojo {
* 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.
- *
- * @parameter
- * @required
*/
+ @Parameter(required=true)
private String headerType;
/**
* The name of the executable you want launch4j to produce.
* The path, if relative, is relative to the pom.xml.
- *
- * @parameter default-value="${project.build.directory}/${project.artifactId}.exe"
*/
+ @Parameter(defaultValue="${project.bluid.directory}/${project.artifactId}.exe")
private File outfile;
/**
@@ -156,164 +135,142 @@ public class Launch4jMojo extends AbstractMojo {
* 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.
- *
- * @parameter default-value="${project.build.directory}/${project.build.finalName}.jar"
*/
+ @Parameter(defaultValue="${project.build.directory}/${project.build.finalName}.jar")
private String jar;
/**
* Whether the executable should wrap the jar or not.
- *
- * @parameter default-value=false
*/
+ @Parameter(defaultValue="false")
private boolean dontWrapJar;
/**
* 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}.
- *
- * @parameter
*/
+ @Parameter
private String errTitle;
/**
- * downloadUrl (?)
- *
- * @parameter
+ * downloadUrl (?).
*/
+ @Parameter
private String downloadUrl;
/**
- * supportUrl (?)
- *
- * @parameter
+ * supportUrl (?).
*/
+ @Parameter
private String supportUrl;
/**
* Constant command line arguments to pass to your program's main method.
* Actual command line arguments entered by the user will appear after these.
- *
- * @parameter
*/
+ @Parameter
private String cmdLine;
/**
* 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.
- *
- * @parameter
*/
+ @Parameter
private String chdir;
/**
* Priority class of windows process.
* Valid values are "normal" (default), "idle" and "high".
* @see MSDN: Scheduling Priorities
- *
- * @parameter default-value="normal"
*/
+ @Parameter(defaultValue="normal")
private String priority;
/**
* 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.
- *
- * @parameter default-value=false
*/
+ @Parameter(defaultValue="false")
private boolean stayAlive;
/**
* If true, when the application exits, any exit code other than 0 is considered a crash and
* the application will be started again.
- *
- * @parameter default-value=false
*/
+ @Parameter(defaultValue="false")
private boolean restartOnCrash;
/**
* The icon to use in the taskbar. Must be in ico format.
- *
- * @parameter
*/
+ @Parameter
private File icon;
/**
* Object files to include. Used for custom headers only.
- *
- * @parameter
*/
+ @Parameter
private List objs;
/**
* Win32 libraries to include. Used for custom headers only.
- *
- * @parameter
*/
+ @Parameter
private List libs;
/**
* Variables to set.
- *
- * @parameter
*/
+ @Parameter
private List vars;
/**
* Details about the supported jres.
- *
- * @parameter
- * @required
*/
+ @Parameter(required=true)
private Jre jre;
/**
* Details about the classpath your application should have.
* This is required if you are not wrapping a jar.
- *
- * @parameter
*/
+ @Parameter
private ClassPath classPath;
/**
* Details about whether to run as a single instance.
- *
- * @parameter
*/
+ @Parameter
private SingleInstance singleInstance;
/**
* Details about the splash screen.
- *
- * @parameter
*/
+ @Parameter
private Splash splash;
/**
* Lots of information you can attach to the windows process.
- *
- * @parameter
*/
+ @Parameter
private VersionInfo versionInfo;
/**
* Various messages you can display.
- *
- * @parameter
*/
+ @Parameter
private Messages messages;
- /**
- * Windows manifest file (a XML file) with the same name as .exe file (myapp.exe.manifest)
- *
- * @parameter
- */
- private File manifest;
+ /**
+ * Windows manifest file (a XML file) with the same name as .exe file (myapp.exe.manifest)
+ */
+ @Parameter
+ private File manifest;
- private File getJar() {
+ private File getJar() {
return new File(jar);
}
@@ -334,7 +291,7 @@ public void execute() throws MojoExecutionException {
c.setPriority(priority);
c.setStayAlive(stayAlive);
c.setRestartOnCrash(restartOnCrash);
- c.setManifest(manifest);
+ c.setManifest(manifest);
c.setIcon(icon);
c.setHeaderObjects(objs);
c.setLibs(libs);
@@ -404,7 +361,6 @@ private File setupBuildEnvironment() throws MojoExecutionException {
* Writes a marker file to prevent unzipping more than once.
*/
private File unpackWorkDir(Artifact a) throws MojoExecutionException {
- String version = a.getVersion();
File platJar = a.getFile();
File dest = platJar.getParentFile();
File marker = new File(dest, platJar.getName() + ".unpacked");
@@ -421,9 +377,9 @@ private File unpackWorkDir(Artifact a) throws MojoExecutionException {
try {
// trying to use plexus-archiver here is a miserable waste of time:
jf = new JarFile(platJar);
- Enumeration en = jf.entries();
+ Enumeration en = jf.entries();
while (en.hasMoreElements()) {
- JarEntry je = (JarEntry)en.nextElement();
+ JarEntry je = en.nextElement();
File outFile = new File(dest, je.getName());
File parent = outFile.getParentFile();
if (parent != null) parent.mkdirs();
@@ -622,13 +578,13 @@ private void printState() {
* The Launch4j version 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
*/
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())
@@ -639,11 +595,11 @@ private String getLaunch4jVersion() throws MojoExecutionException{
break;
}
}
-
+
if(version==null){
throw new MojoExecutionException("Impossible to find which Launch4j version to use");
}
-
+
return version;
}
}
diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Messages.java b/src/main/java/com/akathist/maven/plugins/launch4j/Messages.java
index ef1e6c2..9cb05ca 100644
--- a/src/main/java/com/akathist/maven/plugins/launch4j/Messages.java
+++ b/src/main/java/com/akathist/maven/plugins/launch4j/Messages.java
@@ -29,9 +29,9 @@ public class Messages {
String bundledJreErr;
String jreVersionErr;
-
+
String launcherErr;
-
+
String instanceAlreadyExistsMsg;
diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Splash.java b/src/main/java/com/akathist/maven/plugins/launch4j/Splash.java
index 3aa4337..5531a27 100644
--- a/src/main/java/com/akathist/maven/plugins/launch4j/Splash.java
+++ b/src/main/java/com/akathist/maven/plugins/launch4j/Splash.java
@@ -20,6 +20,8 @@
import java.io.*;
+import org.apache.maven.plugins.annotations.Parameter;
+
public class Splash {
/**
@@ -30,25 +32,22 @@ public class Splash {
/**
* If true, the splash screen will close automatically as soon as an error window or java window appears.
* If false, the splash screen will not close until {@link #timeout} sections. Defaults to true.
- *
- * @parameter default-value=true;
*/
+ @Parameter(defaultValue="true")
boolean waitForWindow;
/**
* The number of seconds to keep the splash screen open before automatically closing it.
* Defaults to 60.
- *
- * @parameter default-value=60
*/
+ @Parameter(defaultValue="60")
int timeout;
/**
* If true, an error message will appear if the app hasn't started in {@link #timeout} seconds.
* If false, the splash screen will close quietly. Defaults to true.
- *
- * @parameter default-value=true
*/
+ @Parameter(defaultValue="true")
boolean timeoutErr;
net.sf.launch4j.config.Splash toL4j() {