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

The following examples show how to use org.apache.maven.model.Scm#getUrl() . 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: MkdocsGitHubPagesDeployMojo.java    From siddhi with Apache License 2.0 6 votes vote down vote up
private void deployDocumentation(MavenProject rootMavenProject, String docGenBasePath) {
    // Creating the credential provider fot Git
    String scmUsername = System.getenv(Constants.SYSTEM_PROPERTY_SCM_USERNAME_KEY);
    String scmPassword = System.getenv(Constants.SYSTEM_PROPERTY_SCM_PASSWORD_KEY);

    if (scmUsername == null && scmPassword == null) {
        getLog().info("SCM_USERNAME and SCM_PASSWORD not defined!");
    }
    String url = null;
    Scm scm = rootMavenProject.getScm();
    if (scm != null) {
        url = scm.getUrl();
    }
    // Deploying documentation
    DocumentationUtils.updateDocumentationOnGitHub(docGenBasePath, mkdocsConfigFile, readmeFile,
            mavenProject.getVersion(), getLog());
    DocumentationUtils.deployMkdocsOnGitHubPages(mavenProject.getVersion(),
            rootMavenProject.getBasedir(), url, scmUsername, scmPassword, getLog());
}
 
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: HelmMojoTest.java    From jkube with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void executeInternalWithNoConfigShouldInitConfigWithDefaultValuesAndGenerate(
    @Mocked Scm scm, @Mocked Developer developer) throws Exception {

  // Given
  assertThat(helmMojo.helm, nullValue());
  new Expectations() {{
    mavenProject.getProperties();
    result = new Properties();
    mavenProject.getBuild().getOutputDirectory();
    result = "target/classes";
    mavenProject.getBuild().getDirectory();
    result = "target";
    mavenProject.getArtifactId();
    result = "artifact-id";
    mavenProject.getVersion();
    result = "1337";
    mavenProject.getDescription();
    result = "A description from Maven";
    mavenProject.getUrl();
    result = "https://project.url";
    mavenProject.getScm();
    result = scm;
    scm.getUrl();
    result = "https://scm.url";
    mavenProject.getDevelopers();
    result = Arrays.asList(developer, developer);
    developer.getName();
    result = "John"; result = "John"; result = null;
    developer.getEmail();
    result = "[email protected]"; result = null;
  }};
  // When
  helmMojo.executeInternal();
  // Then
  assertThat(helmMojo.helm, notNullValue());
  assertThat(helmMojo.helm.getChart(), is("artifact-id"));
  assertThat(helmMojo.helm.getChartExtension(), is("tar.gz"));
  assertThat(helmMojo.helm.getVersion(), is("1337"));
  assertThat(helmMojo.helm.getDescription(), is("A description from Maven"));
  assertThat(helmMojo.helm.getHome(), is("https://project.url"));
  assertThat(helmMojo.helm.getSources(), contains("https://scm.url"));
  assertThat(helmMojo.helm.getMaintainers(), contains(
      new Maintainer("John", "[email protected]")
  ));
  assertThat(helmMojo.helm.getIcon(), nullValue());
  assertThat(helmMojo.helm.getAdditionalFiles(), empty());
  assertThat(helmMojo.helm.getTemplates(), empty());
  assertThat(helmMojo.helm.getTypes(), contains(HelmConfig.HelmType.KUBERNETES));
  assertThat(helmMojo.helm.getSourceDir(), is("target/classes/META-INF/jkube/"));
  assertThat(helmMojo.helm.getOutputDir(), is("target/jkube/helm/artifact-id"));
  assertThat(helmMojo.helm.getTarballOutputDir(), is("target"));
  new Verifications() {{
    HelmService.generateHelmCharts(null, helmMojo.helm);
    times = 1;
  }};
}
 
Example 5
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;
}