Java Code Examples for org.apache.maven.model.Scm#getConnection()
The following examples show how to use
org.apache.maven.model.Scm#getConnection() .
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 |
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 |
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 |
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: AbstractDevOpsCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected String getOrFindGitUrl(UIExecutionContext context, String gitUrlText) { if (Strings.isNullOrBlank(gitUrlText)) { final Project project = getSelectedProject(context); if (project != null) { Resource<?> root = project.getRoot(); if (root != null) { try { Resource<?> gitFolder = root.getChild(".git"); if (gitFolder != null) { Resource<?> config = gitFolder.getChild("config"); if (config != null) { String configText = config.getContents(); gitUrlText = GitHelpers.extractGitUrl(configText); } } } catch (Exception e) { log.debug("Ignoring missing git folders: " + e, e); } } } } if (Strings.isNullOrBlank(gitUrlText)) { Model mavenModel = getMavenModel(context); if (mavenModel != null) { Scm scm = mavenModel.getScm(); if (scm != null) { String connection = scm.getConnection(); if (Strings.isNotBlank(connection)) { gitUrlText = connection; } } } } if (Strings.isNullOrBlank(gitUrlText)) { throw new IllegalArgumentException("Could not find git URL"); } return gitUrlText; }
Example 5
Source File: SCMManifestCustomizer.java From vertx-maven-plugin with Apache License 2.0 | 4 votes |
@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; }