Search in sources :

Example 16 with Scm

use of org.apache.maven.model.Scm in project maven by apache.

the class AbstractModelInterpolatorTest method testShouldThrowExceptionOnRecursiveScmConnectionReference.

@Test
public void testShouldThrowExceptionOnRecursiveScmConnectionReference() throws Exception {
    Model model = new Model();
    Scm scm = new Scm();
    scm.setConnection("${project.scm.connection}/somepath");
    model.setScm(scm);
    ModelInterpolator interpolator = createInterpolator();
    final SimpleProblemCollector collector = new SimpleProblemCollector();
    interpolator.interpolateModel(model, null, createModelBuildingRequest(context), collector);
    assertCollectorState(0, 1, 0, collector);
}
Also used : SimpleProblemCollector(org.apache.maven.model.building.SimpleProblemCollector) Model(org.apache.maven.model.Model) Scm(org.apache.maven.model.Scm) Test(org.junit.jupiter.api.Test)

Example 17 with Scm

use of org.apache.maven.model.Scm in project maven by apache.

the class ModelMerger method mergeModel_Scm.

protected void mergeModel_Scm(Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
    Scm src = source.getScm();
    if (src != null) {
        Scm tgt = target.getScm();
        if (tgt == null) {
            tgt = new Scm();
            tgt.setTag(null);
            target.setScm(tgt);
        }
        mergeScm(tgt, src, sourceDominant, context);
    }
}
Also used : Scm(org.apache.maven.model.Scm)

Example 18 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 19 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 20 with Scm

use of org.apache.maven.model.Scm in project jahia by Jahia.

the class ModuleBuildHelper method updateDuplicatedPom.

private void updateDuplicatedPom(String moduleName, String artifactId, String groupId, String dstVersion, File dstFolder) throws IOException {
    Model pom = null;
    try {
        pom = PomUtils.read(new File(dstFolder, "pom.xml"));
    } catch (XmlPullParserException e) {
        throw new IOException(e);
    }
    if (!"bundle".equals(pom.getPackaging())) {
        throw new IOException("This module is not compatible with the current version of Jahia.");
    }
    pom.setArtifactId(artifactId);
    pom.setGroupId(groupId);
    pom.setVersion(dstVersion);
    pom.setName(moduleName);
    Scm scm = new Scm();
    scm.setConnection(Constants.SCM_DUMMY_URI);
    scm.setDeveloperConnection(Constants.SCM_DUMMY_URI);
    pom.setScm(scm);
    pom.setDistributionManagement(null);
    pom.getProperties().remove("jahia-private-app-store");
    PomUtils.write(pom, new File(dstFolder, "pom.xml"));
}
Also used : Model(org.apache.maven.model.Model) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) Scm(org.apache.maven.model.Scm) JarFile(java.util.jar.JarFile)

Aggregations

Scm (org.apache.maven.model.Scm)63 MavenProject (org.apache.maven.project.MavenProject)20 Model (org.apache.maven.model.Model)14 Test (org.junit.Test)10 File (java.io.File)6 IOException (java.io.IOException)6 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Properties (java.util.Properties)4 Expectations (mockit.Expectations)4 ReleaseDescriptorBuilder (org.apache.maven.shared.release.config.ReleaseDescriptorBuilder)4 DefaultReleaseEnvironment (org.apache.maven.shared.release.env.DefaultReleaseEnvironment)4 ArrayList (java.util.ArrayList)3 Dependency (org.apache.maven.model.Dependency)3 IssueManagement (org.apache.maven.model.IssueManagement)3 License (org.apache.maven.model.License)3 ScmTranslator (org.apache.maven.shared.release.scm.ScmTranslator)3 HashSet (java.util.HashSet)2