本文整理汇总了Java中org.apache.maven.scm.ScmException类的典型用法代码示例。如果您正苦于以下问题:Java ScmException类的具体用法?Java ScmException怎么用?Java ScmException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScmException类属于org.apache.maven.scm包,在下文中一共展示了ScmException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeStatusCommand
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
throws ScmException
{
if ( getLogger().isInfoEnabled() )
{
getLogger().info( "SVN status directory: " + fileSet.getBasedir().getAbsolutePath() );
}
SvnJavaScmProviderRepository javaRepo = (SvnJavaScmProviderRepository) repo;
SvnStatusHandler handler = new SvnStatusHandler( fileSet.getBasedir() );
try
{
SvnJavaUtil.status( javaRepo.getClientManager(), fileSet.getBasedir(), true, // isRecursive
true, // isRemote
handler );
return new StatusScmResult( SvnJavaScmProvider.COMMAND_LINE, handler.getFiles() );
}
catch ( SVNException e )
{
return new StatusScmResult( SvnJavaScmProvider.COMMAND_LINE, "SVN status failed.", e.getMessage(), false );
}
}
示例2: executeBlameCommand
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
/**
* @see org.apache.maven.scm.command.blame.AbstractBlameCommand#executeBlameCommand(org.apache.maven.scm.provider.ScmProviderRepository,
* org.apache.maven.scm.ScmFileSet, java.lang.String)
*/
@Override
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory,
String filename )
throws ScmException
{
try
{
SvnJavaScmProviderRepository javaRepo = (SvnJavaScmProviderRepository) repo;
javaRepo.getClientManager();
AnnotationHandler handler = new AnnotationHandler();
SvnJavaUtil.blame( javaRepo.getClientManager(), new File( workingDirectory.getBasedir(), filename ),
handler );
return new BlameScmResult( "", handler.lines );
}
catch ( SVNException e )
{
throw new ScmException( e.getMessage(), e );
}
}
示例3: resolveBranchOrExpression
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
/**
* Given the ScmManager for the current execution cycle, and the MavenProject structure, determine if we can
* find a maven-provided manner of resolving the current git branch.
*
* @param scmManager The current maven ScmManager
* @param project The Current maven Project
* @param log A Log to write to
* @return The current git branch name, or <code>${env.GIT_BRACH}</code> if the current git branch could not be resolved.
* @throws ScmException
*/
public static String resolveBranchOrExpression(final ScmManager scmManager, final MavenProject project, final Log log) {
String connectionUrl = resolveUrlOrExpression(project, log);
// If a connectionURL other than the default expression was resolved, try to resolve the branch.
if (!StringUtils.equals(connectionUrl, DEFAULT_URL_EXPRESSION)) {
try {
ScmRepository repository = scmManager.makeScmRepository(connectionUrl);
ScmProvider provider = scmManager.getProviderByRepository(repository);
if (GitScmProviderRepository.PROTOCOL_GIT.equals(provider.getScmType())) {
ScmFileSet fileSet = new ScmFileSet(project.getBasedir());
return GitBranchCommand.getCurrentBranch(new ScmLogDispatcher(), (GitScmProviderRepository) repository.getProviderRepository(), fileSet);
} else {
log.warn("Project SCM defines a non-git SCM provider. Falling back to variable resolution.");
}
} catch (ScmException se) {
log.warn("Unable to resolve Git Branch from Project SCM definition.", se);
}
}
log.debug("Git branch unresolvable from Project SCM definition, defaulting to " + DEFAULT_BRANCH_EXPRESSION);
return DEFAULT_BRANCH_EXPRESSION;
}
示例4: getRevision
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
public String getRevision()
throws MojoExecutionException
{
try
{
return this.getScmRevision();
}
catch ( ScmException e )
{
if ( !StringUtils.isEmpty( revisionOnScmFailure ) )
{
getLog().warn( "Cannot get the revision information from the scm repository, proceeding with "
+ "revision of " + revisionOnScmFailure + " : \n" + e.getLocalizedMessage() );
return revisionOnScmFailure;
}
throw new MojoExecutionException( "Cannot get the revision information from the scm repository : \n"
+ e.getLocalizedMessage(), e );
}
}
示例5: getScmRepository
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
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;
}
示例6: checkResult
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
protected void checkResult( ScmResult result )
throws ScmException
{
if ( !result.isSuccess() )
{
// TODO: improve error handling
getLog().error( "Provider message:" );
getLog().error( result.getProviderMessage() );
getLog().error( "Command output:" );
getLog().error( result.getCommandOutput() );
throw new ScmException( "Error!" );
}
}
示例7: info
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
/**
* 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 );
}
示例8: findModifiedPaths
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
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);
}
}
示例9: pathsAffectedByChange
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
private Set<String> pathsAffectedByChange(ChangeLogScmRequest scmRequest, Set<ScmFileStatus> statusToInclude, int limit) throws ScmException {
Set<String> affected = new LinkedHashSet<>();
ChangeLogScmResult changeLogScmResult = this.manager.changeLog(scmRequest);
if (changeLogScmResult.isSuccess()) {
List<ChangeSet> changeSets = limit(changeLogScmResult.getChangeLog().getChangeSets(),limit);
for (ChangeSet change : changeSets) {
List<ChangeFile> files = change.getFiles();
for (final ChangeFile changeFile : files) {
if (statusToInclude.contains(changeFile.getAction())) {
affected.add(changeFile.getName());
}
}
}
}
return affected;
}
示例10: cloneRepository
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
public CheckOutScmResult cloneRepository(String scmUrl, String revision, String cloneTo) throws ScmException {
File buildDir = new File(cloneTo);
if (!buildDir.exists())
buildDir.mkdir();
ScmRepository repo = getScmRepository(String.format("scm:%s:%s", repositoryType.name(), scmUrl), scmManager);
return scmManager.checkOut(repo, new ScmFileSet(buildDir), new ScmTag(revision));
}
示例11: getRepositoryURL
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
protected String getRepositoryURL( File path )
throws ScmException
{
try
{
return SVNURL.fromFile( path ).getURIEncodedPath();
}
catch ( SVNException e )
{
throw new IllegalArgumentException( e.getMessage() );
}
}
示例12: remoteInfo
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
@Override
public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
return new SvnJavaRemoteInfoCommand().executeRemoteInfoCommand( repository, fileSet, parameters );
}
示例13: executeCommand
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
@Override
public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
{
boolean recursive = parameters == null ? false : parameters.getBoolean( CommandParameter.RECURSIVE );
ScmVersion scmVersion =
parameters == null ? null : parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
return executeListCommand( repository, fileSet, recursive, scmVersion );
}
示例14: executeMkdirCommand
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
/**
* @see org.apache.maven.scm.command.mkdir.AbstractMkdirCommand#executeMkdirCommand(org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, java.lang.String)
*/
@Override
protected MkdirScmResult executeMkdirCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
boolean createInLocal )
throws ScmException
{
SvnJavaScmProviderRepository javaRepo = (SvnJavaScmProviderRepository) repository;
Iterator<File> it = fileSet.getFileList().iterator();
String dirPath = it.next().getPath();
// replacing \ with / for windauze
if ( dirPath != null && Os.isFamily( Os.FAMILY_DOS ) )
{
dirPath = StringUtils.replace( dirPath, "\\", "/" );
}
String url = javaRepo.getUrl() + "/" + dirPath;
if ( createInLocal )
{
url = dirPath;
}
List<SVNURL> svnurls = new ArrayList<SVNURL>( 1 );
try
{
svnurls.add( SVNURL.parseURIEncoded( url ) );
SVNCommitInfo commitInfo =
SvnJavaUtil.mkdir( javaRepo.getClientManager(), svnurls.toArray( new SVNURL[svnurls.size()] ),
message );
ScmResult scmResult = new ScmResult( null, null, null, true );
return new MkdirScmResult( Long.toString( commitInfo.getNewRevision() ), scmResult );
}
catch ( SVNException e )
{
throw new ScmException( e.getMessage(), e );
}
}
示例15: executeAddCommand
import org.apache.maven.scm.ScmException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
boolean binary )
throws ScmException
{
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString( CommandParameter.MESSAGE, message );
return executeCommand( repository, fileSet, commandParameters );
}