Search in sources :

Example 1 with Release

use of org.apache.maven.plugins.changes.model.Release in project maven-plugins by apache.

the class AnnouncementMojo method execute.

// =======================================//
// announcement-generate execution //
// =======================================//
/**
     * Generate the template
     *
     * @throws MojoExecutionException in case of errors
     */
public void execute() throws MojoExecutionException {
    // Fail build fast if it is using deprecated parameters
    failIfUsingDeprecatedParameter(outputDirectory, "outputDirectory", "announcementDirectory");
    failIfUsingDeprecatedParameter(generateJiraAnnouncement, "generateJiraAnnouncement", "issueManagementSystems ");
    failIfUsingDeprecatedParameter(jiraMerge, "jiraMerge", "issueManagementSystems ");
    // Run only at the execution root
    if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
        getLog().info("Skipping the announcement generation in this project because it's not the Execution Root");
    } else {
        if (issueManagementSystems == null) {
            issueManagementSystems = new ArrayList<String>();
        }
        if (issueManagementSystems.isEmpty()) {
            issueManagementSystems.add(CHANGES_XML);
        }
        // Fetch releases from the configured issue management systems
        List<Release> releases = null;
        if (issueManagementSystems.contains(CHANGES_XML)) {
            if (getXmlPath().exists()) {
                ChangesXML changesXML = new ChangesXML(getXmlPath(), getLog());
                List<Release> changesReleases = changesXML.getReleaseList();
                releases = releaseUtils.mergeReleases(null, changesReleases);
                getLog().info("Including issues from file " + getXmlPath() + " in announcement...");
            } else {
                getLog().warn("changes.xml file " + getXmlPath().getAbsolutePath() + " does not exist.");
            }
        }
        if (issueManagementSystems.contains(JIRA)) {
            String message = ProjectUtils.validateIssueManagement(project, JIRA, "JIRA announcement");
            if (message == null) {
                List<Release> jiraReleases = getJiraReleases();
                releases = releaseUtils.mergeReleases(releases, jiraReleases);
                getLog().info("Including issues from JIRA in announcement...");
            } else {
                throw new MojoExecutionException("Something is wrong with the Issue Management section. " + message);
            }
        }
        if (issueManagementSystems.contains(TRAC)) {
            String message = ProjectUtils.validateIssueManagement(project, TRAC, "Trac announcement");
            if (message == null) {
                List<Release> tracReleases = getTracReleases();
                releases = releaseUtils.mergeReleases(releases, tracReleases);
                getLog().info("Including issues from Trac in announcement...");
            } else {
                throw new MojoExecutionException("Something is wrong with the Issue Management section. " + message);
            }
        }
        if (issueManagementSystems.contains(GIT_HUB)) {
            String message = ProjectUtils.validateIssueManagement(project, GIT_HUB, "GitHub announcement");
            if (message == null) {
                List<Release> gitHubReleases = getGitHubReleases();
                releases = releaseUtils.mergeReleases(releases, gitHubReleases);
                getLog().info("Including issues from GitHub in announcement...");
            } else {
                throw new MojoExecutionException("Something is wrong with the Issue Management section. " + message);
            }
        }
        // Generate the report
        if (releases == null || releases.isEmpty()) {
            throw new MojoExecutionException("No releases found in any of the " + "configured issue management systems.");
        } else {
            doGenerate(releases);
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ChangesXML(org.apache.maven.plugins.changes.ChangesXML) Release(org.apache.maven.plugins.changes.model.Release)

Example 2 with Release

use of org.apache.maven.plugins.changes.model.Release in project maven-plugins by apache.

the class ChangesReportGenerator method constructReleaseHistory.

private void constructReleaseHistory(Sink sink, ResourceBundle bundle, List<Release> releaseList) {
    sink.section2();
    sink.sectionTitle2();
    sink.text(bundle.getString("report.changes.label.releasehistory"));
    sink.sectionTitle2_();
    sink.table();
    sink.tableRow();
    sinkHeader(sink, bundle.getString("report.issues.label.fixVersion"));
    sinkHeader(sink, bundle.getString("report.changes.label.releaseDate"));
    sinkHeader(sink, bundle.getString("report.changes.label.releaseDescription"));
    sink.tableRow_();
    for (Release release : releaseList) {
        sink.tableRow();
        sinkCellLink(sink, release.getVersion(), "#" + HtmlTools.encodeId(release.getVersion()));
        sinkCell(sink, release.getDateRelease());
        sinkCell(sink, release.getDescription());
        sink.tableRow_();
    }
    sink.table_();
    // MCHANGES-46
    if (linkToFeed) {
        sink.paragraph();
        sink.text(bundle.getString("report.changes.text.rssfeed"));
        sink.nonBreakingSpace();
        sink.link("changes.rss");
        sinkFigure(sink, "images/rss.png", "rss feed");
        sink.link_();
        sink.paragraph_();
    }
    sink.section2_();
}
Also used : Release(org.apache.maven.plugins.changes.model.Release)

Example 3 with Release

use of org.apache.maven.plugins.changes.model.Release in project maven-plugins by apache.

the class ReleaseUtils method mergeReleases.

/**
     * Merge releases from one issue tracker with releases from another issue tracker. If a release is found in both
     * issue trackers, i.e. they have the same version, their issues are merged into one release.
     *
     * @param firstReleases Releases from the first issue tracker
     * @param secondReleases Releases from the second issue tracker
     * @return A list containing the merged releases
     */
public List<Release> mergeReleases(final List<Release> firstReleases, final List<Release> secondReleases) {
    if (firstReleases == null && secondReleases == null) {
        return Collections.emptyList();
    }
    if (firstReleases == null) {
        return secondReleases;
    }
    if (secondReleases == null) {
        return firstReleases;
    }
    List<Release> mergedReleases = new ArrayList<Release>();
    // tracker
    for (Release firstRelease : firstReleases) {
        Release secondRelease = getRelease(secondReleases, firstRelease.getVersion());
        if (secondRelease != null) {
            if (secondRelease.getActions() != null) {
                firstRelease.getActions().addAll(secondRelease.getActions());
            }
        }
        mergedReleases.add(firstRelease);
    }
    // Handle releases that are only in the second issue tracker
    for (Release secondRelease : secondReleases) {
        Release mergedRelease = getRelease(mergedReleases, secondRelease.getVersion());
        if (mergedRelease == null) {
            mergedReleases.add(secondRelease);
        }
    }
    return mergedReleases;
}
Also used : ArrayList(java.util.ArrayList) Release(org.apache.maven.plugins.changes.model.Release)

Example 4 with Release

use of org.apache.maven.plugins.changes.model.Release in project maven-plugins by apache.

the class ReleaseUtils method getLatestRelease.

/**
     * Get the latest release by matching the supplied releases with the version from the pom.
     *
     * @param releases list of releases
     * @param pomVersion Version of the artifact
     * @return A <code>Release</code> that matches the next release of the current project
     * @throws org.apache.maven.plugin.MojoExecutionException If a release can't be found
     */
public Release getLatestRelease(List<Release> releases, String pomVersion) throws MojoExecutionException {
    // Remove "-SNAPSHOT" from the end, if it's there
    if (pomVersion != null && pomVersion.endsWith(SNAPSHOT_SUFFIX)) {
        pomVersion = pomVersion.substring(0, pomVersion.length() - SNAPSHOT_SUFFIX.length());
    }
    getLog().debug("Found " + releases.size() + " releases.");
    Release release = getRelease(releases, pomVersion);
    if (release == null) {
        throw new MojoExecutionException("Couldn't find the release '" + pomVersion + "' among the supplied releases: " + toString(releases));
    }
    return release;
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Release(org.apache.maven.plugins.changes.model.Release)

Example 5 with Release

use of org.apache.maven.plugins.changes.model.Release in project maven-plugins by apache.

the class ReleaseUtils method getRelease.

/**
     * Get a release with the specified version from the list of releases.
     *
     * @param releases A list of releases
     * @param version The version we want
     * @return A Release, or null if no release with the specified version can be found
     */
protected Release getRelease(List<Release> releases, String version) {
    for (Release release : releases) {
        if (getLog().isDebugEnabled()) {
            getLog().debug("The release: " + release.getVersion() + " has " + release.getActions().size() + " actions.");
        }
        if (release.getVersion() != null && release.getVersion().equals(version)) {
            if (getLog().isDebugEnabled()) {
                getLog().debug("Found the correct release: " + release.getVersion());
                logRelease(release);
            }
            return release;
        }
    }
    return null;
}
Also used : Release(org.apache.maven.plugins.changes.model.Release)

Aggregations

Release (org.apache.maven.plugins.changes.model.Release)12 ArrayList (java.util.ArrayList)6 File (java.io.File)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 ChangesXML (org.apache.maven.plugins.changes.ChangesXML)2 Action (org.apache.maven.plugins.changes.model.Action)2 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)1 SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Properties (java.util.Properties)1 CaseInsensitiveMap (org.apache.commons.collections.map.CaseInsensitiveMap)1 Log (org.apache.maven.plugin.logging.Log)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1 FeedGenerator (org.apache.maven.plugins.changes.FeedGenerator)1