net.sf.debianmaven.AbstractDebianMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of debian-maven-plugin Show documentation
Show all versions of debian-maven-plugin Show documentation
This plugin helps building DEB packages from Maven projects.
The packages can be used in DEB-based operating systems such
as Debian and Ubuntu. The plugin uses external Debian tools
to do the actual packaging.
The newest version!
package net.sf.debianmaven;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
public abstract class AbstractDebianMojo extends AbstractMojo
{
private static final String SKIP_DEB_PROPERTY = "skipDeb";
private static final String RUN_DEB_PROPERTY = "runDeb";
/**
* @parameter expression="${deb.package.name}" default-value="${project.artifactId}"
*/
protected String packageName;
/**
* @parameter expression="${deb.package.version}" default-value="${project.version}"
*/
private String packageVersion;
/**
* @parameter expression="${deb.package.revision}" default-value="1"
*/
protected String packageRevision;
/**
* @parameter expression="${deb.package.architecture}" default-value="all"
*/
protected String packageArchitecture;
/**
* @parameter expression="${deb.maintainer.name}" default-value="${project.developers[0].name}"
*/
protected String maintainerName;
/**
* @parameter expression="${deb.maintainer.email}" default-value="${project.developers[0].email}"
*/
protected String maintainerEmail;
/** @parameter default-value="${basedir}/src/deb" */
protected File sourceDir;
/** @parameter default-value="${basedir}/target" */
protected File targetDir;
/** @parameter default-value="${basedir}/target/deb" */
protected File stageDir;
/**
* @parameter expression="${deb.package.snapshotRevFile}"
* @since 1.0.5
*/
private File snapshotRevisionFile = null;
private static final DateFormat datefmt = new SimpleDateFormat("yyyyMMddHHmm");
private String snapshotRevision = null;
protected String processVersion(String version)
{
if (snapshotRevision == null)
{
Date revtime = snapshotRevisionFile != null
? new Date(snapshotRevisionFile.lastModified())
: new Date();
snapshotRevision = "+" + datefmt.format(revtime);
}
return version.replaceAll("-SNAPSHOT", snapshotRevision);
}
protected String[] processVersion(String[] versions)
{
String[] result = new String[versions.length];
for (int i=0 ; i