use of org.codehaus.plexus.util.cli.StreamConsumer in project maven-scm by apache.
the class JazzCheckInCommand method executeCheckInCommand.
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion) throws ScmException {
// Call the Add command to perform the checkin into the repository workspace.
JazzAddCommand addCommand = new JazzAddCommand();
addCommand.setLogger(getLogger());
AddScmResult addResult = addCommand.executeAddCommand(repo, fileSet);
// Now, if it has a flow target, deliver it.
JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
if (jazzRepo.isPushChangesAndHaveFlowTargets()) {
// Push if we need too
JazzScmCommand deliverCmd = createDeliverCommand((JazzScmProviderRepository) repo, fileSet);
StreamConsumer deliverConsumer = // No need for a dedicated consumer for this
new DebugLoggerConsumer(getLogger());
ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
int status = deliverCmd.execute(deliverConsumer, errConsumer);
if (status != 0) {
return new CheckInScmResult(deliverCmd.getCommandString(), "Error code for Jazz SCM deliver command - " + status, errConsumer.getOutput(), false);
}
}
// Return what was added.
return new CheckInScmResult(addResult.getCommandLine(), addResult.getAddedFiles());
}
use of org.codehaus.plexus.util.cli.StreamConsumer in project maven-scm by apache.
the class JazzTckUtil method executeCommand.
/* (non-Javadoc)
* @see org.apache.maven.scm.command.AbstractCommand#executeCommand(org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
*/
@Override
protected ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repository;
StreamConsumer tckConsumer = // No need for a dedicated consumer for this
new DebugLoggerConsumer(getLogger());
ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
String nameWorkspace = jazzRepo.getRepositoryWorkspace();
// String nameSnapshot = "MavenSCMTestSnapshot";
String nameSnapshot = getSnapshotName();
JazzScmCommand tckCreateWorkspaceFromSnapshotCmd = createCreateWorkspaceFromSnapshotCommand(jazzRepo, fileSet, nameWorkspace, nameSnapshot);
int status = tckCreateWorkspaceFromSnapshotCmd.execute(tckConsumer, errConsumer);
if (status != 0) {
return new ScmResult(tckCreateWorkspaceFromSnapshotCmd.getCommandString(), "Error code for Jazz SCM (create workspace --snapshot) command - " + status, errConsumer.getOutput(), false);
}
return new ScmResult(tckCreateWorkspaceFromSnapshotCmd.getCommandString(), "All ok", ((DebugLoggerConsumer) tckConsumer).getOutput(), true);
}
use of org.codehaus.plexus.util.cli.StreamConsumer in project maven-clean-plugin by apache.
the class Utils method createSymlink.
/**
* Creates a symbolic link.
*
* @param target The target (file or directory) of the link, must not be <code>null</code>.
* @param link The path to the link, must not be <code>null</code>.
* @return <code>true</code> if the symlink could be created, <code>false</code> otherwise.
*/
public static boolean createSymlink(File target, File link) {
try {
Commandline cli = new Commandline();
cli.setExecutable("ln");
cli.createArg().setValue("-s");
cli.createArg().setFile(target);
cli.createArg().setFile(link);
int code = CommandLineUtils.executeCommandLine(cli, new StreamConsumer() {
public void consumeLine(String line) {
System.out.println(line);
}
}, new StreamConsumer() {
public void consumeLine(String line) {
System.err.println(line);
}
});
return 0 == code;
} catch (Exception e) {
return false;
}
}
use of org.codehaus.plexus.util.cli.StreamConsumer in project maven-plugins by apache.
the class Utils method createSymlink.
/**
* Creates a symbolic link.
*
* @param target The target (file or directory) of the link, must not be <code>null</code>.
* @param link The path to the link, must not be <code>null</code>.
* @return <code>true</code> if the symlink could be created, <code>false</code> otherwise.
*/
public static boolean createSymlink(File target, File link) {
try {
Commandline cli = new Commandline();
cli.setExecutable("ln");
cli.createArg().setValue("-s");
cli.createArg().setFile(target);
cli.createArg().setFile(link);
int code = CommandLineUtils.executeCommandLine(cli, new StreamConsumer() {
public void consumeLine(String line) {
System.out.println(line);
}
}, new StreamConsumer() {
public void consumeLine(String line) {
System.err.println(line);
}
});
return 0 == code;
} catch (Exception e) {
return false;
}
}
use of org.codehaus.plexus.util.cli.StreamConsumer in project maven-plugins by apache.
the class AbstractInvokerMojo method resolveExternalJreVersion.
private CharSequence resolveExternalJreVersion() {
Artifact pluginArtifact = mojoExecution.getMojoDescriptor().getPluginDescriptor().getPluginArtifact();
pluginArtifact.getFile();
Commandline commandLine = new Commandline();
commandLine.setExecutable(new File(javaHome, "bin/java").getAbsolutePath());
commandLine.createArg().setValue("-cp");
commandLine.createArg().setFile(pluginArtifact.getFile());
commandLine.createArg().setValue(SystemPropertyPrinter.class.getName());
commandLine.createArg().setValue("java.version");
final StringBuilder actualJreVersion = new StringBuilder();
StreamConsumer consumer = new StreamConsumer() {
public void consumeLine(String line) {
actualJreVersion.append(line);
}
};
try {
CommandLineUtils.executeCommandLine(commandLine, consumer, null);
} catch (CommandLineException e) {
getLog().warn(e.getMessage());
}
return actualJreVersion;
}
Aggregations