
org.kuali.maven.plugins.fusion.AbstractFusionMojo Maven / Gradle / Ivy
/**
*
*/
package org.kuali.maven.plugins.fusion;
import java.io.File;
import java.util.List;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.eclipse.jgit.lib.Constants;
import org.kuali.student.svn.model.ExternalModuleInfo;
/**
* @author ocleirig
*
*/
public abstract class AbstractFusionMojo extends AbstractMojo {
/**
* The Maven project object
*
*/
@Component
protected MavenProject project;
/**
* These mappings connect the svn:externals definitions with a property inside the root pom that controls what version each external is
* set to
*
* @parameter
*/
@Parameter
protected List mappings;
/**
* The property where the current build number is stored. Jenkins automatically sets an environment variable called
* BUILD_NUMBER
each time a job is run
*
*/
@Parameter(property=FusionMavenPluginConstants.FUSION_BUILD_NUMBER, defaultValue=FusionMavenPluginConstants.FUSION_BUILD_NUMBER_DEFAULT)
protected String buildNumberProperty;
/**
* Certain operations are slow for JGit so this allows us to run them using C git.
*
*/
@Parameter(property=FusionMavenPluginConstants.EXTERNAL_C_GIT_COMMAND_PREFIX, defaultValue=FusionMavenPluginConstants.EXTERNAL_C_GIT_COMMAND_PREFIX_DEFAULT)
protected String externalCGitCommand;
@Parameter(property = FusionMavenPluginConstants.FUSION_AGGREGATE_BRANCH_REF_SPEC_PREFIX)
protected String aggregateBranchRefSpec = FusionMavenPluginConstants.FUSION_AGGREGATE_BRANCH_REF_SPEC_PREFIX_DEFAULT;
public List getMappings() {
return mappings;
}
public void setMappings(List mappings) {
this.mappings = mappings;
}
public MavenProject getProject() {
return project;
}
public String getBuildNumberProperty() {
return buildNumberProperty;
}
public void setBuildNumberProperty(String buildNumberProperty) {
this.buildNumberProperty = buildNumberProperty;
}
/**
*
*/
public AbstractFusionMojo() {
super();
}
/**
* Check the value of a string property in a null-safe way.
*
* @param property
* @param expectedValue
* @return false if the property is null or not the expected value.
*/
protected boolean nullSafePropertyValueCheck(String property, String expectedValue) {
if (property == null)
return false;
if (property.equals(expectedValue))
return true;
else
return false;
}
protected String getBranchName (ExternalModuleInfo external) {
if (aggregateBranchRefSpec != null) {
if (aggregateBranchRefSpec.endsWith("/"))
return aggregateBranchRefSpec + external.getBranchName();
else
return aggregateBranchRefSpec + "/" + external.getBranchName();
}
else
return external.getBranchName();
}
/**
* Default to finding the branch in refs/remotes/origin
*
* use the mapping defined refspec if defined instead.
*
* @param mapping
*
* @return the absolute refspec path to the branch.
*/
protected String getBranchName(Mapping mapping) {
String refSpec = Constants.R_REMOTES + "origin/";
if (mapping.getRefSpec() != null) {
refSpec = mapping.getRefSpec();
if (!refSpec.endsWith("/")) {
// ensure the refspec ends with a trailing slash (/)
refSpec += "/";
}
}
return refSpec + mapping.getBranchName();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy