Search in sources :

Example 6 with ScmProviderRepository

use of org.apache.maven.scm.provider.ScmProviderRepository in project maven-plugins by apache.

the class ChangeLogReport method getScmRepository.

public ScmRepository getScmRepository() throws ScmException {
    ScmRepository repository;
    try {
        repository = manager.makeScmRepository(getConnection());
        ScmProviderRepository providerRepo = repository.getProviderRepository();
        if (!StringUtils.isEmpty(username)) {
            providerRepo.setUser(username);
        }
        if (!StringUtils.isEmpty(password)) {
            providerRepo.setPassword(password);
        }
        if (repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost) {
            ScmProviderRepositoryWithHost repo = (ScmProviderRepositoryWithHost) repository.getProviderRepository();
            loadInfosFromSettings(repo);
            if (!StringUtils.isEmpty(username)) {
                repo.setUser(username);
            }
            if (!StringUtils.isEmpty(password)) {
                repo.setPassword(password);
            }
            if (!StringUtils.isEmpty(privateKey)) {
                repo.setPrivateKey(privateKey);
            }
            if (!StringUtils.isEmpty(passphrase)) {
                repo.setPassphrase(passphrase);
            }
        }
        if (!StringUtils.isEmpty(tagBase) && repository.getProvider().equals("svn")) {
            SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository();
            svnRepo.setTagBase(tagBase);
        }
    } catch (Exception e) {
        throw new ScmException("Can't load the scm provider.", e);
    }
    return repository;
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmException(org.apache.maven.scm.ScmException) ScmProviderRepositoryWithHost(org.apache.maven.scm.provider.ScmProviderRepositoryWithHost) SvnScmProviderRepository(org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository) ScmProviderRepository(org.apache.maven.scm.provider.ScmProviderRepository) SvnScmProviderRepository(org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository) ParseException(java.text.ParseException) FileNotFoundException(java.io.FileNotFoundException) ScmException(org.apache.maven.scm.ScmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MavenReportException(org.apache.maven.reporting.MavenReportException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Example 7 with ScmProviderRepository

use of org.apache.maven.scm.provider.ScmProviderRepository in project maven-scm by apache.

the class AbstractScmMojo method getScmRepository.

public ScmRepository getScmRepository() throws ScmException {
    ScmRepository repository;
    try {
        repository = getScmManager().makeScmRepository(getConnectionUrl());
        ScmProviderRepository providerRepo = repository.getProviderRepository();
        providerRepo.setPushChanges(pushChanges);
        if (!StringUtils.isEmpty(workItem)) {
            providerRepo.setWorkItem(workItem);
        }
        if (!StringUtils.isEmpty(username)) {
            providerRepo.setUser(username);
        }
        if (!StringUtils.isEmpty(password)) {
            providerRepo.setPassword(password);
        }
        if (repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost) {
            ScmProviderRepositoryWithHost repo = (ScmProviderRepositoryWithHost) repository.getProviderRepository();
            loadInfosFromSettings(repo);
            if (!StringUtils.isEmpty(username)) {
                repo.setUser(username);
            }
            if (!StringUtils.isEmpty(password)) {
                repo.setPassword(password);
            }
            if (!StringUtils.isEmpty(privateKey)) {
                repo.setPrivateKey(privateKey);
            }
            if (!StringUtils.isEmpty(passphrase)) {
                repo.setPassphrase(passphrase);
            }
        }
        if (!StringUtils.isEmpty(tagBase) && repository.getProvider().equals("svn")) {
            SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository();
            svnRepo.setTagBase(tagBase);
        }
    } catch (ScmRepositoryException e) {
        if (!e.getValidationMessages().isEmpty()) {
            for (String message : e.getValidationMessages()) {
                getLog().error(message);
            }
        }
        throw new ScmException("Can't load the scm provider.", e);
    } catch (Exception e) {
        throw new ScmException("Can't load the scm provider.", e);
    }
    return repository;
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) ScmException(org.apache.maven.scm.ScmException) ScmProviderRepositoryWithHost(org.apache.maven.scm.provider.ScmProviderRepositoryWithHost) SvnScmProviderRepository(org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository) ScmProviderRepository(org.apache.maven.scm.provider.ScmProviderRepository) SvnScmProviderRepository(org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository) ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) SecDispatcherException(org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ScmException(org.apache.maven.scm.ScmException)

Example 8 with ScmProviderRepository

use of org.apache.maven.scm.provider.ScmProviderRepository in project maven-scm by apache.

the class AbstractScmManager method makeProviderScmRepository.

/**
 * {@inheritDoc}
 */
public ScmRepository makeProviderScmRepository(String providerType, File path) throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException {
    if (providerType == null) {
        throw new NullPointerException("The provider type cannot be null.");
    }
    ScmProvider provider = getProviderByType(providerType);
    ScmProviderRepository providerRepository = provider.makeProviderScmRepository(path);
    return new ScmRepository(providerType, providerRepository);
}
Also used : ScmProvider(org.apache.maven.scm.provider.ScmProvider) ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmProviderRepository(org.apache.maven.scm.provider.ScmProviderRepository)

Example 9 with ScmProviderRepository

use of org.apache.maven.scm.provider.ScmProviderRepository in project maven-scm by apache.

the class AbstractScmManager method makeScmRepository.

// ----------------------------------------------------------------------
// Repository
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
public ScmRepository makeScmRepository(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException {
    if (scmUrl == null) {
        throw new NullPointerException("The scm url cannot be null.");
    }
    char delimiter = ScmUrlUtils.getDelimiter(scmUrl).charAt(0);
    String providerType = ScmUrlUtils.getProvider(scmUrl);
    ScmProvider provider = getProviderByType(providerType);
    String scmSpecificUrl = cleanScmUrl(scmUrl.substring(providerType.length() + 5));
    ScmProviderRepository providerRepository = provider.makeProviderScmRepository(scmSpecificUrl, delimiter);
    return new ScmRepository(providerType, providerRepository);
}
Also used : ScmProvider(org.apache.maven.scm.provider.ScmProvider) ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmProviderRepository(org.apache.maven.scm.provider.ScmProviderRepository)

Example 10 with ScmProviderRepository

use of org.apache.maven.scm.provider.ScmProviderRepository in project maven-scm by apache.

the class BazaarChangeLogCommand method executeChangeLogCommand.

/**
 * {@inheritDoc}
 */
@Override
protected ChangeLogScmResult executeChangeLogCommand(ChangeLogScmRequest request) throws ScmException {
    final ScmVersion startVersion = request.getStartRevision();
    final ScmVersion endVersion = request.getEndRevision();
    final ScmFileSet fileSet = request.getScmFileSet();
    final String datePattern = request.getDatePattern();
    if (startVersion != null || endVersion != null) {
        final ScmProviderRepository scmProviderRepository = request.getScmRepository().getProviderRepository();
        return executeChangeLogCommand(scmProviderRepository, fileSet, startVersion, endVersion, datePattern);
    }
    return executeChangeLogCommand(fileSet, request.getStartDate(), request.getEndDate(), datePattern, request.getLimit());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmProviderRepository(org.apache.maven.scm.provider.ScmProviderRepository) ScmVersion(org.apache.maven.scm.ScmVersion)

Aggregations

ScmProviderRepository (org.apache.maven.scm.provider.ScmProviderRepository)11 ScmFileSet (org.apache.maven.scm.ScmFileSet)6 ScmProvider (org.apache.maven.scm.provider.ScmProvider)6 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 CommandParameters (org.apache.maven.scm.CommandParameters)4 InfoScmResult (org.apache.maven.scm.command.info.InfoScmResult)4 IOException (java.io.IOException)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 ScmException (org.apache.maven.scm.ScmException)2 ScmVersion (org.apache.maven.scm.ScmVersion)2 ScmProviderRepositoryWithHost (org.apache.maven.scm.provider.ScmProviderRepositoryWithHost)2 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)2 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParseException (java.text.ParseException)1 MavenReportException (org.apache.maven.reporting.MavenReportException)1 ScmRepositoryException (org.apache.maven.scm.repository.ScmRepositoryException)1 SecDispatcherException (org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException)1