protected CheckOutScmResult executeCheckOutCommand()

in maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommand.java [45:105]


    protected CheckOutScmResult executeCheckOutCommand(
            ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow)
            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 (logger.isInfoEnabled()) {
                logger.info("Checking out '" + source.getAbsolutePath() + "' to '" + baseDestination.getAbsolutePath()
                        + "'.");
            }

            List<File> fileList;

            if (fileSet.getFileList().isEmpty()) {
                fileList = FileUtils.getFiles(source.getAbsoluteFile(), "**", null);
            } else {
                fileList = fileSet.getFileList();
            }

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

            // write metadata file
            LocalScmMetadataUtils metadataUtils = new LocalScmMetadataUtils();
            metadataUtils.writeMetadata(baseDestination, metadataUtils.buildMetadata(source));
        } catch (IOException ex) {
            throw new ScmException("Error while checking out the files.", ex);
        }

        return new LocalCheckOutScmResult(null, checkedOutFiles);
    }