org.apache.maven.scm.repository.ScmRepository Java Examples

The following examples show how to use org.apache.maven.scm.repository.ScmRepository. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScmSpy.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * This method extracts the simple metadata such as revision, lastCommitTimestamp of the commit/hash, author of the commit
 * from the Changelog available in the SCM repository
 * @param scmUrl - the SCM url to get the SCM connection
 * @param workingDir - the Working Copy or Directory of the SCM repo
 * @return a {@link Map<String,String>} of values extracted form the changelog, with Keys from {@link ExtraManifestKeys}
 * @throws IOException - any error that might occur while manipulating the SCM Changelog
 * @throws ScmException - other SCM related exceptions
 */
public Map<String, String> getChangeLog(String scmUrl, File workingDir) throws IOException, ScmException {
    Map<String, String> changeLogMap = new HashMap<>();
    ScmRepository scmRepository = scmManager.makeScmRepository(scmUrl);
    ChangeLogScmResult scmResult = scmManager.changeLog(new ChangeLogScmRequest(scmRepository,
        new ScmFileSet(workingDir, "*")));
    if (scmResult.isSuccess()) {
        List<ChangeSet> changeSetList = scmResult.getChangeLog().getChangeSets();
        if (changeSetList != null && !changeSetList.isEmpty()) {
            //get the latest changelog
            ChangeSet changeSet = changeSetList.get(0);
            changeLogMap.put(ExtraManifestKeys.scmType.name(), getScmType(scmUrl));
            changeLogMap.put(ExtraManifestKeys.scmRevision.name(), changeSet.getRevision());
            changeLogMap.put(ExtraManifestKeys.lastCommitTimestamp.name(),
                manifestTimestampFormat(changeSet.getDate()));
            changeLogMap.put(ExtraManifestKeys.author.name(), changeSet.getAuthor());
        }
    }

    return changeLogMap;
}
 
Example #2
Source File: GoogleFormatterMojo.java    From googleformatter-maven-plugin with Apache License 2.0 6 votes vote down vote up
private Set<File> filterUnchangedFiles(Set<File> originalFiles) throws MojoExecutionException {
  MavenProject topLevelProject = session.getTopLevelProject();
  try {
    if (topLevelProject.getScm().getConnection() == null && topLevelProject.getScm().getDeveloperConnection() == null) {
      throw new MojoExecutionException(
          "You must supply at least one of scm.connection or scm.developerConnection in your POM file if you " +
              "specify the filterModified or filter.modified option.");
    }
    String connectionUrl = MoreObjects.firstNonNull(topLevelProject.getScm().getConnection(), topLevelProject.getScm().getDeveloperConnection());
    ScmRepository repository = scmManager.makeScmRepository(connectionUrl);
    ScmFileSet scmFileSet = new ScmFileSet(topLevelProject.getBasedir());
    String basePath = topLevelProject.getBasedir().getAbsoluteFile().getPath();
    List<String> changedFiles =
        scmManager.status(repository, scmFileSet).getChangedFiles().stream()
            .map(f -> new File(basePath, f.getPath()).toString())
            .collect(Collectors.toList());

    return originalFiles.stream().filter(f -> changedFiles.contains(f.getPath())).collect(Collectors.toSet());

  } catch (ScmException e) {
    throw new MojoExecutionException(e.getMessage(), e);
  }
}
 
Example #3
Source File: ScmMojo.java    From pitest with Apache License 2.0 6 votes vote down vote up
private Set<String> findModifiedPaths() throws MojoExecutionException {
  try {
    final ScmRepository repository = this.manager
        .makeScmRepository(getSCMConnection());
    final File scmRoot = scmRoot();
    this.getLog().info("Scm root dir is " + scmRoot);

    final Set<ScmFileStatus> statusToInclude = makeStatusSet();
    final Set<String> modifiedPaths;
    if (analyseLastCommit) {
      modifiedPaths = lastCommitChanges(statusToInclude, repository, scmRoot);
    } else if (originBranch != null && destinationBranch != null) {
      modifiedPaths = changesBetweenBranchs(originBranch, destinationBranch, statusToInclude, repository, scmRoot);
    } else {
      modifiedPaths = localChanges(statusToInclude, repository, scmRoot);
    }
    return modifiedPaths;
  } catch (final ScmException e) {
    throw new MojoExecutionException("Error while querying scm", e);
  }

}
 
Example #4
Source File: ScmRenderer.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Render the access from behind a firewall section
 *
 * @param devRepository the dev repository
 */
private void renderAccessBehindFirewallSection(ScmRepository devRepository) {
    startSection(getI18nString("accessbehindfirewall.title"));

    if (devRepository != null && isScmSystem(devRepository, "svn")) {
        SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) devRepository.getProviderRepository();

        paragraph(getI18nString("accessbehindfirewall.svn.intro"));

        verbatimText("$ svn checkout " + svnRepo.getUrl() + " " + checkoutDirectoryName);
    } else if (devRepository != null && isScmSystem(devRepository, "cvs")) {
        linkPatternedText(getI18nString("accessbehindfirewall.cvs.intro"));
    } else {
        paragraph(getI18nString("accessbehindfirewall.general.intro"));
    }

    endSection();
}
 
Example #5
Source File: AbstractScmMojo.java    From buildnumber-maven-plugin with MIT License 6 votes vote down vote up
/**
 * Get info from scm.
 *
 * @param repository
 * @param fileSet
 * @return
 * @throws ScmException
 * @todo this should be rolled into org.apache.maven.scm.provider.ScmProvider and
 *       org.apache.maven.scm.provider.svn.SvnScmProvider
 */
protected InfoScmResult info( ScmRepository repository, ScmFileSet fileSet )
    throws ScmException
{
    CommandParameters commandParameters = new CommandParameters();

    // only for Git, we will make a test for shortRevisionLength parameter
    if ( GitScmProviderRepository.PROTOCOL_GIT.equals( scmManager.getProviderByRepository( repository ).getScmType() )
        && this.shortRevisionLength > 0 )
    {
        getLog().info( "ShortRevision tag detected. The value is '" + this.shortRevisionLength + "'." );
        if ( shortRevisionLength >= 0 && shortRevisionLength < 4 )
        {
            getLog().warn( "shortRevision parameter less then 4. ShortRevisionLength is relaying on 'git rev-parese --short=LENGTH' command, accordingly to Git rev-parse specification the LENGTH value is miminum 4. " );
        }
        commandParameters.setInt( CommandParameter.SCM_SHORT_REVISION_LENGTH, this.shortRevisionLength );
    }

    if ( !StringUtils.isBlank( scmTag ) && !"HEAD".equals( scmTag ) )
    {
        commandParameters.setScmVersion( CommandParameter.SCM_VERSION, new ScmTag( scmTag ) );
    }

    return scmManager.getProviderByRepository( repository ).info( repository.getProviderRepository(), fileSet,
                                                                  commandParameters );
}
 
Example #6
Source File: AbstractScmMojo.java    From buildnumber-maven-plugin with MIT License 6 votes vote down vote up
protected ScmRepository getScmRepository()
    throws ScmException
{
    ScmRepository repository = scmManager.makeScmRepository( !StringUtils.isBlank( this.scmConnectionUrl )
                    ? scmConnectionUrl : scmDeveloperConnectionUrl );

    ScmProviderRepository scmRepo = repository.getProviderRepository();

    if ( scmRepo instanceof ScmProviderRepositoryWithHost )
    {
        loadInfosFromSettings( (ScmProviderRepositoryWithHost) scmRepo );
    }

    setPasswordIfNotEmpty( scmRepo, password );

    setUserIfNotEmpty( scmRepo, username );

    return repository;
}
 
Example #7
Source File: ScmSpy.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * This method extracts the simple metadata such as revision, lastCommitTimestamp of the commit/hash, author of the commit
 * from the Changelog available in the SCM repository
 * @param scmUrl - the SCM url to get the SCM connection
 * @param workingDir - the Working Copy or Directory of the SCM repo
 * @return a {@link Map<ExtraManifestKeys,String>} of values extracted form the changelog, with Keys from {@link ExtraManifestKeys}
 * @throws IOException - any error that might occur while manipulating the SCM Changelog
 * @throws ScmException - other SCM related exceptions
 */
public Map<ExtraManifestKeys, String> getChangeLog(String scmUrl, File workingDir) throws IOException, ScmException {
    Map<ExtraManifestKeys, String> changeLogMap = new HashMap<>();
    ScmRepository scmRepository = scmManager.makeScmRepository(scmUrl);
    ChangeLogScmResult scmResult = scmManager.changeLog(new ChangeLogScmRequest(scmRepository,
        new ScmFileSet(workingDir, "*")));
    if (scmResult.isSuccess()) {
        List<ChangeSet> changeSetList = scmResult.getChangeLog().getChangeSets();
        if (changeSetList != null && !changeSetList.isEmpty()) {
            //get the latest changelog
            ChangeSet changeSet = changeSetList.get(0);
            changeLogMap.put(ExtraManifestKeys.SCM_TYPE, getScmType(scmUrl));
            changeLogMap.put(ExtraManifestKeys.SCM_REVISION, changeSet.getRevision());
            changeLogMap.put(ExtraManifestKeys.LAST_COMMIT_TIMESTAMP,
                manifestTimestampFormat(changeSet.getDate()));
            changeLogMap.put(ExtraManifestKeys.SCM_AUTHOR, changeSet.getAuthor());
        }
    }

    return changeLogMap;
}
 
Example #8
Source File: CreateMojo.java    From buildnumber-maven-plugin with MIT License 5 votes vote down vote up
public List<ScmFile> update()
    throws MojoExecutionException
{
    try
    {
        ScmRepository repository = getScmRepository();

        ScmProvider scmProvider = scmManager.getProviderByRepository( repository );

        UpdateScmResult result = scmProvider.update( repository, new ScmFileSet( scmDirectory ) );

        if ( result == null )
        {
            return Collections.emptyList();
        }

        checkResult( result );

        if ( result instanceof UpdateScmResultWithRevision )
        {
            String revision = ( (UpdateScmResultWithRevision) result ).getRevision();
            getLog().info( "Got a revision during update: " + revision );
            this.revision = revision;
        }

        return result.getUpdatedFiles();
    }
    catch ( ScmException e )
    {
        throw new MojoExecutionException( "Couldn't update project. " + e.getMessage(), e );
    }

}
 
Example #9
Source File: ScmMojoTest.java    From pitest with Apache License 2.0 5 votes vote down vote up
public void testUnknownAndDeletedClassesAreNotMutationTested()
    throws Exception {
  setupConnection();
  when(this.manager.status(any(ScmRepository.class), any(ScmFileSet.class)))
      .thenReturn(
          new StatusScmResult("", Arrays.asList(new ScmFile(
              "foo/bar/Bar.java", ScmFileStatus.DELETED), new ScmFile(
              "foo/bar/Bar.java", ScmFileStatus.UNKNOWN))));
  this.testee.execute();
  verify(this.executionStrategy, never()).execute(any(File.class),
      any(ReportOptions.class), any(PluginServices.class), anyMap());
}
 
Example #10
Source File: ScmMojoTest.java    From pitest with Apache License 2.0 5 votes vote down vote up
private void setFileWithStatus(final ScmFileStatus status)
    throws ScmException {
  when(this.manager.status(any(ScmRepository.class), any(ScmFileSet.class)))
      .thenReturn(
          new StatusScmResult("", Arrays.asList(new ScmFile(
              "foo/bar/Bar.java", status))));
}
 
Example #11
Source File: ScmMojo.java    From pitest with Apache License 2.0 5 votes vote down vote up
private Set<String> localChanges(Set<ScmFileStatus> statusToInclude, ScmRepository repository, File scmRoot) throws ScmException {
  final StatusScmResult status = this.manager.status(repository,
          new ScmFileSet(scmRoot));
  Set<String> affected = new LinkedHashSet<>();
  for (final ScmFile file : status.getChangedFiles()) {
    if (statusToInclude.contains(file.getStatus())) {
      affected.add(file.getPath());
    }
  }
  return affected;
}
 
Example #12
Source File: CreateMojo.java    From buildnumber-maven-plugin with MIT License 5 votes vote down vote up
/**
 * Get the branch info for this revision from the repository. For svn, it is in svn info.
 *
 * @return
 * @throws MojoExecutionException
 * @throws MojoExecutionException
 */
public String getScmBranch()
    throws MojoExecutionException
{
    try
    {
        ScmRepository repository = getScmRepository();
        ScmProvider provider = scmManager.getProviderByRepository( repository );
        /* git branch can be obtained directly by a command */
        if ( GitScmProviderRepository.PROTOCOL_GIT.equals( provider.getScmType() ) )
        {
            ScmFileSet fileSet = new ScmFileSet( scmDirectory );
            return GitBranchCommand.getCurrentBranch( getLogger(),
                                                      (GitScmProviderRepository) repository.getProviderRepository(),
                                                      fileSet );
        }
        else if ( provider instanceof HgScmProvider )
        {
            /* hg branch can be obtained directly by a command */
            HgOutputConsumer consumer = new HgOutputConsumer( getLogger() );
            ScmResult result = HgUtils.execute( consumer, logger, scmDirectory, new String[] { "id", "-b" } );
            checkResult( result );
            if ( StringUtils.isNotEmpty( consumer.getOutput() ) )
            {
                return consumer.getOutput();
            }
        }
    }
    catch ( ScmException e )
    {
        getLog().warn( "Cannot get the branch information from the git repository: \n" + e.getLocalizedMessage() );
    }

    return getScmBranchFromUrl();
}
 
Example #13
Source File: ScmRenderer.java    From maven-confluence-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Render the access from behind a firewall section
 *
 * @param anonymousRepository the anonymous repository
 * @param devRepository the dev repository
 */
private void renderAccessThroughProxySection(ScmRepository anonymousRepository, ScmRepository devRepository) {
    if (isScmSystem(anonymousRepository, "svn") || isScmSystem(devRepository, "svn")) {
        startSection(getI18nString("accessthroughtproxy.title"));

        paragraph(getI18nString("accessthroughtproxy.svn.intro1"));
        paragraph(getI18nString("accessthroughtproxy.svn.intro2"));
        paragraph(getI18nString("accessthroughtproxy.svn.intro3"));

        verbatimText("[global]" + SystemUtils.LINE_SEPARATOR + "http-proxy-host = your.proxy.name"
                + SystemUtils.LINE_SEPARATOR + "http-proxy-port = 3128" + SystemUtils.LINE_SEPARATOR);

        endSection();
    }
}
 
Example #14
Source File: ScmRenderer.java    From maven-confluence-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Render the anonymous access section depending the repository.
 * <p>
 * Note: ClearCase, Starteam et Perforce seems to have no anonymous access.
 * </p>
 *
 * @param anonymousRepository the anonymous repository
 */
private void renderAnonymousAccessSection(ScmRepository anonymousRepository) {
    if (isScmSystem(anonymousRepository, "clearcase") || isScmSystem(anonymousRepository, "perforce")
            || isScmSystem(anonymousRepository, "starteam") || StringUtils.isEmpty(anonymousConnection)) {
        return;
    }

    startSection(getI18nString("anonymousaccess.title"));

    if (anonymousRepository != null && isScmSystem(anonymousRepository, "cvs")) {
        CvsScmProviderRepository cvsRepo
                = (CvsScmProviderRepository) anonymousRepository.getProviderRepository();

        anonymousAccessCVS(cvsRepo);
    } else if (anonymousRepository != null && isScmSystem(anonymousRepository, "git")) {
        GitScmProviderRepository gitRepo
                = (GitScmProviderRepository) anonymousRepository.getProviderRepository();

        anonymousAccessGit(gitRepo);
    } else if (anonymousRepository != null && isScmSystem(anonymousRepository, "hg")) {
        HgScmProviderRepository hgRepo = (HgScmProviderRepository) anonymousRepository.getProviderRepository();

        anonymousAccessMercurial(hgRepo);
    } else if (anonymousRepository != null && isScmSystem(anonymousRepository, "svn")) {
        SvnScmProviderRepository svnRepo
                = (SvnScmProviderRepository) anonymousRepository.getProviderRepository();

        anonymousAccessSubversion(svnRepo);
    } else {
        paragraph(getI18nString("anonymousaccess.general.intro"));

        verbatimText(anonymousConnection.substring(4));
    }

    endSection();
}
 
Example #15
Source File: ScmRenderer.java    From maven-confluence-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Render the overview section
 *
 * @param anonymousRepository the anonymous repository
 * @param devRepository the developer repository
 */
private void renderOverviewSection(ScmRepository anonymousRepository, ScmRepository devRepository) {
    startSection(getI18nString("overview.title"));

    if (isScmSystem(anonymousRepository, "clearcase") || isScmSystem(devRepository, "clearcase")) {
        sink.paragraph();
        linkPatternedText(getI18nString("clearcase.intro"));
        sink.paragraph_();
    } else if (isScmSystem(anonymousRepository, "cvs") || isScmSystem(devRepository, "cvs")) {
        sink.paragraph();
        linkPatternedText(getI18nString("cvs.intro"));
        sink.paragraph_();
    } else if (isScmSystem(anonymousRepository, "git") || isScmSystem(devRepository, "git")) {
        sink.paragraph();
        linkPatternedText(getI18nString("git.intro"));
        sink.paragraph_();
    } else if (isScmSystem(anonymousRepository, "hg") || isScmSystem(devRepository, "hg")) {
        sink.paragraph();
        linkPatternedText(getI18nString("hg.intro"));
        sink.paragraph_();
    } else if (isScmSystem(anonymousRepository, "perforce") || isScmSystem(devRepository, "perforce")) {
        sink.paragraph();
        linkPatternedText(getI18nString("perforce.intro"));
        sink.paragraph_();
    } else if (isScmSystem(anonymousRepository, "starteam") || isScmSystem(devRepository, "starteam")) {
        sink.paragraph();
        linkPatternedText(getI18nString("starteam.intro"));
        sink.paragraph_();
    } else if (isScmSystem(anonymousRepository, "svn") || isScmSystem(devRepository, "svn")) {
        sink.paragraph();
        linkPatternedText(getI18nString("svn.intro"));
        sink.paragraph_();
    } else {
        paragraph(getI18nString("general.intro"));
    }

    endSection();
}
 
Example #16
Source File: CreateMojo.java    From buildnumber-maven-plugin with MIT License 4 votes vote down vote up
public List<ScmFile> getStatus()
    throws ScmException
{

    ScmRepository repository = getScmRepository();

    ScmProvider scmProvider = scmManager.getProviderByRepository( repository );

    StatusScmResult result = scmProvider.status( repository, new ScmFileSet( scmDirectory ) );

    if ( result == null )
    {
        return Collections.emptyList();
    }

    checkResult( result );

    return result.getChangedFiles();

}
 
Example #17
Source File: TagMasterMojo.java    From gitflow-helper-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected void execute(final GitBranchInfo gitBranchInfo) throws MojoExecutionException, MojoFailureException {
    if (project.isExecutionRoot() && (gitBranchInfo.getType().equals(GitBranchType.MASTER) || gitBranchInfo.getType().equals(GitBranchType.SUPPORT))) {
        if (gitURLExpression == null) {
            gitURLExpression = ScmUtils.resolveUrlOrExpression(project);
        }
        String gitURL = resolveExpression(gitURLExpression);
        if (!gitURL.startsWith("scm:git:")) {
            gitURL = "scm:git:" + gitURL;
        }
        getLog().debug("gitURLExpression: '" + gitURLExpression + "' resolved to: '" + gitURL + "'");
        ExpansionBuffer eb = new ExpansionBuffer(gitURL);
        if (!eb.hasMoreLegalPlaceholders()) {

            getLog().info("Tagging SCM for CI build matching branchPattern: [" + gitBranchInfo.getPattern() + "]");

            try {
                ScmRepository repository = scmManager.makeScmRepository(gitURL);
                ScmProvider provider = scmManager.getProviderByRepository(repository);

                String sanitizedTag = provider.sanitizeTagName(tag);
                getLog().info("Sanitized tag: '" + sanitizedTag + "'");

                ScmTagParameters tagParams = new ScmTagParameters("Release tag [" + sanitizedTag + "] generated by gitflow-helper-maven-plugin.");
                tagParams.setRemoteTagging(true);

                final TagScmResult tagScmResult = provider.tag(repository, new ScmFileSet(project.getBasedir()), sanitizedTag, tagParams);
                if (!tagScmResult.isSuccess()) {
                    getLog().error("Provider message:");
                    getLog().error(tagScmResult.getProviderMessage());
                    getLog().error("Command output:");
                    getLog().error(tagScmResult.getCommandOutput());

                    throw new MojoFailureException(tagScmResult.getProviderMessage() );
                }
            } catch (ScmException scme) {
                throw new MojoFailureException("Unable to tag master branch.", scme);
            }
        } else {
            throw new MojoFailureException("Unable to resolve gitURLExpression: " + gitURLExpression + ". Leaving build configuration unaltered.");
        }
    }
}
 
Example #18
Source File: ScmRenderer.java    From maven-confluence-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * Render the developer access section
 *
 * @param devRepository the dev repository
 */
private void renderDeveloperAccessSection(ScmRepository devRepository) {
    if (StringUtils.isEmpty(devConnection)) {
        return;
    }

    startSection(getI18nString("devaccess.title"));

    if (devRepository != null && isScmSystem(devRepository, "clearcase")) {
        developerAccessClearCase();
    } else if (devRepository != null && isScmSystem(devRepository, "cvs")) {
        CvsScmProviderRepository cvsRepo = (CvsScmProviderRepository) devRepository.getProviderRepository();

        developerAccessCVS(cvsRepo);
    } else if (devRepository != null && isScmSystem(devRepository, "git")) {
        GitScmProviderRepository gitRepo = (GitScmProviderRepository) devRepository.getProviderRepository();

        developerAccessGit(gitRepo);
    } else if (devRepository != null && isScmSystem(devRepository, "hg")) {
        HgScmProviderRepository hgRepo = (HgScmProviderRepository) devRepository.getProviderRepository();

        developerAccessMercurial(hgRepo);
    } else if (devRepository != null && isScmSystem(devRepository, "perforce")) {
        PerforceScmProviderRepository perforceRepo
                = (PerforceScmProviderRepository) devRepository.getProviderRepository();

        developerAccessPerforce(perforceRepo);
    } else if (devRepository != null && isScmSystem(devRepository, "starteam")) {
        StarteamScmProviderRepository starteamRepo
                = (StarteamScmProviderRepository) devRepository.getProviderRepository();

        developerAccessStarteam(starteamRepo);
    } else if (devRepository != null && isScmSystem(devRepository, "svn")) {
        SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) devRepository.getProviderRepository();

        developerAccessSubversion(svnRepo);
    } else {
        paragraph(getI18nString("devaccess.general.intro"));

        verbatimText(devConnection.substring(4));
    }

    endSection();
}
 
Example #19
Source File: ScmMojo.java    From pitest with Apache License 2.0 4 votes vote down vote up
private Set<String> lastCommitChanges(Set<ScmFileStatus> statusToInclude, ScmRepository repository, File scmRoot) throws ScmException {
  ChangeLogScmRequest scmRequest = new ChangeLogScmRequest(repository, new ScmFileSet(scmRoot));
  scmRequest.setLimit(1);
  return pathsAffectedByChange(scmRequest, statusToInclude, 1);
}
 
Example #20
Source File: ScmMojo.java    From pitest with Apache License 2.0 4 votes vote down vote up
private Set<String> changesBetweenBranchs(String origine, String destination, Set<ScmFileStatus> statusToInclude, ScmRepository repository, File scmRoot) throws ScmException {
  ChangeLogScmRequest scmRequest = new ChangeLogScmRequest(repository, new ScmFileSet(scmRoot));
  scmRequest.setScmBranch(new ScmBranch(destination + ".." + origine));
  return pathsAffectedByChange(scmRequest, statusToInclude, NO_LIMIT);
}
 
Example #21
Source File: ScmRenderer.java    From maven-confluence-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void renderBody() {
    Scm scm = model.getScm();
    if (scm == null || StringUtils.isEmpty(anonymousConnection)
            && StringUtils.isEmpty(devConnection)
            && StringUtils.isEmpty(scm.getUrl())) {
        startSection(getTitle());

        paragraph(getI18nString("noscm"));

        endSection();

        return;
    }
    
    // fix issue #141
    startSection( "Source Control Management");

    ScmRepository anonymousRepository = getScmRepository(anonymousConnection);
    ScmRepository devRepository = getScmRepository(devConnection);

    // Overview section
    renderOverviewSection(anonymousRepository, devRepository);

    // Web access section
    renderWebAccessSection(webAccessUrl);

    // Anonymous access section if needed
    renderAnonymousAccessSection(anonymousRepository);

    // Developer access section
    renderDeveloperAccessSection(devRepository);

    // Access from behind a firewall section if needed
    renderAccessBehindFirewallSection(devRepository);

    // Access through a proxy section if needed
    renderAccessThroughProxySection(anonymousRepository, devRepository);
    
    endSection();
}
 
Example #22
Source File: ScmMojoTest.java    From pitest with Apache License 2.0 4 votes vote down vote up
private void setupToReturnNoModifiedFiles() throws ScmException {
  when(this.manager.status(any(ScmRepository.class), any(ScmFileSet.class)))
      .thenReturn(new StatusScmResult("", Collections.<ScmFile> emptyList()));
}
 
Example #23
Source File: ScmRenderer.java    From maven-confluence-plugin with Apache License 2.0 3 votes vote down vote up
/**
 * Convenience method that return true is the defined
 * <code>SCM repository</code> is a known provider.
 * <p>
 * Currently, we fully support ClearCase, CVS, Git, Perforce, Mercurial,
 * Starteam and Subversion by the maven-scm-providers component.
 * </p>
 *
 * @param scmRepository a SCM repository
 * @param scmProvider a SCM provider name
 * @return true if the provider of the given SCM repository is equal to the
 * given scm provider.
 * @see
 * <a href="http://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-providers/">maven-scm-providers</a>
 */
private static boolean isScmSystem(ScmRepository scmRepository, String scmProvider) {
    if (StringUtils.isEmpty(scmProvider)) {
        return false;
    }

    if (scmRepository != null && scmProvider.equalsIgnoreCase(scmRepository.getProvider())) {
        return true;
    }

    return false;
}