private Set<File> filterUnchangedFiles(Set<File> originalFiles) throws MojoExecutionException { MavenProject topLevelProject = session.getTopLevelProject(); try { 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 -> String.format("%s/%s", basePath, f.getPath())) .collect(Collectors.toList()); return originalFiles.stream() .filter(f -> changedFiles.contains(f.getPath())) .collect(Collectors.toSet()); } catch (ScmException e) { throw new MojoExecutionException(e.getMessage(), e); } }
/** {@inheritDoc} */ public List<String> validateScmUrl( String scmSpecificUrl, char delimiter ) { List<String> errorMessages = new ArrayList<String>(); String[] checkCmd = new String[]{BazaarConstants.CHECK, scmSpecificUrl}; ScmResult result; try { File tmpDir = new File( System.getProperty( "java.io.tmpdir" ) ); result = BazaarUtils.execute( tmpDir, checkCmd ); if ( !result.isSuccess() ) { errorMessages.add( result.getCommandOutput() ); errorMessages.add( result.getProviderMessage() ); } } catch ( ScmException e ) { errorMessages.add( e.getMessage() ); } return errorMessages; }
} catch (ScmException e) { if (logger.isErrorEnabled()) { logger.error(e.getMessage());
public boolean checkinFiles(File scmRoot, String commitMessage){ boolean checkinOk = false; if(!expectScmRepositoryInitiated()){ return checkinOk; } LOGGER.fine("Checking in SCM files ..."); ScmFileSet fileSet = new ScmFileSet(scmRoot); // Let's commit everything ! try { CheckInScmResult result = this.scmManager.checkIn(this.scmRepository, fileSet, commitMessage); if(!result.isSuccess()){ LOGGER.severe("[checkinFiles] Problem during SCM commit : "+result.getCommandOutput()); return checkinOk; } checkinOk = true; } catch (ScmException e) { LOGGER.throwing(ScmManager.class.getName(), "checkIn", e); LOGGER.severe("[checkinFiles] Error while checkin : "+e.getMessage()); return checkinOk; } if(checkinOk){ LOGGER.fine("Checked in SCM files !"); } return checkinOk; }
public boolean checkout(File checkoutDirectory){ boolean checkoutOk = false; if(!expectScmRepositoryInitiated()){ return checkoutOk; } // Checkouting sources LOGGER.fine("Checking out SCM files into ["+checkoutDirectory.getAbsolutePath()+"] ..."); try { CheckOutScmResult result = scmManager.checkOut(this.scmRepository, new ScmFileSet(checkoutDirectory)); if(!result.isSuccess()){ LOGGER.severe("[checkout] Error during checkout : "+result.getProviderMessage()+" || "+result.getCommandOutput()); return checkoutOk; } checkoutOk = true; } catch (ScmException e) { LOGGER.throwing(ScmManager.class.getName(), "checkOut", e); LOGGER.severe("[checkout] Error during checkout : "+e.getMessage()); return checkoutOk; } if(checkoutOk){ LOGGER.fine("Checked out SCM files into ["+checkoutDirectory.getAbsolutePath()+"] !"); } return checkoutOk; }
private synchronized boolean run(String command, String[] args) throws GitException { try { Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workDir, command); if (args != null) { for (int i = 0; i < args.length; i++) cl.createArgument().setValue(args[i]); } StringBuffer sb = new StringBuffer(); sb.append("git ").append(command); if (args != null) { for (int i = 0; i < args.length; i++) sb.append(" ").append(args[i]); } int exitCode = GitCommandLineUtils.execute(cl, stdout, stderr, log); log.debug("RAN: " + sb.toString() + " / $? = " + exitCode); return exitCode == 0; } catch (ScmException e) { throw new GitException("Couldn't run command " + command + ": " + e.getMessage(), e); } }
/** * {@inheritDoc} */ public void execute() throws MojoExecutionException { super.execute(); try { ScmRepository repository = getScmRepository(); RemoveScmResult result = getScmManager().remove( repository, getFileSet(), message ); checkResult( result ); } catch ( IOException e ) { throw new MojoExecutionException( "Cannot run remove command : " + e.getMessage(), e ); } catch ( ScmException e ) { throw new MojoExecutionException( "Cannot run remove command : " + e.getMessage(), e ); } } }
} catch (ScmException e) { LOGGER.throwing(ScmManager.class.getName(), "remove", e); LOGGER.severe("[deleteHierarchy] Hierarchy deletion aborted : "+e.getMessage()); return null;
throw new MojoExecutionException( e.getMessage(), e );
} catch (ScmException e) { if (logger.isErrorEnabled()) { logger.error(e.getMessage());
throw new TransferFailedException("Error interacting with SCM: " + e.getMessage(), e); } catch (IOException e) { fireTransferError(target, e, TransferEvent.REQUEST_GET);
private void prepareScm( File pomFile, ReleaseDescriptor releaseDescriptor, ScmRepository repository, ScmProvider provider ) throws ReleaseExecutionException, ReleaseScmCommandException { try { if ( isUpdateScm() && ( releaseDescriptor.isScmUseEditMode() || provider.requiresEditMode() ) ) { EditScmResult result = provider.edit( repository, new ScmFileSet( new File( releaseDescriptor.getWorkingDirectory() ), pomFile ) ); if ( !result.isSuccess() ) { throw new ReleaseScmCommandException( "Unable to enable editing on the POM", result ); } } } catch ( ScmException e ) { throw new ReleaseExecutionException( "An error occurred enabling edit mode: " + e.getMessage(), e ); } }
throw new MojoExecutionException( "Couldn't update project. " + e.getMessage(), e );
throw new ReleaseExecutionException( "Cannot remove release POMs from SCM: " + exception.getMessage(), exception );
private void checkin( ScmProvider provider, ScmRepository repository, ScmFileSet fileSet, ReleaseDescriptor releaseDescriptor, String message ) throws ReleaseExecutionException, ReleaseScmCommandException { CheckInScmResult result; try { result = provider.checkIn( repository, fileSet, (ScmVersion) null, message ); } catch ( ScmException e ) { throw new ReleaseExecutionException( "An error is occurred in the checkin process: " + e.getMessage(), e ); } if ( !result.isSuccess() ) { throw new ReleaseScmCommandException( "Unable to commit files", result ); } if ( releaseDescriptor.isRemoteTagging() ) { releaseDescriptor.setScmReleasedPomRevision( result.getScmRevision() ); } }
private static synchronized PerforceInfoCommand getSingleton( ScmLogger logger, PerforceScmProviderRepository repo ) { if ( singleton == null ) { PerforceInfoCommand pic = new PerforceInfoCommand(); if ( logger != null ) { pic.setLogger( logger ); } try { pic.executeCommand( repo, null, null ); singleton = pic; } catch ( ScmException e ) { if ( pic.getLogger().isErrorEnabled() ) { pic.getLogger().error( "ScmException " + e.getMessage(), e ); } } } return singleton; }
private static synchronized PerforceInfoCommand getSingleton( ScmLogger logger, PerforceScmProviderRepository repo ) { if ( singleton == null ) { PerforceInfoCommand pic = new PerforceInfoCommand(); if ( logger != null ) { pic.setLogger( logger ); } try { pic.executeCommand( repo, null, null ); singleton = pic; } catch ( ScmException e ) { if ( pic.getLogger().isErrorEnabled() ) { pic.getLogger().error( "ScmException " + e.getMessage(), e ); } } } return singleton; }
private void addReleasePomsToScm( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List<MavenProject> reactorProjects, boolean simulate, ReleaseResult result, List<File> releasePoms ) throws ReleaseFailureException, ReleaseExecutionException { if ( simulate ) { logInfo( result, "Full run would be adding " + releasePoms ); } else { ScmRepository scmRepository = getScmRepository( releaseDescriptor, releaseEnvironment ); ScmProvider scmProvider = getScmProvider( scmRepository ); MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); ScmFileSet scmFileSet = new ScmFileSet( rootProject.getFile().getParentFile(), releasePoms ); try { AddScmResult scmResult = scmProvider.add( scmRepository, scmFileSet ); if ( !scmResult.isSuccess() ) { throw new ReleaseScmCommandException( "Cannot add release POM to SCM", scmResult ); } } catch ( ScmException exception ) { throw new ReleaseExecutionException( "Cannot add release POM to SCM: " + exception.getMessage(), exception ); } } }
throw new ReleaseExecutionException( "An error occurred enabling edit mode: " + e.getMessage(), e );
public void execute( Map context ) throws Exception { Project project = ContinuumBuildAgentUtil.getProject( context ); try { File workingDirectory = buildAgentConfigurationService.getWorkingDirectory( project.getId() ); ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory ); config.setLatestUpdateDate( ContinuumBuildAgentUtil.getLatestUpdateDate( context ) ); getLogger().info( "Getting changeLog of project: " + project.getName() ); ChangeLogScmResult changeLogResult = scm.changeLog( config ); if ( !changeLogResult.isSuccess() ) { getLogger().warn( "Error getting change log of project " + project.getName() ); getLogger().warn( "Command Output: " + changeLogResult.getCommandOutput() ); getLogger().warn( "Provider Message: " + changeLogResult.getProviderMessage() ); } context.put( ContinuumBuildAgentUtil.KEY_LATEST_UPDATE_DATE, getLatestUpdateDate( changeLogResult ) ); } catch ( ScmException e ) { context.put( ContinuumBuildAgentUtil.KEY_LATEST_UPDATE_DATE, null ); getLogger().error( e.getMessage(), e ); } }