Package org.apache.maven.scm.provider.local.repository

Examples of org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository


    /** {@inheritDoc} */
    protected ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
                                           boolean binary )
        throws ScmException
    {
        LocalScmProviderRepository localRepo = (LocalScmProviderRepository) repository;

        List<ScmFile> fileList = new ArrayList<ScmFile>();
        for ( File file : fileSet.getFileList() )
        {
            String path = file.getPath().replace( '\\', '/' );
            localRepo.addFile( path );
            fileList.add( new ScmFile( path, ScmFileStatus.ADDED ) );
        }

        // TODO: Also, ensure it is tested from the update test
        return new AddScmResult( null, fileList );
View Full Code Here


{
    protected MkdirScmResult executeMkdirCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
                                                  boolean createInLocal )
        throws ScmException
    {
        LocalScmProviderRepository repo = (LocalScmProviderRepository) repository;
        List<ScmFile> createdDirs = new ArrayList<ScmFile>();

        // create/commit the directory directly in the repository
        if ( !createInLocal )
        {
            File file = (File) fileSet.getFileList().get( 0 );
            File modulePath = new File( repo.getRoot(), repo.getModule() );
            File dir = new File( modulePath, file.getName() );

            if ( dir.exists() )
            {
                return new MkdirScmResult( null, "Directory already exists!", "Directory already exists.", false );
            }
            else
            {
                if ( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "Creating directory in '" + modulePath.getAbsolutePath() + "'" );
                }

                FileUtils.mkdir( dir.getAbsolutePath() );
                createdDirs.add( new ScmFile( dir.getPath(), ScmFileStatus.ADDED ) );
            }
        }
        else
        {
            // add the directory, but not commit
            LocalAddCommand addCmd = new LocalAddCommand();
            addCmd.setLogger( getLogger() );

            CommandParameters parameters = new CommandParameters();
            parameters.setString( CommandParameter.MESSAGE, message );
            parameters.setString( CommandParameter.BINARY, "false" );

            String path = ( (File) fileSet.getFileList().get( 0 ) ).getPath();
            if ( repo.isFileAdded( path ) )
            {
                return new MkdirScmResult( null, "Directory already exists!", "Directory already exists.", false );
            }

            AddScmResult result = (AddScmResult) addCmd.execute( repository, fileSet, parameters );
View Full Code Here

    /** {@inheritDoc} */
    protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
                                                      ScmVersion version )
        throws ScmException
    {
        LocalScmProviderRepository repository = (LocalScmProviderRepository) repo;

        if ( version != null && StringUtils.isNotEmpty( version.getName() ) )
        {
            throw new ScmException( "The local scm doesn't support tags." );
        }

        File root = new File( repository.getRoot() );

        String module = repository.getModule();

        File source = new File( root, module );

        File baseDestination = fileSet.getBasedir();

        if ( !baseDestination.exists() )
        {
            throw new ScmException(
                "The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ")." );
        }

        if ( !root.exists() )
        {
            throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." );
        }

        if ( !source.exists() )
        {
            throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." );
        }

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

        try
        {
            // Only copy files newer than in the repo
            File repoRoot = new File( repository.getRoot(), repository.getModule() );

            List<File> files = fileSet.getFileList();

            if ( files.isEmpty() )
            {
                @SuppressWarnings( "unchecked" )
                List<File> listFiles = FileUtils.getFiles( baseDestination, "**", null, false );
              
                files = listFiles;
            }

            for ( File file : files )
            {
                String path = file.getPath().replace( '\\', '/' );
                File repoFile = new File( repoRoot, path );
                file = new File( baseDestination, path );

                ScmFileStatus status;

                if ( repoFile.exists() )
                {
                    String repoFileContents = FileUtils.fileRead( repoFile );

                    String fileContents = FileUtils.fileRead( file );

                    if ( getLogger().isDebugEnabled() )
                    {
                        getLogger().debug( "fileContents:" + fileContents );
                        getLogger().debug( "repoFileContents:" + repoFileContents );
                    }
                    if ( fileContents.equals( repoFileContents ) )
                    {
                        continue;
                    }

                    status = ScmFileStatus.CHECKED_IN;
                }
                else if ( repository.isFileAdded( path ) )
                {
                    status = ScmFileStatus.CHECKED_IN;
                }
                else
                {
View Full Code Here

        if ( version != null )
        {
            throw new ScmException( "The local scm doesn't support tags." );
        }

        LocalScmProviderRepository repository = (LocalScmProviderRepository) repo;

        File root = new File( repository.getRoot() );

        String module = repository.getModule();

        File source = new File( root, module );

        if ( !root.exists() )
        {
View Full Code Here

    protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet,
                                                          Date startDate, Date endDate, ScmBranch branch,
                                                          String datePattern )
        throws ScmException
    {
        LocalScmProviderRepository repo = (LocalScmProviderRepository) repository;

        if ( branch != null )
        {
            throw new ScmException( "The local scm doesn't support tags." );
        }

        File root = new File( repo.getRoot() );

        String module = repo.getModule();

        File source = new File( root, module );

        File baseDestination = fileSet.getBasedir();

        if ( !baseDestination.exists() )
        {
            throw new ScmException(
                "The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ")." );
        }

        if ( !root.exists() )
        {
            throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." );
        }

        if ( !source.exists() )
        {
            throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." );
        }

        List<ChangeSet> changeLogList = new ArrayList<ChangeSet>();

        try
        {
            File repoRoot = new File( repo.getRoot(), repo.getModule() );

            List<File> files = fileSet.getFileList();

            if ( files.isEmpty() )
            {
View Full Code Here

{
    /** {@inheritDoc} */
    protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version )
        throws ScmException
    {
        LocalScmProviderRepository repository = (LocalScmProviderRepository) repo;

        if ( version != null )
        {
            throw new ScmException( "The local scm doesn't support tags." );
        }

        File root = new File( repository.getRoot() );

        String module = repository.getModule();

        File source = new File( root, module );

        File baseDestination = fileSet.getBasedir();

View Full Code Here

    /** {@inheritDoc} */
    protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet,
                                                        ScmVersion version, boolean recursive )
        throws ScmException
    {
        LocalScmProviderRepository repository = (LocalScmProviderRepository) repo;

        if ( version != null )
        {
            throw new ScmException( "The local scm doesn't support tags." );
        }

        File root = new File( repository.getRoot() );

        String module = repository.getModule();

        File source = new File( root, module );

        File baseDestination = fileSet.getBasedir();

        if ( !root.exists() )
        {
            throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." );
        }

        if ( !source.exists() )
        {
            throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." );
        }

        List<ScmFile> checkedOutFiles;

        try
        {
            if ( baseDestination.exists() )
            {
                FileUtils.deleteDirectory( baseDestination );
            }

            if ( !baseDestination.mkdirs() )
            {
                throw new ScmException(
                    "Could not create destination directory '" + baseDestination.getAbsolutePath() + "'." );
            }

            if ( getLogger().isInfoEnabled() )
            {
                getLogger().info(
                                  "Checking out '" + source.getAbsolutePath() + "' to '"
                                      + baseDestination.getAbsolutePath() + "'." );
            }

            List<File> fileList;

            if ( fileSet.getFileList().isEmpty() )
            {
                @SuppressWarnings( "unchecked" )
                List<File> files = FileUtils.getFiles( source.getAbsoluteFile(), "**", null );
                fileList = files;
            }
            else
            {
                fileList = fileSet.getFileList();
            }

            checkedOutFiles = checkOut( source, baseDestination, fileList, repository.getModule() );

            // write metadata file
            LocalScmMetadataUtils metadataUtils = new LocalScmMetadataUtils( getLogger() );
            metadataUtils.writeMetadata( baseDestination, metadataUtils.buildMetadata( source ) );
        }
View Full Code Here

        if ( !moduleFile.isDirectory() )
        {
            throw new ScmRepositoryException( "The module isn't a directory." );
        }

        return new LocalScmProviderRepository( rootFile.getAbsolutePath(), module );
    }
View Full Code Here

    /** {@inheritDoc} */
    protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
                                                      ScmVersion version )
        throws ScmException
    {
        LocalScmProviderRepository repository = (LocalScmProviderRepository) repo;

        if ( version != null && StringUtils.isNotEmpty( version.getName() ) )
        {
            throw new ScmException( "The local scm doesn't support tags." );
        }

        File root = new File( repository.getRoot() );

        String module = repository.getModule();

        File source = new File( root, module );

        File baseDestination = fileSet.getBasedir();

        if ( !baseDestination.exists() )
        {
            throw new ScmException(
                "The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ")." );
        }

        if ( !root.exists() )
        {
            throw new ScmException( "The base directory doesn't exist (" + root.getAbsolutePath() + ")." );
        }

        if ( !source.exists() )
        {
            throw new ScmException( "The module directory doesn't exist (" + source.getAbsolutePath() + ")." );
        }

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

        try
        {
            // Only copy files newer than in the repo
            File repoRoot = new File( repository.getRoot(), repository.getModule() );

            List<File> files = fileSet.getFileList();

            if ( files.isEmpty() )
            {
                @SuppressWarnings( "unchecked" )
                List<File> listFiles = FileUtils.getFiles( baseDestination, "**", null, false );
              
                files = listFiles;
            }

            for ( File file : files )
            {
                String path = file.getPath().replace( '\\', '/' );
                File repoFile = new File( repoRoot, path );
                file = new File( baseDestination, path );

                ScmFileStatus status;

                if ( repoFile.exists() )
                {
                    String repoFileContents = FileUtils.fileRead( repoFile );

                    String fileContents = FileUtils.fileRead( file );

                    if ( getLogger().isDebugEnabled() )
                    {
                        getLogger().debug( "fileContents:" + fileContents );
                        getLogger().debug( "repoFileContents:" + repoFileContents );
                    }
                    if ( fileContents.equals( repoFileContents ) )
                    {
                        continue;
                    }

                    status = ScmFileStatus.CHECKED_IN;
                }
                else if ( repository.isFileAdded( path ) )
                {
                    status = ScmFileStatus.CHECKED_IN;
                }
                else
                {
View Full Code Here

    /** {@inheritDoc} */
    protected ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
                                           boolean binary )
        throws ScmException
    {
        LocalScmProviderRepository localRepo = (LocalScmProviderRepository) repository;

        List<ScmFile> fileList = new ArrayList<ScmFile>();
        for ( File file : fileSet.getFileList() )
        {
            String path = file.getPath().replace( '\\', '/' );
            localRepo.addFile( path );
            fileList.add( new ScmFile( path, ScmFileStatus.ADDED ) );
        }

        // TODO: Also, ensure it is tested from the update test
        return new AddScmResult( null, fileList );
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository

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.