Package org.apache.maven.scm.command.tag

Examples of org.apache.maven.scm.command.tag.TagScmResult


        {
            FileUtils.fileWrite( messageFile.getAbsolutePath(), scmTagParameters.getMessage() );
        }
        catch ( IOException ex )
        {
            return new TagScmResult( null, "Error while making a temporary file for the commit message: "
                + ex.getMessage(), null, false );
        }

        try
        {
            CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
            CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

            int exitCode;

            Commandline clTag = createCommandLine( repository, fileSet.getBasedir(), tag, messageFile );

            exitCode = GitCommandLineUtils.execute( clTag, stdout, stderr, getLogger() );
            if ( exitCode != 0 )
            {
                return new TagScmResult( clTag.toString(), "The git-tag command failed.", stderr.getOutput(), false );
            }

            if( repo.isPushChanges() )
            {
                // and now push the tag to the configured upstream repository
                Commandline clPush = createPushCommandLine( repository, fileSet, tag );
   
                exitCode = GitCommandLineUtils.execute( clPush, stdout, stderr, getLogger() );
                if ( exitCode != 0 )
                {
                    return new TagScmResult( clPush.toString(), "The git-push command failed.", stderr.getOutput(), false );
                }
            }
           
            // plus search for the tagged files
            GitListConsumer listConsumer = new GitListConsumer( getLogger(), fileSet.getBasedir(), ScmFileStatus.TAGGED );

            Commandline clList = GitListCommand.createCommandLine( repository, fileSet.getBasedir() );

            exitCode = GitCommandLineUtils.execute( clList, listConsumer, stderr, getLogger() );
            if ( exitCode != 0 )
            {
                return new CheckOutScmResult( clList.toString(), "The git-ls-files command failed.",
                                              stderr.getOutput(), false );
            }

            return new TagScmResult( clTag.toString(), listConsumer.getListedFiles() );
        }
        finally
        {
            try
            {
View Full Code Here


    public void testTagCommandTest()
        throws Exception
    {
        String tag = getTagName();

        @SuppressWarnings( "deprecation" ) TagScmResult tagResult =
            getScmManager().getProviderByUrl( getScmUrl() ).tag( getScmRepository(), new ScmFileSet( getWorkingCopy() ),
                                                                 tag );

        assertResultIsSuccess( tagResult );
View Full Code Here

            {
                taggedFiles.add( new ScmFile( walk.getPathString(), ScmFileStatus.CHECKED_OUT ) );
            }
            walk.release();

            return new TagScmResult( "JGit tag", taggedFiles );
        }
        catch ( Exception e )
        {
            throw new ScmException( "JGit tag failure!", e );
        }
View Full Code Here

            FileUtils.fileWrite( messageFile.getAbsolutePath(), scmTagParameters == null ? "" : scmTagParameters
                .getMessage() );
        }
        catch ( IOException ex )
        {
            return new TagScmResult( null, "Error while making a temporary file for the commit message: "
                + ex.getMessage(), null, false );
        }

        Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag, messageFile, scmTagParameters );

        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();

        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        if ( getLogger().isInfoEnabled() )
        {
            getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) );
            getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
        }

        int exitCode;

        try
        {
            exitCode = SvnCommandLineUtils.execute( cl, stdout, stderr, getLogger() );
        }
        catch ( CommandLineException ex )
        {
            throw new ScmException( "Error while executing command.", ex );
        }
        finally
        {
            try
            {
                FileUtils.forceDelete( messageFile );
            }
            catch ( IOException ex )
            {
                // ignore
            }
        }

        if ( exitCode != 0 )
        {
            // TODO: Improve this error message
            return new TagScmResult( cl.toString(), "The svn tag command failed.", stderr.getOutput(), false );
        }

        List<ScmFile> fileList = new ArrayList<ScmFile>();

        List<File> files = null;

        try
        {
            if ( StringUtils.isNotEmpty( fileSet.getExcludes() ) )
            {
                @SuppressWarnings( "unchecked" )
                List<File> list =
                    FileUtils.getFiles( fileSet.getBasedir(),
                                        ( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**"
                                                        : fileSet.getIncludes() ), fileSet.getExcludes()
                                            + ",**/.svn/**", false );
                files = list;
            }
            else
            {
                @SuppressWarnings( "unchecked" )
                List<File> list =
                    FileUtils.getFiles( fileSet.getBasedir(),
                                        ( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**"
                                                        : fileSet.getIncludes() ), "**/.svn/**", false );
                files = list;
            }
        }
        catch ( IOException e )
        {
            throw new ScmException( "Error while executing command.", e );
        }

        for ( Iterator<File> i = files.iterator(); i.hasNext(); )
        {
            File f = i.next();

            fileList.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) );
        }

        return new TagScmResult( cl.toString(), fileList );
    }
View Full Code Here

    /** {@inheritDoc} */
    protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
                                           ScmTagParameters scmTagParameters )
        throws ScmException
    {
        return new TagScmResult( null, Collections.<ScmFile>emptyList() );
    }
View Full Code Here

    /** {@inheritDoc} */
    protected ScmResult executeTagCommand( ScmProviderRepository repository, ScmFileSet fileSet, String tagName,
                                           String message )
        throws ScmException
    {
        return new TagScmResult( null, Collections.<ScmFile>emptyList() );
    }
View Full Code Here

            taggedFiles = accuRev.statTag( snapshotName );
        }

        if ( success && taggedFiles != null )
        {
            return new TagScmResult( accuRev.getCommandLines(), getScmFiles( taggedFiles, ScmFileStatus.TAGGED ) );
        }
        else
        {
            return new TagScmResult( accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(), false );
        }
    }
View Full Code Here

                {
                    fileList.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) );
                }
            }

            return new TagScmResult( fileList, result );
        }
        else
        {
            throw new ScmException( "Error while executing command " + cmd.toString() );
        }
View Full Code Here

                                           ScmTagParameters scmTagParameters )
        throws ScmException
    {
        getLogger().info(
            "Attempting to checkpoint project associated with sandbox " + fileSet.getBasedir().getAbsolutePath() );
        TagScmResult result;
        String message = scmTagParameters.getMessage();
        IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;

        try
        {
            // First validate the checkpoint label string by evaluating the groovy script
            String chkptLabel = evalGroovyExpression( tagName );
            Project.validateTag( chkptLabel );
            String msg = ( ( null == message || message.length() == 0 ) ? System.getProperty( "message" ) : message );
            // Get information about the Project
            Project siProject = iRepo.getProject();
            // Ensure this is not a build project configuration
            if ( !siProject.isBuild() )
            {
                Response res = siProject.checkpoint( msg, chkptLabel );
                int exitCode = res.getExitCode();
                boolean success = ( exitCode == 0 ? true : false );
                WorkItem wi = res.getWorkItem( siProject.getConfigurationPath() );
                String chkpt = wi.getResult().getField( "resultant" ).getItem().getId();
                getLogger().info(
                    "Successfully checkpointed project " + siProject.getConfigurationPath() + " with label '"
                        + chkptLabel + "', new revision is " + chkpt );
                result =
                    new TagScmResult( res.getCommandString(), wi.getResult().getMessage(), "Exit Code: " + exitCode,
                                      success );
            }
            else
            {
                getLogger().error(
                    "Cannot checkpoint a build project configuration: " + siProject.getConfigurationPath() + "!" );
                result =
                    new TagScmResult( "si checkpoint", "Cannot checkpoint a build project configuration!", "", false );
            }
        }
        catch ( CompilationFailedException cfe )
        {
            getLogger().error( "Groovy Compilation Exception: " + cfe.getMessage() );
            result = new TagScmResult( "si checkpoint", cfe.getMessage(), "", false );
        }
        catch ( APIException aex )
        {
            ExceptionHandler eh = new ExceptionHandler( aex );
            getLogger().error( "MKS API Exception: " + eh.getMessage() );
            getLogger().info( eh.getCommand() + " exited with return code " + eh.getExitCode() );
            result = new TagScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
        }
        catch ( Exception e )
        {
            getLogger().error( "Failed to checkpoint project! " + e.getMessage() );
            result = new TagScmResult( "si checkpoint", e.getMessage(), "", false );
        }
        return result;
    }
View Full Code Here

            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 )
        {
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.command.tag.TagScmResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.