use of org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository in project maven-plugins by apache.
the class ChangeLogReport method getScmRepository.
public ScmRepository getScmRepository() throws ScmException {
ScmRepository repository;
try {
repository = manager.makeScmRepository(getConnection());
ScmProviderRepository providerRepo = repository.getProviderRepository();
if (!StringUtils.isEmpty(username)) {
providerRepo.setUser(username);
}
if (!StringUtils.isEmpty(password)) {
providerRepo.setPassword(password);
}
if (repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost) {
ScmProviderRepositoryWithHost repo = (ScmProviderRepositoryWithHost) repository.getProviderRepository();
loadInfosFromSettings(repo);
if (!StringUtils.isEmpty(username)) {
repo.setUser(username);
}
if (!StringUtils.isEmpty(password)) {
repo.setPassword(password);
}
if (!StringUtils.isEmpty(privateKey)) {
repo.setPrivateKey(privateKey);
}
if (!StringUtils.isEmpty(passphrase)) {
repo.setPassphrase(passphrase);
}
}
if (!StringUtils.isEmpty(tagBase) && repository.getProvider().equals("svn")) {
SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository();
svnRepo.setTagBase(tagBase);
}
} catch (Exception e) {
throw new ScmException("Can't load the scm provider.", e);
}
return repository;
}
use of org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository in project maven-plugins by apache.
the class DoapMojo method writeSourceRepository.
/**
* Write a DOAP repository, for instance:
* <p/>
* <pre>
* <repository>
* <SVNRepository>
* <location rdf:resource="http://svn.apache.org/repos/asf/maven/components/trunk/"/>
* <browse rdf:resource="http://svn.apache.org/viewcvs.cgi/maven/components/trunk/"/>
* </SVNRepository>
* </repository>
* </pre>
*
* @param writer not null
* @param project the Maven project, not null
* @param connection not null
* @see <a href="http://usefulinc.com/ns/doap#Repository">http://usefulinc.com/ns/doap#Repository</a>
* @see <a href="http://usefulinc.com/ns/doap#CVSRepository">http://usefulinc.com/ns/doap#CVSRepository</a>
* @see <a href="http://usefulinc.com/ns/doap#SVNRepository">http://usefulinc.com/ns/doap#SVNRepository</a>
*/
private void writeSourceRepository(XMLWriter writer, MavenProject project, String connection) {
ScmRepository repository = getScmRepository(connection);
DoapUtil.writeStartElement(writer, doapOptions.getXmlnsPrefix(), "repository");
if (isScmSystem(repository, "cvs")) {
DoapUtil.writeStartElement(writer, doapOptions.getXmlnsPrefix(), "CVSRepository");
CvsScmProviderRepository cvsRepo = (CvsScmProviderRepository) repository.getProviderRepository();
DoapUtil.writeElement(writer, doapOptions.getXmlnsPrefix(), "anon-root", cvsRepo.getCvsRoot());
DoapUtil.writeElement(writer, doapOptions.getXmlnsPrefix(), "module", cvsRepo.getModule());
} else if (isScmSystem(repository, "svn")) {
DoapUtil.writeStartElement(writer, doapOptions.getXmlnsPrefix(), "SVNRepository");
SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository();
DoapUtil.writeRdfResourceElement(writer, doapOptions.getXmlnsPrefix(), "location", svnRepo.getUrl());
} else {
/*
* Supported DOAP repositories actually unsupported by SCM: BitKeeper
* (http://usefulinc.com/ns/doap#BKRepository) Arch (http://usefulinc.com/ns/doap#ArchRepository) Other SCM
* repos are unsupported by DOAP.
*/
DoapUtil.writeStartElement(writer, doapOptions.getXmlnsPrefix(), "Repository");
if (connection.length() < 4) {
throw new IllegalArgumentException("The source repository connection is too short.");
}
DoapUtil.writeRdfResourceElement(writer, doapOptions.getXmlnsPrefix(), "location", connection.substring(4));
}
DoapUtil.writeRdfResourceElement(writer, doapOptions.getXmlnsPrefix(), "browse", project.getScm().getUrl());
// CVSRepository || SVNRepository || Repository
writer.endElement();
// repository
writer.endElement();
}
use of org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository in project maven-plugins by apache.
the class AbstractScmPublishMojo method checkCreateRemoteSvnPath.
private void checkCreateRemoteSvnPath() throws MojoExecutionException {
getLog().debug("AbstractSvnScmProvider used, so we can check if remote url exists and eventually create it.");
AbstractSvnScmProvider svnScmProvider = (AbstractSvnScmProvider) scmProvider;
try {
boolean remoteExists = svnScmProvider.remoteUrlExist(scmRepository.getProviderRepository(), null);
if (remoteExists) {
return;
}
} catch (ScmException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
String remoteUrl = ((SvnScmProviderRepository) scmRepository.getProviderRepository()).getUrl();
if (!automaticRemotePathCreation) {
// olamy: return ?? that will fail during checkout IMHO :-)
logWarn("Remote svn url %s does not exist and automatic remote path creation disabled.", remoteUrl);
return;
}
logInfo("Remote svn url %s does not exist: creating.", remoteUrl);
File baseDir = null;
try {
// create a temporary directory for svnexec
baseDir = File.createTempFile("scm", "tmp");
baseDir.delete();
baseDir.mkdirs();
// to prevent fileSet cannot be empty
ScmFileSet scmFileSet = new ScmFileSet(baseDir, new File(""));
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString(CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.FALSE.toString());
commandParameters.setString(CommandParameter.MESSAGE, "Automatic svn path creation: " + remoteUrl);
svnScmProvider.mkdir(scmRepository.getProviderRepository(), scmFileSet, commandParameters);
// new remote url so force checkout!
if (checkoutDirectory.exists()) {
FileUtils.deleteDirectory(checkoutDirectory);
}
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (ScmException e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
if (baseDir != null) {
try {
FileUtils.forceDeleteOnExit(baseDir);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
}
}
Aggregations