Search in sources :

Example 31 with Scm

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;
}
Also used : Scm(org.apache.maven.model.Scm) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 32 with Scm

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;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) MavenProjectScmInfo(org.eclipse.m2e.scm.MavenProjectScmInfo) Scm(org.apache.maven.model.Scm)

Example 33 with Scm

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);
            }
        }
    }
}
Also used : Node(org.w3c.dom.Node) Scm(org.apache.maven.model.Scm) Document(org.w3c.dom.Document)

Example 34 with Scm

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);
}
Also used : Scm(org.apache.maven.model.Scm)

Example 35 with Scm

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;
}
Also used : Scm(org.apache.maven.model.Scm) MavenPomScm(org.gradle.api.publish.maven.MavenPomScm)

Aggregations

Scm (org.apache.maven.model.Scm)64 MavenProject (org.apache.maven.project.MavenProject)21 Model (org.apache.maven.model.Model)14 Test (org.junit.Test)10 File (java.io.File)7 IOException (java.io.IOException)7 Map (java.util.Map)5 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Properties (java.util.Properties)4 Expectations (mockit.Expectations)4 Dependency (org.apache.maven.model.Dependency)4 IssueManagement (org.apache.maven.model.IssueManagement)4 ReleaseDescriptorBuilder (org.apache.maven.shared.release.config.ReleaseDescriptorBuilder)4 DefaultReleaseEnvironment (org.apache.maven.shared.release.env.DefaultReleaseEnvironment)4 Path (java.nio.file.Path)3 License (org.apache.maven.model.License)3 Parent (org.apache.maven.model.Parent)3