Skip to content

Commit

Permalink
Removed Launch4j code. Now Maven dependencies are used.
Browse files Browse the repository at this point in the history
  • Loading branch information
taxone committed Sep 2, 2014
1 parent 618e3b6 commit 1de6646
Show file tree
Hide file tree
Showing 43 changed files with 245 additions and 5,499 deletions.
427 changes: 200 additions & 227 deletions pom.xml

Large diffs are not rendered by default.

88 changes: 45 additions & 43 deletions src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.InputStream;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.jar.JarEntry;
Expand All @@ -41,7 +40,6 @@
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
Expand All @@ -56,6 +54,10 @@
*/
public class Launch4jMojo extends AbstractMojo {

private static final String LAUNCH4J_ARTIFACT_ID = "launch4j";

private static final String LAUNCH4J_GROUP_ID = "net.sf.launch4j";

/**
* The dependencies required by the project.
*
Expand Down Expand Up @@ -108,6 +110,13 @@ public class Launch4jMojo extends AbstractMojo {
* @component
*/
private ArtifactResolver resolver;

/**
* The dependencies of this plugin.
* Used to get the Launch4j artifact version.
*
* @parameter default-value="${plugin.artifacts}" */
private java.util.List<Artifact> pluginArtifacts;

/**
* The base of the current project.
Expand Down Expand Up @@ -209,15 +218,7 @@ public class Launch4jMojo extends AbstractMojo {
*/
private String priority;

/**
* Sets the process name to the executable filename (instead of java) and uses XP-style manifests (if any).
* Using this parameter creates a launch4j-tmp directory inside the JRE,
* so don't use it if your app won't have permission to do that.
*
* @parameter default-value=false
*/
private boolean customProcName;


/**
* 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.
Expand Down Expand Up @@ -323,8 +324,7 @@ public void execute() throws MojoExecutionException {
c.setSupportUrl(supportUrl);
c.setCmdLine(cmdLine);
c.setChdir(chdir);
c.setPriority(priority);
c.setCustomProcName(customProcName);
c.setPriority(priority);
c.setStayAlive(stayAlive);
c.setManifest(manifest);
c.setIcon(icon);
Expand Down Expand Up @@ -518,36 +518,11 @@ private Artifact chooseBinaryBits() throws MojoExecutionException {
throw new MojoExecutionException("Sorry, Launch4j doesn't support the '" + os + "' OS.");
}

return factory.createArtifactWithClassifier("com.akathist.maven.plugins.launch4j", "launch4j-maven-plugin",
getMyVersion(), "jar", "workdir-" + plat);
}

/**
* All this work just to get the version of the current plugin!
* We want to download the platform-specific bundle whose version matches the plugin's version,
* so we have to figure out what version we are.
*/
private String getMyVersion() throws MojoExecutionException {
/*
getLog().info("version = " + plugin.getVersion());
return plugin.getVersion(); // plugin was set by ${plugin}, but it doesn't work: getVersion returns null!
*/
Log log = getLog();
log.debug("searching for launch4j plugin");
Iterator i = plugins.iterator();
while (i.hasNext()) {
Plugin p = (Plugin)i.next();
if (log.isDebugEnabled()) log.debug(p.getGroupId() + " ## " + p.getArtifactId() + " ## " + p.getVersion());
if ("launch4j-maven-plugin".equals(p.getArtifactId()) &&
"com.akathist.maven.plugins.launch4j".equals(p.getGroupId())) {
String v = p.getVersion();
log.debug("Found launch4j version " + v);
return v;
}
}
throw new MojoExecutionException("Launch4j isn't among this project's plugins. How can that be?");
return factory.createArtifactWithClassifier(LAUNCH4J_GROUP_ID, LAUNCH4J_ARTIFACT_ID,
getLaunch4jVersion(), "jar", "workdir-" + plat);
}


private File getBaseDir() {
return basedir;
}
Expand All @@ -567,8 +542,7 @@ private void printState() {
log.debug("supportUrl = " + supportUrl);
log.debug("cmdLine = " + cmdLine);
log.debug("chdir = " + chdir);
log.debug("priority = " + priority);
log.debug("customProcName = " + customProcName);
log.debug("priority = " + priority);
log.debug("stayAlive = " + stayAlive);
log.debug("icon = " + icon);
log.debug("objs = " + objs);
Expand Down Expand Up @@ -635,4 +609,32 @@ 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())
&& "core".equals(artifact.getClassifier()) ){

version = artifact.getVersion();
getLog().debug("Found launch4j version " + version);
break;
}
}

if(version==null){
throw new MojoExecutionException("Impossible to find which Launch4j version to use");
}

return version;
}
}
207 changes: 0 additions & 207 deletions src/main/java/net/sf/launch4j/Builder.java

This file was deleted.

Loading

0 comments on commit 1de6646

Please sign in to comment.