Java Code Examples for org.apache.maven.model.Scm#getDeveloperConnection()

The following examples show how to use org.apache.maven.model.Scm#getDeveloperConnection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationAwareMavenXpp3Writer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void writeScm(Scm scm, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (scm.getConnection() != null) {
        writeValue(serializer, "connection", scm.getConnection(), scm);
    }
    if (scm.getDeveloperConnection() != null) {
        writeValue(serializer, "developerConnection", scm.getDeveloperConnection(), scm);
    }
    if ((scm.getTag() != null) && !scm.getTag().equals("HEAD")) {
        writeValue(serializer, "tag", scm.getTag(), scm);
    }
    if (scm.getUrl() != null) {
        writeValue(serializer, "url", scm.getUrl(), scm);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(scm, "", start, b.length());
}
 
Example 2
Source File: BaseMojo.java    From multi-module-maven-release-plugin with MIT License 6 votes vote down vote up
protected static String getRemoteUrlOrNullIfNoneSet(Scm originalScm, Scm actualScm) throws ValidationException {
    if (originalScm == null) {
        // No scm was specified, so don't inherit from any parent poms as they are probably used in different git repos
        return null;
    }

    // There is an SCM specified, so the actual SCM with derived values is used in case (so that variables etc are interpolated)
    String remote = actualScm.getDeveloperConnection();
    if (remote == null) {
        remote = actualScm.getConnection();
    }
    if (remote == null) {
        return null;
    }
    return GitHelper.scmUrlToRemote(remote);
}
 
Example 3
Source File: SCMManifestCustomizer.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private static String addAttributesFromProject(Map<String, String> attributes, Scm scm) {
    String connectionUrl = scm.getConnection() == null ? scm.getDeveloperConnection() : scm.getConnection();
    if (scm.getUrl() != null) {
        attributes.put(ExtraManifestKeys.SCM_URL.header(), scm.getUrl());
    }

    if (scm.getTag() != null) {
        attributes.put(ExtraManifestKeys.SCM_TAG.header(), scm.getTag());
    }
    return connectionUrl;
}
 
Example 4
Source File: SCMManifestCustomizer.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, String> getEntries(PackageMojo mojo, MavenProject project) {
    Map<String, String> attributes = new HashMap<>();

    if (mojo.isSkipScmMetadata()) {
        return attributes;
    }

    //Add SCM Metadata only when <scm> is configured in the pom.xml
    if (project.getScm() != null) {
        Scm scm = project.getScm();
        String connectionUrl = scm.getConnection() == null ? scm.getDeveloperConnection() : scm.getConnection();

        if (scm.getUrl() != null) {
            attributes.put("Scm-Url", scm.getUrl());
        }

        if (scm.getTag() != null) {
            attributes.put("Scm-Tag", scm.getTag());
        }
        if (mojo.getScmManager() != null && connectionUrl != null) {
            try {
                //SCM metadata
                File baseDir = project.getBasedir();
                ScmSpy scmSpy = new ScmSpy(mojo.getScmManager());

                Map<String, String> scmChangeLogMap = scmSpy.getChangeLog(connectionUrl, baseDir);

                if (!scmChangeLogMap.isEmpty()) {
                    attributes.put("Scm-Type",
                        scmChangeLogMap.get(ExtraManifestKeys.scmType.name()));
                    attributes.put("Scm-Revision",
                        scmChangeLogMap.get(ExtraManifestKeys.scmRevision.name()));
                    attributes.put("Last-Commit-Timestamp",
                        scmChangeLogMap.get(ExtraManifestKeys.lastCommitTimestamp.name()));
                    attributes.put("Author",
                        scmChangeLogMap.get(ExtraManifestKeys.author.name()));
                }

            } catch (Exception e) {
                mojo.getLog().warn("Error while getting SCM Metadata `" + e.getMessage() + "`");
                mojo.getLog().warn("SCM metadata ignored");
                mojo.getLog().debug(e);
            }
        }
    }
    return attributes;
}