Example usage for org.apache.maven.project MavenProject getIssueManagement

List of usage examples for org.apache.maven.project MavenProject getIssueManagement

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getIssueManagement.

Prototype

public IssueManagement getIssueManagement() 

Source Link

Usage

From source file:com.effectivemaven.centrepoint.maven.repository.CentralRepositoryService.java

License:Apache License

public Project retrieveProject(String groupId, String artifactId, String version) throws RepositoryException {
    // get the project from the repository
    Artifact artifact = artifactFactory.createProjectArtifact(groupId, artifactId, version);
    MavenProject mavenProject;
    try {/*from   w  w  w  .ja va  2 s  . co m*/
        mavenProject = projectBuilder.buildFromRepository(artifact, Collections.singletonList(repository),
                localRepository);
    } catch (ProjectBuildingException e) {
        throw new RepositoryException(e.getMessage(), e);
    }

    // populate the Centrepoint model from the Maven project
    Project project = new Project();
    project.setId(MavenCoordinates.constructProjectId(groupId, artifactId));
    project.setVersion(version);

    MavenCoordinates coordinates = new MavenCoordinates();
    coordinates.setGroupId(groupId);
    coordinates.setArtifactId(artifactId);
    project.addExtensionModel(coordinates);

    project.setDescription(mavenProject.getDescription());
    project.setName(mavenProject.getName());
    if (mavenProject.getCiManagement() != null) {
        project.setCiManagementUrl(mavenProject.getCiManagement().getUrl());
    }
    if (mavenProject.getIssueManagement() != null) {
        project.setIssueTrackerUrl(mavenProject.getIssueManagement().getUrl());
    }
    if (mavenProject.getScm() != null) {
        project.setScmUrl(mavenProject.getScm().getUrl());
    }
    project.setUrl(mavenProject.getUrl());

    DistributionManagement distMgmt = mavenProject.getDistributionManagement();
    if (distMgmt != null) {
        project.setRepositoryUrl(distMgmt.getRepository().getUrl());
        project.setSnapshotRepositoryUrl(distMgmt.getSnapshotRepository().getUrl());
    }

    return project;
}

From source file:com.github.spyhunter99.pdf.plugin.PdfMojo.java

License:Apache License

/**
 * Parsing the generated report to see if it is correct or not. Log the error for the user.
 *
 * @param mojoDescriptor not null//from   w  w  w .  jav a 2  s . c  o  m
 * @param generatedReport not null
 * @param localReportName not null
 * @return <code>true</code> if Doxia is able to parse the generated report, <code>false</code> otherwise.
 * @since 1.1
 */
private boolean isValidGeneratedReport(Artifact pluginArtifact, File generatedReport, String localReportName) {
    SinkAdapter sinkAdapter = new SinkAdapter();
    Reader reader = null;
    try {
        reader = ReaderFactory.newXmlReader(generatedReport);

        doxia.parse(reader, generatedReport.getParentFile().getName(), sinkAdapter);

        reader.close();
        reader = null;
    } catch (ParseException e) {
        StringBuilder sb = new StringBuilder(1024);

        sb.append(EOL).append(EOL);
        sb.append("Error when parsing the generated report: ").append(generatedReport.getAbsolutePath());
        sb.append(EOL);
        sb.append(e.getMessage());
        sb.append(EOL).append(EOL);

        sb.append("You could:").append(EOL);
        sb.append("  * exclude all reports using -DincludeReports=false").append(EOL);
        sb.append("  * remove the ");
        sb.append(pluginArtifact.getGroupId());
        sb.append(":");
        sb.append(pluginArtifact.getArtifactId());
        sb.append(":");
        sb.append(pluginArtifact.getVersion());
        sb.append(" from the <reporting/> part. To not affect the site generation, ");
        sb.append("you could create a PDF profile.").append(EOL);
        sb.append(EOL);

        MavenProject pluginProject = getReportPluginProject(pluginArtifact);

        if (pluginProject == null) {
            sb.append("You could also contact the Plugin team.").append(EOL);
        } else {
            sb.append("You could also contact the Plugin team:").append(EOL);
            if (pluginProject.getMailingLists() != null && !pluginProject.getMailingLists().isEmpty()) {
                boolean appended = false;
                for (Object o : pluginProject.getMailingLists()) {
                    MailingList mailingList = (MailingList) o;

                    if (StringUtils.isNotEmpty(mailingList.getName())
                            && StringUtils.isNotEmpty(mailingList.getPost())) {
                        if (!appended) {
                            sb.append("  Mailing Lists:").append(EOL);
                            appended = true;
                        }
                        sb.append("    ").append(mailingList.getName());
                        sb.append(": ").append(mailingList.getPost());
                        sb.append(EOL);
                    }
                }
            }
            if (StringUtils.isNotEmpty(pluginProject.getUrl())) {
                sb.append("  Web Site:").append(EOL);
                sb.append("    ").append(pluginProject.getUrl());
                sb.append(EOL);
            }
            if (pluginProject.getIssueManagement() != null
                    && StringUtils.isNotEmpty(pluginProject.getIssueManagement().getUrl())) {
                sb.append("  Issue Tracking:").append(EOL);
                sb.append("    ").append(pluginProject.getIssueManagement().getUrl());
                sb.append(EOL);
            }
        }

        sb.append(EOL).append("Ignoring the \"").append(localReportName).append("\" report in the PDF.")
                .append(EOL);

        getLog().error(sb.toString());
        getLog().debug(e);

        return false;
    } catch (ParserNotFoundException e) {
        getLog().error("ParserNotFoundException: " + e.getMessage());
        getLog().debug(e);

        return false;
    } catch (IOException e) {
        getLog().error("IOException: " + e.getMessage());
        getLog().debug(e);

        return false;
    } finally {
        IOUtil.close(reader);
    }

    return true;
}

From source file:io.fabric8.maven.enricher.standard.MavenIssueManagementEnricher.java

License:Apache License

@Override
public Map<String, String> getAnnotations(Kind kind) {
    Map<String, String> annotations = new HashMap<>();
    if (kind.isController() || kind == Kind.SERVICE) {
        MavenProject rootProject = getProject();
        if (hasIssueManagement(rootProject)) {
            IssueManagement issueManagement = rootProject.getIssueManagement();
            String system = issueManagement.getSystem();
            String url = issueManagement.getUrl();
            if (StringUtils.isNotEmpty(system) && StringUtils.isNotEmpty(url)) {
                annotations.put(ISSUE_MANAGEMENT_SYSTEM, system);
                annotations.put(ISSUE_MANAGEMENT_URL, url);
                return annotations;
            }//  ww w.j  a v a  2s .c om
        }
    }
    return annotations;
}

From source file:io.fabric8.maven.enricher.standard.MavenIssueManagementEnricher.java

License:Apache License

private boolean hasIssueManagement(MavenProject project) {
    return project.getIssueManagement() != null;
}

From source file:org.eclipse.m2e.core.ui.internal.actions.OpenUrlAction.java

License:Open Source License

private static String getUrl(String actionId, MavenProject mavenProject) {
    String url = null;/*ww  w .  j a  v  a 2 s  .c om*/
    if (ID_PROJECT.equals(actionId)) {
        url = mavenProject.getUrl();
        if (url == null) {
            openDialog(Messages.OpenUrlAction_error_no_url);
        }
    } else if (ID_ISSUES.equals(actionId)) {
        IssueManagement issueManagement = mavenProject.getIssueManagement();
        if (issueManagement != null) {
            url = issueManagement.getUrl();
        }
        if (url == null) {
            openDialog(Messages.OpenUrlAction_error_no_issues);
        }
    } else if (ID_SCM.equals(actionId)) {
        Scm scm = mavenProject.getScm();
        if (scm != null) {
            url = scm.getUrl();
        }
        if (url == null) {
            openDialog(Messages.OpenUrlAction_error_no_scm);
        }
    } else if (ID_CI.equals(actionId)) {
        CiManagement ciManagement = mavenProject.getCiManagement();
        if (ciManagement != null) {
            url = ciManagement.getUrl();
        }
        if (url == null) {
            openDialog(Messages.OpenUrlAction_error_no_ci);
        }
    }
    return url;
}

From source file:org.maven.ide.eclipse.mylyn3.MavenRepositoryLinkProvider.java

License:Open Source License

private String getIssueManagementUrl(IResource resource) {
    IProject project = resource.getProject();
    if (project == null || !project.isAccessible()) {
        return null;
    }//  www  . j av a  2 s .co  m

    MavenProjectManager projectManager = MavenPlugin.getDefault().getMavenProjectManager();
    IProgressMonitor monitor = new NullProgressMonitor();
    IMavenProjectFacade facade = projectManager.create(project, monitor);
    if (facade != null) {
        MavenProject mavenProject;
        try {
            mavenProject = facade.getMavenProject(monitor);
            if (mavenProject != null) {
                IssueManagement issueManagement = mavenProject.getIssueManagement();
                if (issueManagement != null) {
                    return issueManagement.getUrl();
                }
            }
        } catch (CoreException ex) {
            MavenLogger.log("Could not determine project issue management URL", ex);
        }
    }

    return null;
}

From source file:org.sonar.batch.maven.MavenProjectConverter.java

License:Open Source License

/**
 * For SONAR-3676/*www  .  ja v a 2 s. c o m*/
 */
private static void convertMavenLinksToProperties(ProjectDefinition definition, MavenProject pom) {
    setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_HOME_PAGE, pom.getUrl());

    Scm scm = pom.getScm();
    if (scm == null) {
        scm = new Scm();
    }
    setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_SOURCES, scm.getUrl());
    setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_SOURCES_DEV, scm.getDeveloperConnection());

    CiManagement ci = pom.getCiManagement();
    if (ci == null) {
        ci = new CiManagement();
    }
    setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_CI, ci.getUrl());

    IssueManagement issues = pom.getIssueManagement();
    if (issues == null) {
        issues = new IssueManagement();
    }
    setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_ISSUE_TRACKER, issues.getUrl());
}

From source file:org.sonar.updatecenter.deprecated.UpdateCenter.java

License:Open Source License

private History<Plugin> resolvePluginHistory(String id) throws Exception {
    String groupId = StringUtils.substringBefore(id, ":");
    String artifactId = StringUtils.substringAfter(id, ":");

    Artifact artifact = artifactFactory.createArtifact(groupId, artifactId, Artifact.LATEST_VERSION,
            Artifact.SCOPE_COMPILE, ARTIFACT_JAR_TYPE);

    List<ArtifactVersion> versions = filterSnapshots(
            metadataSource.retrieveAvailableVersions(artifact, localRepository, remoteRepositories));

    History<Plugin> history = new History<Plugin>();
    for (ArtifactVersion version : versions) {
        Plugin plugin = org.sonar.updatecenter.deprecated.Plugin
                .extractMetadata(resolve(artifact.getGroupId(), artifact.getArtifactId(), version.toString()));
        history.addArtifact(version, plugin);

        MavenProject project = mavenProjectBuilder
                .buildFromRepository(//w w  w  . j  av  a2  s .c om
                        artifactFactory.createArtifact(groupId, artifactId, version.toString(),
                                Artifact.SCOPE_COMPILE, ARTIFACT_POM_TYPE),
                        remoteRepositories, localRepository);

        if (plugin.getVersion() == null) {
            // Legacy plugin - set default values
            plugin.setKey(project.getArtifactId());
            plugin.setName(project.getName());
            plugin.setVersion(project.getVersion());

            String sonarVersion = "1.10"; // TODO Is it minimal version for all extension points ?
            for (Dependency dependency : project.getDependencies()) {
                if ("sonar-plugin-api".equals(dependency.getArtifactId())) { // TODO dirty hack
                    sonarVersion = dependency.getVersion();
                }
            }

            plugin.setRequiredSonarVersion(sonarVersion);
            plugin.setHomepage(project.getUrl());
        }
        plugin.setDownloadUrl(getPluginDownloadUrl(groupId, artifactId, plugin.getVersion()));
        // There is no equivalent for following properties in MANIFEST.MF
        if (project.getIssueManagement() != null) {
            plugin.setIssueTracker(project.getIssueManagement().getUrl());
        } else {
            System.out.println("Unknown Issue Management for " + plugin.getKey() + ":" + plugin.getVersion());
        }
        if (project.getScm() != null) {
            String scmUrl = project.getScm().getUrl();
            if (StringUtils.startsWith(scmUrl, "scm:")) {
                scmUrl = StringUtils.substringAfter(StringUtils.substringAfter(scmUrl, ":"), ":");
            }
            plugin.setSources(scmUrl);
        } else {
            System.out.println("Unknown SCM for " + plugin.getKey() + ":" + plugin.getVersion());
        }
        if (project.getLicenses() != null && project.getLicenses().size() > 0) {
            plugin.setLicense(project.getLicenses().get(0).getName());
        } else {
            System.out.println("Unknown License for " + plugin.getKey() + ":" + plugin.getVersion());
        }
        if (project.getDevelopers().size() > 0) {
            plugin.setDevelopers(project.getDevelopers());
        } else {
            System.out.println("Unknown Developers for " + plugin.getKey() + ":" + plugin.getVersion());
        }
    }
    return history;
}

From source file:org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.java

License:Open Source License

/**
 * For SONAR-3676/*from w  w  w.j  a v a2  s.  c  om*/
 */
private static void convertMavenLinksToProperties(Properties props, MavenProject pom) {
    setPropertyIfNotAlreadyExists(props, LINKS_HOME_PAGE, pom.getUrl());

    Scm scm = pom.getScm();
    if (scm == null) {
        scm = new Scm();
    }
    setPropertyIfNotAlreadyExists(props, LINKS_SOURCES, scm.getUrl());
    setPropertyIfNotAlreadyExists(props, LINKS_SOURCES_DEV, scm.getDeveloperConnection());

    CiManagement ci = pom.getCiManagement();
    if (ci == null) {
        ci = new CiManagement();
    }
    setPropertyIfNotAlreadyExists(props, LINKS_CI, ci.getUrl());

    IssueManagement issues = pom.getIssueManagement();
    if (issues == null) {
        issues = new IssueManagement();
    }
    setPropertyIfNotAlreadyExists(props, LINKS_ISSUE_TRACKER, issues.getUrl());
}