Search in sources :

Example 31 with TagScmResult

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);
    }
}
Also used : ScmProvider(org.apache.maven.scm.provider.ScmProvider) ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmException(org.apache.maven.scm.ScmException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ScmTagParameters(org.apache.maven.scm.ScmTagParameters) IOException(java.io.IOException) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 32 with TagScmResult

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);
}
Also used : TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository)

Aggregations

TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)32 File (java.io.File)12 ScmException (org.apache.maven.scm.ScmException)11 ArrayList (java.util.ArrayList)6 ScmFile (org.apache.maven.scm.ScmFile)6 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)6 Commandline (org.codehaus.plexus.util.cli.Commandline)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 IOException (java.io.IOException)3 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)3 AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)3 CommandParameters (org.apache.maven.scm.CommandParameters)2 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)2 ScmResult (org.apache.maven.scm.ScmResult)2 ScmTag (org.apache.maven.scm.ScmTag)2 ScmTagParameters (org.apache.maven.scm.ScmTagParameters)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 AccuRevScmProviderRepository (org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository)2 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)2 CvsTagConsumer (org.apache.maven.scm.provider.cvslib.command.tag.CvsTagConsumer)2