use of org.apache.maven.model.Scm in project m2e-core by eclipse-m2e.
the class MavenCheckoutLocationPage method getScms.
public Scm[] getScms() {
if (scmUrls == null) {
return new Scm[0];
}
String revision = getRevision();
Scm[] scms = new Scm[scmUrls.length];
for (int i = 0; i < scms.length; i++) {
Scm scm = new Scm();
scm.setConnection(scmUrls[i].getUrl());
scm.setTag(revision);
scms[i] = scm;
}
return scms;
}
use of org.apache.maven.model.Scm in project m2e-core by eclipse-m2e.
the class MavenCheckoutWizard method performFinish.
public boolean performFinish() {
if (!canFinish()) {
return false;
}
final boolean checkoutAllProjects = scheckoutPage.isCheckoutAllProjects();
Scm[] scms = scheckoutPage.getScms();
final Collection<MavenProjectScmInfo> mavenProjects = new ArrayList<>();
for (Scm scm : scms) {
String url = scm.getConnection();
String revision = scm.getTag();
if (url.endsWith("/")) {
// $NON-NLS-1$
url = url.substring(0, url.length() - 1);
}
// $NON-NLS-1$
int n = url.lastIndexOf("/");
// $NON-NLS-1$
String label = (n == -1 ? url : url.substring(n)) + "/" + IMavenConstants.POM_FILE_NAME;
MavenProjectScmInfo projectInfo = new //
MavenProjectScmInfo(//
label, //
null, null, revision, url, url);
mavenProjects.add(projectInfo);
}
MavenProjectCheckoutJob job = new MavenProjectCheckoutJob(importConfiguration, checkoutAllProjects, workingSets) {
protected Collection<MavenProjectScmInfo> getProjects(IProgressMonitor monitor) {
return mavenProjects;
}
};
if (!locationPage.isInWorkspace()) {
job.setLocation(locationPage.getLocationPath().toFile());
}
job.schedule();
return true;
}
use of org.apache.maven.model.Scm in project unleash-maven-plugin by shillner.
the class DevVersionUtil method revertScmSettings.
public void revertScmSettings(MavenProject projectToRevert, Document document) {
Scm scm = this.metadata.getCachedScmSettings(projectToRevert);
if (scm != null) {
this.log.debug("\t\tReversion of SCM connection tags");
Document originalPOM = this.metadata.getCachedOriginalPOM(projectToRevert);
Node scmNode = PomUtil.getOrCreateScmNode(document, false);
Node originalScmNode = PomUtil.getOrCreateScmNode(originalPOM, false);
if (scmNode != null) {
Optional<String> connection = PomUtil.getChildNodeTextContent(originalScmNode, PomUtil.NODE_NAME_SCM_CONNECTION);
if (connection.isPresent()) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_CONNECTION, connection.get(), false);
}
Optional<String> devConnection = PomUtil.getChildNodeTextContent(originalScmNode, PomUtil.NODE_NAME_SCM_DEV_CONNECTION);
if (devConnection.isPresent()) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_DEV_CONNECTION, devConnection.get(), false);
}
Optional<String> url = PomUtil.getChildNodeTextContent(originalScmNode, PomUtil.NODE_NAME_SCM_URL);
if (url.isPresent()) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_URL, url.get(), false);
}
if (scm.getTag() != null) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_TAG, scm.getTag(), false);
} else {
PomUtil.deleteNode(scmNode, PomUtil.NODE_NAME_SCM_TAG);
}
}
}
}
use of org.apache.maven.model.Scm in project unleash-maven-plugin by shillner.
the class MavenScmUtil method calcProviderName.
/**
* Derives the name of the required SCM provider from the given Maven project by analyzing the scm connection strings
* of the project.
*
* @param project the project from which the SCM provider is retrieved.
* @return the name of the required SCM provider.
*/
public static Optional<String> calcProviderName(MavenProject project) {
String providerName = null;
Scm scm = project.getScm();
if (scm != null) {
// takes the developer connection first or the connection url if devConnection is empty or null
String connection = StringUtils.trimToNull(scm.getDeveloperConnection());
connection = connection != null ? connection : StringUtils.trimToNull(scm.getConnection());
// scm url format description: https://maven.apache.org/scm/scm-url-format.html
if (connection != null) {
// cuts the substring "scm:" at the beginning
connection = connection.substring(4);
// as stated in the scm url format description, the provider delimiter may be a colon (:) or a pipe (|) if
// colons are used otherwise (e.g. for windows paths)
// svn:http://... -> svn:http://...
// svn|http://... -> svn
// svn:http://xyz|... -> svn:http://xyz
int nextPipe = connection.indexOf('|');
if (nextPipe > -1) {
connection = connection.substring(0, nextPipe);
}
// svn -> svn
// svn:http... -> svn
int nextColon = connection.indexOf(':');
if (nextColon > -1) {
providerName = connection.substring(0, nextColon);
} else {
providerName = connection;
}
}
}
return Optional.fromNullable(providerName);
}
use of org.apache.maven.model.Scm in project gradle by gradle.
the class MavenPomFileGenerator method convertScm.
private Scm convertScm(MavenPomScm source) {
Scm target = new Scm();
target.setConnection(source.getConnection().getOrNull());
target.setDeveloperConnection(source.getDeveloperConnection().getOrNull());
target.setUrl(source.getUrl().getOrNull());
target.setTag(source.getTag().getOrNull());
return target;
}
Aggregations