*/
protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet files, String message,
ScmVersion version )
throws ScmException
{
Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir() );
PerforceCheckInConsumer consumer = new PerforceCheckInConsumer();
try
{
String jobs = System.getProperty( "maven.scm.jobs" );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( PerforceScmProvider.clean( "Executing " + cl.toString() ) );
}
PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
String changes = createChangeListSpecification( prepo, files, message,
PerforceScmProvider.getRepoPath( getLogger(), prepo,
files.getBasedir() ),
jobs );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Sending changelist:\n" + changes );
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
int exitCode =
CommandLineUtils.executeCommandLine( cl, new ByteArrayInputStream( changes.getBytes() ), consumer,
err );
if ( exitCode != 0 )
{
String cmdLine = CommandLineUtils.toString( cl.getCommandline() );
StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() );
msg.append( '\n' );
msg.append( "Command line was:" + cmdLine );
throw new CommandLineException( msg.toString() );
}
}
catch ( CommandLineException e )
{
if ( getLogger().isErrorEnabled() )
{
getLogger().error( "CommandLineException " + e.getMessage(), e );
}
}
return new CheckInScmResult( cl.toString(), consumer.isSuccess() ? "Checkin successful" : "Unable to submit",
consumer.getOutput(), consumer.isSuccess() );
}