org.bitbucket.bradleysmithllc.module_signer_mojo.ProjectSignerMOJO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of module-signer Show documentation
Show all versions of module-signer Show documentation
Mojo for placing build information and git version info into the project artifact.
package org.bitbucket.bradleysmithllc.module_signer_mojo;
import com.sun.codemodel.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.Status;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Goal which touches a timestamp file.
*
* @goal package-meta-info
* @phase process-sources
*/
public class ProjectSignerMOJO
extends AbstractMojo
{
/**
* @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/module-signer-source/"
* @required
*/
private File srcDirectory;
/**
* @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/module-signer-resource/META-INF/services"
* @required
*/
private File rsrcDirectory;
/**
* @parameter expression="${project}" default-value="${project}"
*/
protected MavenProject mavenProject;
/**
* Helper class to assist in attaching artifacts to the project instance.
* project-helper instance, used to make addition of resources simpler.
* @component
* @required
* @readonly
*/
private MavenProjectHelper projectHelper;
/**
* @parameter expression="${etlunitFailNotClean}"
*/
protected boolean failOnNotClean;
public void execute()
throws MojoExecutionException
{
String package_ = clean(mavenProject.getGroupId()) + "." + clean(mavenProject.getArtifactId()) + ".version_" + clean(mavenProject.getVersion());
try
{
String directory = "target/generated-sources/module-signer-resource";
List includes = Collections.singletonList("**/*");
List excludes = null;
projectHelper.addResource(mavenProject, directory, includes, excludes);
JCodeModel cm = new JCodeModel();
JDefinedClass dc = cm._class(package_ + "." + "MavenProjectInstance");
dc._extends(MavenProjectImpl.class);
JMethod m = dc.constructor(0);
m.mods().setPublic();
JBlock block = m.body();
block.directStatement("// System Properties");
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy