Package org.apache.maven.scm

Examples of org.apache.maven.scm.ScmException


                }
            }
        }
        catch ( CommandLineException e )
        {
            throw new ScmException( e.getMessage(), e );
        }

        return new LoginScmResult( cl.toString(), isSuccess ? "Login successful" : "Login failed",
                                   consumer.getOutput(), isSuccess );
    }
View Full Code Here


        {
            boolean success = workingDir.mkdirs();
            if ( !success )
            {
                String msg = "Working directory did not exist" + " and it couldn't be created: " + workingDir;
                throw new ScmException( msg );
            }
        }
        return cmd;
    }
View Full Code Here

        {
            exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, consumer );
        }
        catch ( CommandLineException ex )
        {
            throw new ScmException( "Command could not be executed: " + cmd, ex );
        }
        return exitCode;
    }
View Full Code Here

        throws ScmException
    {

        if ( tag == null || StringUtils.isEmpty( tag.trim() ) )
        {
            throw new ScmException( "tag must be specified" );
        }

        if ( !fileSet.getFileList().isEmpty() )
        {
            throw new ScmException( "This provider doesn't support tagging subsets of a directory : " + fileSet.getFileList() );
        }

        File workingDir = fileSet.getBasedir();

        // build the command
        String[] tagCmd =
            new String[]{ HgCommandConstants.TAG_CMD, HgCommandConstants.MESSAGE_OPTION, scmTagParameters.getMessage(),
                tag };

        // keep the command about in string form for reporting
        StringBuilder cmd = joinCmd( tagCmd );
        HgTagConsumer consumer = new HgTagConsumer( getLogger() );
        ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, tagCmd );
        HgScmProviderRepository repository = (HgScmProviderRepository) scmProviderRepository;
        if ( result.isSuccess() )
        {
            // now push
            // Push to parent branch if any

            if ( repository.isPushChanges() )
            {
                if ( !repository.getURI().equals( fileSet.getBasedir().getAbsolutePath() ) )
                {
                    String branchName = HgUtils.getCurrentBranchName( getLogger(), workingDir );
                    boolean differentOutgoingBranch =
                        HgUtils.differentOutgoingBranchFound( getLogger(), workingDir, branchName );

                    String[] pushCmd = new String[]{ HgCommandConstants.PUSH_CMD,
                        differentOutgoingBranch ? HgCommandConstants.REVISION_OPTION + branchName : null,
                        repository.getURI() };

                    result =
                        HgUtils.execute( new HgConsumer( getLogger() ), getLogger(), fileSet.getBasedir(), pushCmd );
                }
            }
        }
        else
        {
            throw new ScmException( "Error while executing command " + cmd.toString() );
        }

        // do an inventory to return the files tagged (all of them)
        String[] listCmd = new String[]{ HgCommandConstants.INVENTORY_CMD };
        HgListConsumer listconsumer = new HgListConsumer( getLogger() );
        result = HgUtils.execute( listconsumer, getLogger(), fileSet.getBasedir(), listCmd );
        if ( result.isSuccess() )
        {
            List<ScmFile> files = listconsumer.getFiles();
            List<ScmFile> fileList = new ArrayList<ScmFile>();
            for ( ScmFile f : files )
            {
                if ( !f.getPath().endsWith( ".hgtags" ) )
                {
                    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

        {
            String prefixStr = prefix.getCanonicalPath();
            String fileStr = file.getCanonicalPath();
            if ( !fileStr.startsWith( prefixStr ) )
            {
                throw new ScmException( prefixStr + " is not a prefix of " + fileStr );
            }
            return fileStr.substring( prefixStr.length() );
        }
        catch ( IOException e )
        {
            throw new ScmException( "IOException", e );
        }

    }
View Full Code Here

            logger.debug( "Synergy : Entering createTask method of SynergyUtil" );
        }

        if ( synopsis == null || synopsis.equals( "" ) )
        {
            throw new ScmException( "A synopsis must be specified to create a task." );
        }

        Commandline cl = SynergyCCM.createTask( synopsis, release, defaultTask, ccmAddr );

        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
View Full Code Here

            logger.debug( "Synergy : Entering start method" );
        }

        if ( username == null )
        {
            throw new ScmException( "username can't be null" );
        }

        if ( password == null )
        {
            throw new ScmException( "password can't be null" );
        }

        Commandline cl = SynergyCCM.start( username, password, role );

        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
View Full Code Here

            }
            exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr );
        }
        catch ( CommandLineException ex )
        {
            throw new ScmException( "Error while executing synergy command [" + cl.toString() + "].", ex );
        }

        if ( logger.isDebugEnabled() )
        {
            logger.debug( "Exit code :" + exitCode );
        }
        if ( stdout instanceof StringStreamConsumer )
        {
            if ( logger.isDebugEnabled() )
            {
                logger.debug( "STDOUT :" + ( (StringStreamConsumer) stdout ).getOutput() );
            }
        }
        else
        {
            if ( logger.isDebugEnabled() )
            {
                logger.debug( "STDOUT : unavailable" );
            }
        }
        if ( logger.isDebugEnabled() )
        {
            logger.debug( "STDERR :" + stderr.getOutput() );
        }

        if ( exitCode != 0 && failOnError )
        {
            if ( stdout instanceof StringStreamConsumer )
            {
                throw new ScmException( "Commandeline = " + cl.toString() + "\nSTDOUT = "
                    + ( (StringStreamConsumer) stdout ).getOutput() + "\nSTDERR = " + stderr.getOutput() + "\n" );
            }
            else
            {
                throw new ScmException( "Commandeline = " + cl.toString() + "\nSTDOUT = unavailable" + "\nSTDERR = "
                    + stderr.getOutput() + "\n" );
            }
        }

        return exitCode;
View Full Code Here

        {
            exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr, getLogger() );
        }
        catch ( CommandLineException ex )
        {
            throw new ScmException( "Error while executing command.", ex );
        }
        finally
        {
            try
            {
View Full Code Here

                                                        ScmVersion version, boolean recursive )
        throws ScmException
    {
        if ( fileSet.getFileList().size() != 0 )
        {
            throw new ScmException( "This provider doesn't support checking out subsets of a project" );
        }

        if ( getLogger().isDebugEnabled() )
        {
            getLogger().debug( "executing checkout command..." );
        }

        SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;

        if ( getLogger().isDebugEnabled() )
        {
            getLogger().debug( fileSet.toString() );
        }

        String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), null );

        File waPath;
        try
        {
            String projectSpec =
                SynergyUtil.getWorkingProject( getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr );
            if ( projectSpec != null )
            {
                if ( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "A working project already exists [" + projectSpec + "]." );
                }
                SynergyUtil.synchronize( getLogger(), projectSpec, ccmAddr );
            }
            else
            {
                SynergyUtil.checkoutProject( getLogger(), null, repo.getProjectSpec(), version,
                                             repo.getProjectPurpose(), repo.getProjectRelease(), ccmAddr );
                projectSpec =
                    SynergyUtil.getWorkingProject( getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr );
                if ( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "A new working project [" + projectSpec + "] was created." );
                }
            }
            SynergyUtil.reconfigure( getLogger(), projectSpec, ccmAddr );
            waPath = SynergyUtil.getWorkArea( getLogger(), projectSpec, ccmAddr );

        }
        finally
        {
            SynergyUtil.stop( getLogger(), ccmAddr );
        }

        File source = new File( waPath, repo.getProjectName() );

        if ( getLogger().isInfoEnabled() )
        {
            getLogger().info(
                              "We will now copy files from Synergy Work Area [" + source
                                  + "] to expected folder [" + fileSet.getBasedir() + "]" );
        }

        // Move files to the expected folder
        try
        {
            FileUtils.copyDirectoryStructure( source, fileSet.getBasedir() );
        }
        catch ( IOException e1 )
        {
            throw new ScmException( "Unable to copy directory structure", e1 );
        }

        if ( getLogger().isDebugEnabled() )
        {
            getLogger().debug( "We will list content of checkout directory." );
        }

        // We need to list files in the directory
        List<ScmFile> files = new ArrayList<ScmFile>();
        try
        {
            @SuppressWarnings( "unchecked" )
            List<File> realFiles = FileUtils.getFiles( fileSet.getBasedir(), null, "_ccmwaid.inf" );
            for ( File f : realFiles )
            {
                files.add( new ScmFile( f.getPath(), ScmFileStatus.CHECKED_OUT ) );
            }
        }
        catch ( IOException e )
        {
            throw new ScmException( "Unable to list files in checkout directory", e );
        }

        if ( getLogger().isDebugEnabled() )
        {
            getLogger().debug( "checkout command end successfully ..." );
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.ScmException

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.