com.heroku.sdk.maven.HerokuMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of heroku-maven-plugin Show documentation
Show all versions of heroku-maven-plugin Show documentation
Maven plugin for deploying applications to Heroku
package com.heroku.sdk.maven;
import com.heroku.sdk.maven.executor.ListDependencies;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public abstract class HerokuMojo extends AbstractMojo {
/**
* The current Maven session.
*
* @parameter property="session"
* @required
* @readonly
*/
protected MavenSession mavenSession;
/**
* The Maven BuildPluginManager component.
*
* @component
* @required
*/
protected BuildPluginManager pluginManager;
/**
* The project currently being build.
*
* @parameter property="project"
* @required
* @readonly
*/
protected MavenProject mavenProject;
/**
* @parameter property="project.build.directory"
* @readonly
*/
private File outputPath;
/**
* The name of the Heroku app.
*
* Command line -Dheroku.appName=...
*
* @parameter property="heroku.appName"
*/
protected String appName = null;
/**
* The major version of the JDK Heroku with run the app with.
*
* Command line -Dheroku.jdkVersion=...
*
* @parameter property="heroku.jdkVersion"
*/
protected String jdkVersion = null;
/**
* The URL of the JDK binaries Heroku will use.
*
* Command line -Dheroku.jdkUrl=...
*
* @parameter property="heroku.jdkUrl"
*/
protected String jdkUrl = null;
/**
* The Heorku runtime stack.
*
* Command line -Dheroku.stack=...
*
* @parameter property="heroku.stack"
*/
protected String stack = "cedar-14";
/**
* Configuration variables that will be set on the Heroku app.
*
* @parameter property="heroku.configVars"
*/
protected Map configVars = null;
/**
* A set of file patterns to include in the zip.
* @parameter alias="includes"
*/
protected String[] mIncludes = new String[0];
/**
* If the target directory should also be included. Defaults to true.
* @parameter
*/
protected boolean includeTarget = true;
/**
* A filename where the slug is stored at, inside the heroku-target directory
*
* @parameter property="heroku.slugFilename"
*/
protected String slugFilename = "slug.tgz";
/**
* If upload progress should be logged to debug.
*
* @parameter property="heroku.logProgress"
*/
protected boolean logProgess = false;
protected File getTargetDir() {
return outputPath;
}
protected Map getConfigVars() {
return configVars;
}
protected List getIncludes() {
List files = new ArrayList(mIncludes.length);
for (String s : mIncludes) {
if (s.contains("*")) {
String[] dirs = s.split(File.separator);
String pattern = dirs[dirs.length-1];
File basedir = new File(mavenProject.getBasedir(), s.replace(pattern, ""));
Collection listFiles = FileUtils.listFiles(basedir, new WildcardFileFilter(pattern), null);
files.addAll(listFiles);
} else {
files.add(new File(s));
}
}
return files;
}
public void setIncludes(String[] includes) {
mIncludes = includes;
}
public boolean isIncludeTarget() {
return includeTarget;
}
public void setIncludeTarget(boolean includeTarget) {
this.includeTarget = includeTarget;
}
public String getSlugFilename() {
return slugFilename;
}
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
ListDependencies.execute(this.mavenProject, this.mavenSession, this.pluginManager);
}
}