Package org.apache.maven.scm.command.add

Examples of org.apache.maven.scm.command.add.AddScmResult


    {
        createFooJava( file );

        ScmRepository scmRepository = getScmRepository();
        scmRepository.getProviderRepository().setUser( username );
        AddScmResult addResult = getScmManager().add( scmRepository, new ScmFileSet( getWorkingCopy(), "**/*.java" ) );

        assertResultIsSuccess( addResult );

        CheckInScmResult result =
            getScmManager().checkIn( scmRepository, new ScmFileSet( getWorkingCopy(), "**/Foo.java" ), "Commit message" );
View Full Code Here


                {
                    getLogger().info( "added file: " + scmFile );
                }
            }

            return new AddScmResult( "JGit add", addedFiles );

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

            MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
            ScmFileSet scmFileSet = new ScmFileSet( rootProject.getFile().getParentFile(), releasePoms );

            try
            {
                AddScmResult scmResult = scmProvider.add( scmRepository, scmFileSet );

                if ( !scmResult.isSuccess() )
                {
                    throw new ReleaseScmCommandException( "Cannot add release POM to SCM", scmResult );
                }
            }
            catch ( ScmException exception )
View Full Code Here

        File scmFile = new File( basedir, scmFilePath );

        if ( scmFilePath.length() != 0 )
        {
            AddScmResult result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );

            /*
             * TODO dirty fix to work around files with property svn:eol-style=native if a file has that property, first
             * time file is added it fails, second time it succeeds the solution is check if the scm provider is svn and
             * unset that property when the SCM API allows it
             */
            if ( !result.isSuccess() )
            {
                result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );
            }

            addedFiles = result.getAddedFiles().size();
        }

        String reservedScmFile = scmProvider.getScmSpecificFilename();

        if ( scmFile.isDirectory() )
View Full Code Here

        int addedFiles = 0;

        File scmFile = new File(basedir, scmFilePath);

        if (scmFilePath.length() != 0) {
            AddScmResult result = scmProvider.add(scmRepository, new ScmFileSet(basedir, new File(scmFilePath)));

            /*
             * TODO dirty fix to work around files with property svn:eol-style=native if a file has that property, first
             * time file is added it fails, second time it succeeds the solution is check if the scm provider is svn and
             * unset that property when the SCM API allows it
             */
            if (!result.isSuccess()) {
                result = scmProvider.add(scmRepository, new ScmFileSet(basedir, new File(scmFilePath)));
            }

            addedFiles = result.getAddedFiles().size();
        }

        String reservedScmFile = scmProvider.getScmSpecificFilename();

        if (scmFile.isDirectory()) {
View Full Code Here

          currentPath.append(File.separator);
        }
        File currentFile = new File(currentPath.toString());

        // Trying to add current path to the scm ...
        AddScmResult addResult = this.scmManager.add(this.scmRepository, new ScmFileSet(scmRoot, currentFile));
        // If current has not yet been synchronized, addResult.isSuccess() should be true
        if(addResult.isSuccess()){
          synchronizedFiles.addAll(refineUpdatedFilesInScmResult(addResult.getAddedFiles()));

                    if(i == pathChunks.length-1 && new File(scmRoot.getAbsolutePath()+File.separator+currentPath.toString()).isDirectory()){
                        addResult = this.scmManager.add(this.scmRepository, new ScmFileSet(scmRoot, currentPath.toString()+"/**/*"));
                        if(addResult.isSuccess()){
                            synchronizedFiles.addAll(refineUpdatedFilesInScmResult(addResult.getAddedFiles()));
                        } else {
                            LOGGER.severe("Error while adding SCM files in directory : " + addResult.getCommandOutput());
                        }
                    }
        } else {
                    // If addResult.isSuccess() is false, it isn't an error if it is related to path chunks (except for latest one) :
                    // if pathChunk is already synchronized, addResult.isSuccess() will be false.
                    Level logLevel = (i==pathChunks.length-1)?Level.SEVERE:Level.FINE;
                    LOGGER.log(logLevel, "Error while adding SCM file : " + addResult.getCommandOutput());
                }
      }
        } catch (IOException e) {
            LOGGER.throwing(ScmFileSet.class.getName(), "init<>", e);
            LOGGER.warning("[addFile] Error while creating ScmFileset : "+e.getMessage());
View Full Code Here

        List<File> addedFiles = accuRev.add( basedir, relativeFiles, message );

        if ( addedFiles != null )
        {
            List<ScmFile> resultFiles = getScmFiles( addedFiles, ScmFileStatus.ADDED );
            return new AddScmResult( accuRev.getCommandLines(), resultFiles );
        }
        else
        {
            return new AddScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
        }
    }
View Full Code Here

        String includes = Sandbox.formatFilePatterns( fileSet.getIncludes() );
        String msg = ( ( null == message || message.length() == 0 ) ? System.getProperty( "message" ) : message );
        List<ScmFile> addedFiles = siSandbox.addNonMembers( excludes, includes, msg );
        if ( siSandbox.getOverallAddSuccess() )
        {
            return new AddScmResult( "si add", addedFiles );
        }
        else
        {
            return new AddScmResult( addedFiles,
                                     new ScmResult( "si add", "There was a problem adding files to the repository", "",
                                                    false ) );
        }
    }
View Full Code Here

        JazzScmCommand command = createAddCommand( repo, fileSet );

        int status = command.execute( addConsumer, errConsumer );
        if ( status != 0 || errConsumer.hasBeenFed() )
        {
            return new AddScmResult( command.getCommandString(),
                                     "Error code for Jazz SCM add (checkin) command - " + status,
                                     errConsumer.getOutput(), false );
        }

        return new AddScmResult( command.getCommandString(), addConsumer.getFiles() );
    }
View Full Code Here

        if ( fileSet.getFileList().isEmpty() )
        {
            throw new ScmException( "You must provide at least one file/directory to add" );
        }

        AddScmResult result = executeAddFileSet( fileSet );

        if ( result != null )
        {
            return result;
        }
       
        // SCM-709: statusCommand uses repositoryRoot instead of workingDirectory, adjust it with relativeRepositoryPath
        Commandline clRevparse = GitStatusCommand.createRevparseShowToplevelCommand( fileSet );
       
        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        URI relativeRepositoryPath = null;
       
        int exitCode;

        exitCode = GitCommandLineUtils.execute( clRevparse, stdout, stderr, getLogger() );
        if ( exitCode != 0 )
        {
            // git-status returns non-zero if nothing to do
            if ( getLogger().isInfoEnabled() )
            {
                getLogger().info( "Could not resolve toplevel" );
            }
        }
        else
        {
            relativeRepositoryPath =
                GitStatusConsumer.resolveURI( stdout.getOutput().trim(), fileSet.getBasedir().toURI() );
        }

        // git-add doesn't show single files, but only summary :/
        // so we must run git-status and consume the output
        // borrow a few things from the git-status command
        Commandline clStatus = GitStatusCommand.createCommandLine( repository, fileSet );

        GitStatusConsumer statusConsumer =
            new GitStatusConsumer( getLogger(), fileSet.getBasedir(), relativeRepositoryPath );
        stderr = new CommandLineUtils.StringStreamConsumer();
        exitCode = GitCommandLineUtils.execute( clStatus, statusConsumer, stderr, getLogger() );
        if ( exitCode != 0 )
        {
            // git-status returns non-zero if nothing to do
            if ( getLogger().isInfoEnabled() )
            {
                getLogger().info( "nothing added to commit but untracked files present (use \"git add\" to track)" );
            }
        }

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

        // rewrite all detected files to now have status 'checked_in'
        for ( ScmFile scmfile : statusConsumer.getChangedFiles() )
        {
            // if a specific fileSet is given, we have to check if the file is really tracked
            for ( File f : fileSet.getFileList() )
            {
                if ( FilenameUtils.separatorsToUnix( f.getPath() ).equals( scmfile.getPath() ) )
                {
                    changedFiles.add( scmfile );
                }
            }
        }

        Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() );
        return new AddScmResult( cl.toString(), changedFiles );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.command.add.AddScmResult

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.