Package org.apache.maven.scm.command.checkout

Examples of org.apache.maven.scm.command.checkout.CheckOutScmResult


            Commandline clClone = createCloneCommand( repository, fileSet.getBasedir(), version );

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

        GitRemoteInfoCommand gitRemoteInfoCommand = new GitRemoteInfoCommand();
        gitRemoteInfoCommand.setLogger( getLogger() );
        RemoteInfoScmResult result = gitRemoteInfoCommand.executeRemoteInfoCommand( repository, null, null );

        if ( fileSet.getBasedir().exists() && new File( fileSet.getBasedir(), ".git" ).exists()
            && result.getBranches().size() > 0 )
        {
            // git repo exists, so we must git-pull the changes
            Commandline clPull = createPullCommand( repository, fileSet.getBasedir(), version );

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

            // and now lets do the git-checkout itself
            Commandline clCheckout = createCommandLine( repository, fileSet.getBasedir(), version );

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

        // and now search for the files
        GitListConsumer listConsumer =
            new GitListConsumer( getLogger(), fileSet.getBasedir(), ScmFileStatus.CHECKED_IN );

        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 CheckOutScmResult( lastCommandLine, listConsumer.getListedFiles() );
    }
View Full Code Here


            }
        }

        checkoutDirectory.mkdirs();

        CheckOutScmResult scmResult;

        scmResult = provider.checkOut( repository, new ScmFileSet( checkoutDirectory ),
                                       new ScmTag( releaseDescriptor.getScmReleaseLabel() ) );

        if ( releaseDescriptor.isLocalCheckout() && !scmResult.isSuccess() )
        {
            // this is not beautiful but needed to indicate that the execute() method
            // should continue in the parent directory
            return null;
        }

        String scmRelativePathProjectDirectory = scmResult.getRelativePathProjectDirectory();
        if ( StringUtils.isEmpty( scmRelativePathProjectDirectory ) )
        {
            String basedir;
            try
            {
                basedir = ReleaseUtil.getCommonBasedir( reactorProjects );
            }
            catch ( IOException e )
            {
                throw new ReleaseExecutionException( "Exception occurred while calculating common basedir: "
                    + e.getMessage(), e );
            }

            String rootProjectBasedir = rootProject.getBasedir().getAbsolutePath();
            try
            {
                if ( ReleaseUtil.isSymlink( rootProject.getBasedir() ) )
                {
                    rootProjectBasedir = rootProject.getBasedir().getCanonicalPath();
                }
            }
            catch ( IOException e )
            {
                throw new ReleaseExecutionException( e.getMessage(), e );
            }
            if ( rootProjectBasedir.length() > basedir.length() )
            {
                scmRelativePathProjectDirectory = rootProjectBasedir.substring( basedir.length() + 1 );
            }
        }
        releaseDescriptor.setScmRelativePathProjectDirectory( scmRelativePathProjectDirectory );

        if ( !scmResult.isSuccess() )
        {
            result.setResultCode( ReleaseResult.ERROR );
            logError( result, scmResult.getProviderMessage() );

            throw new ReleaseScmCommandException( "Unable to checkout from SCM", scmResult );
        }

        result.setResultCode( ReleaseResult.SUCCESS );
View Full Code Here

            }
        }

        checkoutDirectory.mkdirs();

        CheckOutScmResult scmResult;

        scmResult = provider.checkOut( repository, new ScmFileSet( checkoutDirectory ),
                                       new ScmTag( releaseDescriptor.getScmReleaseLabel() ) );

        if ( releaseDescriptor.isLocalCheckout() && !scmResult.isSuccess() )
        {
            // this is not beautiful but needed to indicate that the execute() method
            // should continue in the parent directory
            return null;
        }

        String scmRelativePathProjectDirectory = scmResult.getRelativePathProjectDirectory();
        if ( StringUtils.isEmpty( scmRelativePathProjectDirectory ) )
        {
            String basedir;
            try
            {
                basedir = ReleaseUtil.getCommonBasedir( reactorProjects );
            }
            catch ( IOException e )
            {
                throw new ReleaseExecutionException( "Exception occurred while calculating common basedir: "
                    + e.getMessage(), e );
            }

            String rootProjectBasedir = rootProject.getBasedir().getAbsolutePath();
            try
            {
                if ( ReleaseUtil.isSymlink( rootProject.getBasedir() ) )
                {
                    rootProjectBasedir = rootProject.getBasedir().getCanonicalPath();
                }
            }
            catch ( IOException e )
            {
                throw new ReleaseExecutionException( e.getMessage(), e );
            }
            if ( rootProjectBasedir.length() > basedir.length() )
            {
                scmRelativePathProjectDirectory = rootProjectBasedir.substring( basedir.length() + 1 );
            }
        }
        releaseDescriptor.setScmRelativePathProjectDirectory( scmRelativePathProjectDirectory );

        if ( !scmResult.isSuccess() )
        {
            result.setResultCode( ReleaseResult.ERROR );
            logError( result, scmResult.getProviderMessage() );

            throw new ReleaseScmCommandException( "Unable to checkout from SCM", scmResult );
        }

        result.setResultCode( ReleaseResult.SUCCESS );
View Full Code Here

        catch ( IOException e )
        {
            throw new ScmException( "Error while checking out the files.", e );
        }

        return new CheckOutScmResult( null, checkedOutFiles );
    }
View Full Code Here

        phase.setMavenExecutor( mock );

        ScmProvider scmProviderMock = mock( ScmProvider.class );
        when( scmProviderMock.checkOut( isA( ScmRepository.class ),
                                        argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
                                        isA( ScmTag.class ) ) ).thenReturn( new CheckOutScmResult( "...", Collections.<ScmFile>emptyList() ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( scmProviderMock );

        // execute
View Full Code Here

        phase.setMavenExecutor( mock );

        ScmProvider scmProviderMock = mock( ScmProvider.class );
        when( scmProviderMock.checkOut( isA( ScmRepository.class ),
                                        argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
                                        isA( ScmTag.class ) ) ).thenReturn( new CheckOutScmResult( "...", Collections.<ScmFile>emptyList() ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( scmProviderMock );

        releaseDescriptor.setUseReleaseProfile( false );
View Full Code Here

        phase.setMavenExecutor( mock );

        ScmProvider scmProviderMock = mock( ScmProvider.class );
        when( scmProviderMock.checkOut( isA( ScmRepository.class ),
                                        argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
                                        isA( ScmTag.class ) ) ).thenReturn( new CheckOutScmResult( "...", Collections.<ScmFile>emptyList() ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( scmProviderMock );

        // execute
View Full Code Here

        phase.setMavenExecutor( mock );

        ScmProvider scmProviderMock = mock( ScmProvider.class );
        when( scmProviderMock.checkOut( isA( ScmRepository.class ),
                                        argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
                                        isA( ScmTag.class ) ) ).thenReturn( new CheckOutScmResult( "...", Collections.<ScmFile>emptyList() ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( scmProviderMock );

        releaseDescriptor.setUseReleaseProfile( false );
View Full Code Here

        phase.setMavenExecutor( mock );

        ScmProvider scmProviderMock = mock( ScmProvider.class );
        when( scmProviderMock.checkOut( isA( ScmRepository.class ),
                                        argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
                                        isA( ScmTag.class ) ) ).thenReturn( new CheckOutScmResult( "...", Collections.<ScmFile>emptyList() ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( scmProviderMock );

        ReleaseDescriptorStoreStub configStore = new ReleaseDescriptorStoreStub();
View Full Code Here

        ScmManager scmManager = (ScmManager) lookup( ScmManager.ROLE );
        ScmProviderStub providerStub =
            (ScmProviderStub) scmManager.getProviderByUrl( releaseDescriptor.getScmSourceUrl() );

        providerStub.setCheckOutScmResult( new CheckOutScmResult( "", "", "", false ) );

        try
        {
            releaseManager.perform( releaseDescriptor, new DefaultReleaseEnvironment(), createReactorProjects() );
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.command.checkout.CheckOutScmResult

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.