use of org.apache.maven.scm.ScmTag in project maven-scm by apache.
the class SvnTagCommand method createCommandLine.
public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, String tag, File messageFile, ScmTagParameters scmTagParameters) {
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
cl.createArg().setValue("copy");
cl.createArg().setValue("--file");
cl.createArg().setValue(messageFile.getAbsolutePath());
cl.createArg().setValue("--parents");
if (scmTagParameters != null && scmTagParameters.getScmRevision() != null) {
cl.createArg().setValue("--revision");
cl.createArg().setValue(scmTagParameters.getScmRevision());
}
if (scmTagParameters != null && scmTagParameters.isRemoteTagging()) {
cl.createArg().setValue(SvnCommandUtils.fixUrl(repository.getUrl(), repository.getUser()));
} else {
cl.createArg().setValue(".");
}
// Note: this currently assumes you have the tag base checked out too
String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag));
cl.createArg().setValue(SvnCommandUtils.fixUrl(tagUrl, repository.getUser()));
return cl;
}
use of org.apache.maven.scm.ScmTag in project maven-scm by apache.
the class SvnTagBranchUtilsTest method testResolveTagUrl.
private void testResolveTagUrl(String scmUrl, String tagBase, String tag, String expected) throws Exception {
SvnScmProviderRepository repository = getSvnRepository(scmUrl);
if (tagBase != null) {
repository.setTagBase(tagBase);
}
if (tagBase != null) {
assertEquals(repository.getTagBase(), tagBase);
} else {
assertEquals(repository.getTagBase(), SvnTagBranchUtils.resolveTagBase(repository.getUrl()));
}
assertEquals(expected, SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag)));
}
use of org.apache.maven.scm.ScmTag in project maven-scm by apache.
the class SvnExeExportCommand method executeExportCommand.
/**
* {@inheritDoc}
*/
protected ExportScmResult executeExportCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, String outputDirectory) throws ScmException {
if (outputDirectory == null) {
outputDirectory = fileSet.getBasedir().getAbsolutePath();
}
SvnScmProviderRepository repository = (SvnScmProviderRepository) repo;
String url = repository.getUrl();
if (version != null && StringUtils.isNotEmpty(version.getName())) {
if (version instanceof ScmTag) {
url = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version);
} else if (version instanceof ScmBranch) {
url = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version);
}
}
url = SvnCommandUtils.fixUrl(url, repository.getUser());
Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet.getBasedir(), version, url, outputDirectory);
SvnUpdateConsumer consumer = new SvnUpdateConsumer(getLogger(), fileSet.getBasedir());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (cl.getWorkingDirectory() != null && Os.isFamily(Os.FAMILY_WINDOWS)) {
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new ExportScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new ExportScmResultWithRevision(cl.toString(), consumer.getUpdatedFiles(), String.valueOf(consumer.getRevision()));
}
use of org.apache.maven.scm.ScmTag in project maven-scm by apache.
the class SynergyCCMTest method testCheckoutProject.
public void testCheckoutProject() throws Exception {
Commandline cl = SynergyCCM.checkoutProject(null, "MyProject", new ScmTag("MyVersion"), "MyPurpose", "MyRelease", "CCM_ADDR");
assertTrue("CCM_ADDR is not set.", assertContains(cl.getEnvironmentVariables(), "CCM_ADDR=CCM_ADDR"));
assertCommandLine("ccm co -subprojects -rel -t MyVersion -purpose MyPurpose -release MyRelease -p MyProject", null, cl);
File f = File.createTempFile("test", null);
f.deleteOnExit();
cl = SynergyCCM.checkoutProject(f.getParentFile(), "MyProject", new ScmTag("MyVersion"), "MyPurpose", "MyRelease", "CCM_ADDR");
if (f.getCanonicalPath().indexOf(' ') > -1) {
assertCommandLine("ccm co -subprojects -rel -t MyVersion -purpose MyPurpose -release MyRelease -path \"" + f.getParentFile().getCanonicalPath() + "\" -p MyProject", null, cl);
} else {
assertCommandLine("ccm co -subprojects -rel -t MyVersion -purpose MyPurpose -release MyRelease -path " + f.getParentFile().getCanonicalPath() + " -p MyProject", null, cl);
}
}
use of org.apache.maven.scm.ScmTag in project maven-scm by apache.
the class MavenScmCli method main.
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public static void main(String[] args) {
MavenScmCli cli;
try {
cli = new MavenScmCli();
} catch (Exception ex) {
System.err.println("Error while starting Maven Scm.");
ex.printStackTrace(System.err);
return;
}
String scmUrl;
String command;
if (args.length != 3) {
System.err.println("Usage: maven-scm-client <command> <working directory> <scm url> [<scmVersion> [<scmVersionType>]]");
System.err.println("scmVersion is a branch name/tag name/revision number.");
System.err.println("scmVersionType can be 'branch', 'tag', 'revision'. " + "The default value is 'revision'.");
return;
}
command = args[0];
// SCM-641
File workingDirectory = new File(args[1]).getAbsoluteFile();
scmUrl = args[2];
ScmVersion scmVersion = null;
if (args.length > 3) {
String version = args[3];
if (args.length > 4) {
String type = args[4];
if ("tag".equals(type)) {
scmVersion = new ScmTag(version);
} else if ("branch".equals(type)) {
scmVersion = new ScmBranch(version);
} else if ("revision".equals(type)) {
scmVersion = new ScmRevision(version);
} else {
throw new IllegalArgumentException("'" + type + "' version type isn't known.");
}
} else {
scmVersion = new ScmRevision(args[3]);
}
}
cli.execute(scmUrl, command, workingDirectory, scmVersion);
cli.stop();
}
Aggregations