|
|
@ -21,8 +21,11 @@ import java.io.FileInputStream;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Enumeration;
|
|
|
|
import java.util.Enumeration;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.maven.archiver.MavenArchiveConfiguration;
|
|
|
|
import org.apache.maven.archiver.MavenArchiveConfiguration;
|
|
|
|
import org.apache.maven.archiver.MavenArchiver;
|
|
|
|
import org.apache.maven.archiver.MavenArchiver;
|
|
|
@ -54,7 +57,8 @@ import org.sonatype.aether.resolution.ArtifactResult;
|
|
|
|
import org.sonatype.aether.util.artifact.DefaultArtifact;
|
|
|
|
import org.sonatype.aether.util.artifact.DefaultArtifact;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Abstract base of MOJOs that package executable archives.
|
|
|
|
* MOJO that can can be used to repackage existing JAR and WAR archives so that they can
|
|
|
|
|
|
|
|
* be executed from the command line using {@literal java -jar}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Phillip Webb
|
|
|
|
* @author Phillip Webb
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -65,6 +69,14 @@ public class ExecutableArchiveMojo extends AbstractMojo {
|
|
|
|
|
|
|
|
|
|
|
|
private static final String START_CLASS_ATTRIBUTE = "Start-Class";
|
|
|
|
private static final String START_CLASS_ATTRIBUTE = "Start-Class";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Map<String, ArchiveHelper> ARCHIVE_HELPERS;
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
|
|
|
Map<String, ArchiveHelper> helpers = new HashMap<String, ArchiveHelper>();
|
|
|
|
|
|
|
|
helpers.put("jar", new ExecutableJarHelper());
|
|
|
|
|
|
|
|
helpers.put("war", new ExecutableWarHelper());
|
|
|
|
|
|
|
|
ARCHIVE_HELPERS = Collections.unmodifiableMap(helpers);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Archiver used to create a JAR file.
|
|
|
|
* Archiver used to create a JAR file.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -149,10 +161,6 @@ public class ExecutableArchiveMojo extends AbstractMojo {
|
|
|
|
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
|
|
|
|
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
|
|
|
|
private RepositorySystemSession repositorySystemSession;
|
|
|
|
private RepositorySystemSession repositorySystemSession;
|
|
|
|
|
|
|
|
|
|
|
|
private ExecutableJarHelper jarHelper = new ExecutableJarHelper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ExecutableWarHelper warHelper = new ExecutableWarHelper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
|
|
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
|
|
|
File archiveFile = createArchive();
|
|
|
|
File archiveFile = createArchive();
|
|
|
@ -169,13 +177,11 @@ public class ExecutableArchiveMojo extends AbstractMojo {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ArchiveHelper getArchiveHelper() throws MojoExecutionException {
|
|
|
|
private ArchiveHelper getArchiveHelper() throws MojoExecutionException {
|
|
|
|
if (getType().equals("jar")) {
|
|
|
|
ArchiveHelper helper = ARCHIVE_HELPERS.get(getType());
|
|
|
|
return this.jarHelper;
|
|
|
|
if (helper == null) {
|
|
|
|
}
|
|
|
|
throw new MojoExecutionException("Unsupported packaging type: " + getType());
|
|
|
|
if (getType().equals("war")) {
|
|
|
|
|
|
|
|
return this.warHelper;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new MojoExecutionException("Unsupported packaging type: " + getType());
|
|
|
|
return helper;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private File createArchive() throws MojoExecutionException {
|
|
|
|
private File createArchive() throws MojoExecutionException {
|
|
|
|