Java Code Examples for org.apache.maven.project.MavenProject#getScm()
The following examples show how to use
org.apache.maven.project.MavenProject#getScm() .
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: SCMManifestCustomizer.java From vertx-maven-plugin with Apache License 2.0 | 6 votes |
@Override public Map<String, String> getEntries(AbstractVertxMojo mojo, MavenProject project) { Map<String, String> attributes = new HashMap<>(); Scm scm = project.getScm(); // TODO this should be in the archive. if (mojo.skipScmMetadata() || scm == null) { return attributes; } String connectionUrl = addAttributesFromProject(attributes, scm); if (mojo.getScmManager() != null && connectionUrl != null) { try { addAttributeFromScmManager(mojo, attributes, connectionUrl, project.getBasedir()); } 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; }
Example 2
Source File: ScmUtils.java From gitflow-helper-maven-plugin with Apache License 2.0 | 6 votes |
/** * Given the ScmManager for the current execution cycle, and the MavenProject structure, determine the SCM URL or * an expression we can resolve the URL from. * * @param project The Current maven Project * @return The developerConnection, if none set, the connection, if none set, then the expression, <code>"${env.GIT_URL}"</code> */ public static String resolveUrlOrExpression(final MavenProject project) { String connectionUrl; // Some projects don't specify SCM Blocks, and instead rely upon the CI server to provide an '${env.GIT_BRANCH}' if (project.getScm() != null) { // Start with the developer connection, then fall back to the non-developer connection. connectionUrl = project.getScm().getDeveloperConnection(); if (StringUtils.isBlank(connectionUrl)) { connectionUrl = project.getScm().getConnection(); } // Issue #74, missing an emtpy / null check before returning. if (!StringUtils.isBlank(connectionUrl)) { return connectionUrl; } } return DEFAULT_URL_EXPRESSION; }
Example 3
Source File: MkdocsGitHubPagesDeployMojo.java From siddhi with Apache License 2.0 | 6 votes |
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 4
Source File: CheckoutAction.java From netbeans with Apache License 2.0 | 5 votes |
private Scm getScm() { Iterator<? extends MavenProject> prj = result.allInstances().iterator(); if (!prj.hasNext()) { return null; } MavenProject project = prj.next(); return project.getScm(); }
Example 5
Source File: MavenScmUtil.java From unleash-maven-plugin with Eclipse Public License 1.0 | 5 votes |
/** * 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); }
Example 6
Source File: MavenHelper.java From cyclonedx-gradle-plugin with Apache License 2.0 | 4 votes |
/** * Extracts data from a project and adds the data to the component. * @param project the project to extract data from * @param component the component to add data to */ private void extractMetadata(MavenProject project, Component component) { if (component.getPublisher() == null) { // If we don't already have publisher information, retrieve it. if (project.getOrganization() != null) { component.setPublisher(project.getOrganization().getName()); } } if (component.getDescription() == null) { // If we don't already have description information, retrieve it. component.setDescription(project.getDescription()); } if (component.getLicenseChoice() == null || component.getLicenseChoice().getLicenses() == null || component.getLicenseChoice().getLicenses().isEmpty()) { // If we don't already have license information, retrieve it. if (project.getLicenses() != null) { component.setLicenseChoice(resolveMavenLicenses(project.getLicenses())); } } if (CycloneDxSchema.Version.VERSION_10 != schemaVersion) { if (project.getOrganization() != null && project.getOrganization().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.WEBSITE)) { addExternalReference(ExternalReference.Type.WEBSITE, project.getOrganization().getUrl(), component); } } if (project.getCiManagement() != null && project.getCiManagement().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.BUILD_SYSTEM)) { addExternalReference(ExternalReference.Type.BUILD_SYSTEM, project.getCiManagement().getUrl(), component); } } if (project.getDistributionManagement() != null && project.getDistributionManagement().getDownloadUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.DISTRIBUTION)) { addExternalReference(ExternalReference.Type.DISTRIBUTION, project.getDistributionManagement().getDownloadUrl(), component); } } if (project.getDistributionManagement() != null && project.getDistributionManagement().getRepository() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.DISTRIBUTION)) { addExternalReference(ExternalReference.Type.DISTRIBUTION, project.getDistributionManagement().getRepository().getUrl(), component); } } if (project.getIssueManagement() != null && project.getIssueManagement().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.ISSUE_TRACKER)) { addExternalReference(ExternalReference.Type.ISSUE_TRACKER, project.getIssueManagement().getUrl(), component); } } if (project.getMailingLists() != null && project.getMailingLists().size() > 0) { for (MailingList list : project.getMailingLists()) { if (list.getArchive() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.MAILING_LIST)) { addExternalReference(ExternalReference.Type.MAILING_LIST, list.getArchive(), component); } } else if (list.getSubscribe() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.MAILING_LIST)) { addExternalReference(ExternalReference.Type.MAILING_LIST, list.getSubscribe(), component); } } } } if (project.getScm() != null && project.getScm().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.VCS)) { addExternalReference(ExternalReference.Type.VCS, project.getScm().getUrl(), component); } } } }
Example 7
Source File: BaseCycloneDxMojo.java From cyclonedx-maven-plugin with Apache License 2.0 | 4 votes |
/** * Extracts data from a project and adds the data to the component. * @param project the project to extract data from * @param component the component to add data to */ private void extractMetadata(MavenProject project, Component component) { if (component.getPublisher() == null) { // If we don't already have publisher information, retrieve it. if (project.getOrganization() != null) { component.setPublisher(project.getOrganization().getName()); } } if (component.getDescription() == null) { // If we don't already have description information, retrieve it. component.setDescription(project.getDescription()); } if (component.getLicenseChoice() == null || component.getLicenseChoice().getLicenses() == null || component.getLicenseChoice().getLicenses().isEmpty()) { // If we don't already have license information, retrieve it. if (project.getLicenses() != null) { component.setLicenseChoice(resolveMavenLicenses(project.getLicenses())); } } if (CycloneDxSchema.Version.VERSION_10 != schemaVersion()) { if (project.getOrganization() != null && project.getOrganization().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.WEBSITE)) { addExternalReference(ExternalReference.Type.WEBSITE, project.getOrganization().getUrl(), component); } } if (project.getCiManagement() != null && project.getCiManagement().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.BUILD_SYSTEM)) { addExternalReference(ExternalReference.Type.BUILD_SYSTEM, project.getCiManagement().getUrl(), component); } } if (project.getDistributionManagement() != null && project.getDistributionManagement().getDownloadUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.DISTRIBUTION)) { addExternalReference(ExternalReference.Type.DISTRIBUTION, project.getDistributionManagement().getDownloadUrl(), component); } } if (project.getDistributionManagement() != null && project.getDistributionManagement().getRepository() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.DISTRIBUTION)) { addExternalReference(ExternalReference.Type.DISTRIBUTION, project.getDistributionManagement().getRepository().getUrl(), component); } } if (project.getIssueManagement() != null && project.getIssueManagement().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.ISSUE_TRACKER)) { addExternalReference(ExternalReference.Type.ISSUE_TRACKER, project.getIssueManagement().getUrl(), component); } } if (project.getMailingLists() != null && project.getMailingLists().size() > 0) { for (MailingList list : project.getMailingLists()) { if (list.getArchive() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.MAILING_LIST)) { addExternalReference(ExternalReference.Type.MAILING_LIST, list.getArchive(), component); } } else if (list.getSubscribe() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.MAILING_LIST)) { addExternalReference(ExternalReference.Type.MAILING_LIST, list.getSubscribe(), component); } } } } if (project.getScm() != null && project.getScm().getUrl() != null) { if (!doesComponentHaveExternalReference(component, ExternalReference.Type.VCS)) { addExternalReference(ExternalReference.Type.VCS, project.getScm().getUrl(), component); } } } }
Example 8
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; }