Search in sources :

Example 1 with LocalAddCommand

use of org.apache.maven.scm.provider.local.command.add.LocalAddCommand in project maven-scm by apache.

the class LocalScmProvider method add.

/**
 * {@inheritDoc}
 */
public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    LocalAddCommand command = new LocalAddCommand();
    command.setLogger(getLogger());
    return (AddScmResult) command.execute(repository, fileSet, parameters);
}
Also used : AddScmResult(org.apache.maven.scm.command.add.AddScmResult) LocalAddCommand(org.apache.maven.scm.provider.local.command.add.LocalAddCommand)

Example 2 with LocalAddCommand

use of org.apache.maven.scm.provider.local.command.add.LocalAddCommand in project maven-scm by apache.

the class LocalMkdirCommand method executeMkdirCommand.

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);
        createdDirs.addAll(result.getAddedFiles());
    }
    return new MkdirScmResult(null, createdDirs);
}
Also used : LocalScmProviderRepository(org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository) MkdirScmResult(org.apache.maven.scm.command.mkdir.MkdirScmResult) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ArrayList(java.util.ArrayList) LocalAddCommand(org.apache.maven.scm.provider.local.command.add.LocalAddCommand) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

AddScmResult (org.apache.maven.scm.command.add.AddScmResult)2 LocalAddCommand (org.apache.maven.scm.provider.local.command.add.LocalAddCommand)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 CommandParameters (org.apache.maven.scm.CommandParameters)1 ScmFile (org.apache.maven.scm.ScmFile)1 MkdirScmResult (org.apache.maven.scm.command.mkdir.MkdirScmResult)1 LocalScmProviderRepository (org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository)1