use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class TagMojo method execute.
/**
* {@inheritDoc}
*/
public void execute() throws MojoExecutionException {
super.execute();
try {
SimpleDateFormat dateFormat = null;
String tagTimestamp = "";
String finalTag = tag;
if (addTimestamp) {
try {
getLog().info("Using timestamp pattern '" + timestampFormat + "'");
dateFormat = new SimpleDateFormat(timestampFormat);
tagTimestamp = dateFormat.format(new Date());
getLog().info("Using timestamp '" + tagTimestamp + "'");
} catch (IllegalArgumentException e) {
String msg = "The timestamp format '" + timestampFormat + "' is invalid.";
getLog().error(msg, e);
throw new MojoExecutionException(msg, e);
}
if ("end".equals(timestampPosition)) {
finalTag += timestampPrefix + tagTimestamp;
} else {
finalTag = tagTimestamp + timestampPrefix + finalTag;
}
}
ScmRepository repository = getScmRepository();
ScmProvider provider = getScmManager().getProviderByRepository(repository);
finalTag = provider.sanitizeTagName(finalTag);
getLog().info("Final Tag Name: '" + finalTag + "'");
ScmTagParameters scmTagParameters = new ScmTagParameters(message);
scmTagParameters.setRemoteTagging(remoteTagging);
TagScmResult result = provider.tag(repository, getFileSet(), finalTag, scmTagParameters);
checkResult(result);
} catch (IOException e) {
throw new MojoExecutionException("Cannot run tag command : ", e);
} catch (ScmException e) {
throw new MojoExecutionException("Cannot run tag command : ", e);
}
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class PerforceTagCommand method executeTagCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet files, String tag, ScmTagParameters scmTagParameters) throws ScmException {
PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
actualRepoLocation = PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir());
PerforceTagConsumer consumer = new PerforceTagConsumer();
createLabel(repo, files, tag, consumer, false);
if (consumer.isSuccess()) {
syncLabel(repo, files, tag, consumer);
}
if (consumer.isSuccess()) {
// Now update the label if we need to lock it
if (shouldLock()) {
consumer = new PerforceTagConsumer();
createLabel(repo, files, tag, consumer, true);
}
}
if (consumer.isSuccess()) {
// Unclear what to pass as the first arg
return new TagScmResult("p4 label -i", consumer.getTagged());
}
// Unclear what to pass as the first arg
return new TagScmResult("p4 label -i", "Tag failed", consumer.getOutput(), false);
}
Aggregations