Search in sources :

Example 6 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 parent component with releases from child component. If a release is found in both
     * components, i.e. they have the same version, their issues are merged into one (parent) release with component
     * marker for component issues.
     *
     * @param releases Releases from the parent component
     * @param componentName child component name (retrieved from project name)
     * @param componentReleases Releases from the child component
     * @return A list containing the merged releases
     */
public List<Release> mergeReleases(final List<Release> releases, final String componentName, final List<Release> componentReleases) {
    if (releases == null && componentReleases == null) {
        return Collections.emptyList();
    }
    if (componentReleases == null) {
        return releases;
    }
    final List<Release> mergedReleases = new ArrayList<Release>();
    if (releases != null) {
        for (Object release1 : releases) {
            final Release release = (Release) release1;
            final Release componentRelease = getRelease(componentReleases, release.getVersion());
            if (componentRelease != null) {
                release.addComponent(componentName, componentRelease);
            }
            mergedReleases.add(release);
        }
    }
    for (Object componentRelease1 : componentReleases) {
        final Release release = (Release) componentRelease1;
        final Release mergedRelease = getRelease(mergedReleases, release.getVersion());
        if (mergedRelease == null) {
            final Release componentRelease = new Release();
            componentRelease.setVersion(release.getVersion());
            componentRelease.setDateRelease(release.getDateRelease());
            componentRelease.addComponent(componentName, release);
            mergedReleases.add(componentRelease);
        }
    }
    return mergedReleases;
}
Also used : ArrayList(java.util.ArrayList) Release(org.apache.maven.plugins.changes.model.Release)

Example 7 with Release

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

the class ChangesMojo method executeReport.

public void executeReport(Locale locale) throws MavenReportException {
    failIfUsingDeprecatedParameter(escapeHTML, "escapeHTML", "Using markup inside CDATA sections does not work for all output formats!");
    failIfUsingDeprecatedParameter(issueLinkTemplate, "issueLinkTemplate", "You must use 'issueLinkTemplatePerSystem' for the system '" + ChangesReportGenerator.DEFAULT_ISSUE_SYSTEM_KEY + "' instead.");
    Date now = new Date();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(publishDateFormat, new Locale(publishDateLocale));
    Properties additionalProperties = new Properties();
    additionalProperties.put("publishDate", simpleDateFormat.format(now));
    ChangesXML changesXml = getChangesFromFile(xmlPath, project, additionalProperties);
    if (changesXml == null) {
        return;
    }
    if (aggregated) {
        final String basePath = project.getBasedir().getAbsolutePath();
        final String absolutePath = xmlPath.getAbsolutePath();
        if (!absolutePath.startsWith(basePath)) {
            getLog().warn("xmlPath should be within the project dir for aggregated changes report.");
            return;
        }
        final String relativePath = absolutePath.substring(basePath.length());
        List<Release> releaseList = changesXml.getReleaseList();
        for (Object o : project.getCollectedProjects()) {
            final MavenProject childProject = (MavenProject) o;
            final File changesFile = new File(childProject.getBasedir(), relativePath);
            final ChangesXML childXml = getChangesFromFile(changesFile, childProject, additionalProperties);
            if (childXml != null) {
                releaseList = releaseUtils.mergeReleases(releaseList, childProject.getName(), childXml.getReleaseList());
            }
        }
        changesXml.setReleaseList(releaseList);
    }
    ChangesReportGenerator report = new ChangesReportGenerator(changesXml.getReleaseList());
    report.setAuthor(changesXml.getAuthor());
    report.setTitle(changesXml.getTitle());
    report.setEscapeHTML(true);
    // We need something case insensitive to maintain backward compatibility
    if (issueLinkTemplatePerSystem == null) {
        caseInsensitiveIssueLinkTemplatePerSystem = new CaseInsensitiveMap();
    } else {
        caseInsensitiveIssueLinkTemplatePerSystem = new CaseInsensitiveMap(issueLinkTemplatePerSystem);
    }
    // Set good default values for issue management systems here
    addIssueLinkTemplate(ChangesReportGenerator.DEFAULT_ISSUE_SYSTEM_KEY, "%URL%/ViewIssue.jspa?key=%ISSUE%");
    addIssueLinkTemplate("Bitbucket", "%URL%/issue/%ISSUE%");
    addIssueLinkTemplate("Bugzilla", "%URL%/show_bug.cgi?id=%ISSUE%");
    addIssueLinkTemplate("GitHub", "%URL%/%ISSUE%");
    addIssueLinkTemplate("GoogleCode", "%URL%/detail?id=%ISSUE%");
    addIssueLinkTemplate("JIRA", "%URL%/%ISSUE%");
    addIssueLinkTemplate("Mantis", "%URL%/view.php?id=%ISSUE%");
    addIssueLinkTemplate("MKS", "%URL%/viewissue?selection=%ISSUE%");
    addIssueLinkTemplate("Redmine", "%URL%/issues/show/%ISSUE%");
    addIssueLinkTemplate("Scarab", "%URL%/issues/id/%ISSUE%");
    addIssueLinkTemplate("SourceForge", "http://sourceforge.net/support/tracker.php?aid=%ISSUE%");
    addIssueLinkTemplate("SourceForge2", "%URL%/%ISSUE%");
    addIssueLinkTemplate("Trac", "%URL%/ticket/%ISSUE%");
    addIssueLinkTemplate("Trackplus", "%URL%/printItem.action?key=%ISSUE%");
    addIssueLinkTemplate("YouTrack", "%URL%/issue/%ISSUE%");
    // @todo Add more issue management systems here
    // Remember to also add documentation in usage.apt.vm
    // Show the current issueLinkTemplatePerSystem configuration
    logIssueLinkTemplatePerSystem(caseInsensitiveIssueLinkTemplatePerSystem);
    report.setIssueLinksPerSystem(caseInsensitiveIssueLinkTemplatePerSystem);
    report.setSystem(system);
    report.setTeamlist(teamlist);
    report.setUrl(url);
    report.setAddActionDate(addActionDate);
    if (StringUtils.isEmpty(url)) {
        getLog().warn("No issue management URL defined in POM. Links to your issues will not work correctly.");
    }
    boolean feedGenerated = false;
    if (StringUtils.isNotEmpty(feedType)) {
        feedGenerated = generateFeed(changesXml, locale);
    }
    report.setLinkToFeed(feedGenerated);
    report.doGenerateReport(getBundle(locale), getSink());
    // Copy the images
    copyStaticResources();
}
Also used : Locale(java.util.Locale) Properties(java.util.Properties) Date(java.util.Date) CaseInsensitiveMap(org.apache.commons.collections.map.CaseInsensitiveMap) MavenProject(org.apache.maven.project.MavenProject) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Release(org.apache.maven.plugins.changes.model.Release)

Example 8 with Release

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

the class FeedGenerator method getEntries.

private List<SyndEntry> getEntries(final List<Release> releases) {
    final List<SyndEntry> entries = new ArrayList<SyndEntry>(1);
    if (releases.size() > 0) {
        // TODO: is this guaranteed to be the latest?
        final Release release = releases.get(0);
        final SyndEntry entry = new SyndEntryImpl();
        entry.setTitle(release.getVersion());
        entry.setLink(link + "#" + HtmlTools.encodeId(release.getVersion()));
        entry.setDescription(getSyndContent(release));
        entry.setPublishedDate(getDate(release.getDateRelease(), dateFormat));
        entries.add(entry);
    }
    return entries;
}
Also used : SyndEntry(com.sun.syndication.feed.synd.SyndEntry) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList) Release(org.apache.maven.plugins.changes.model.Release)

Example 9 with Release

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

the class IssueAdapter method getReleases.

/**
     * Adapt a <code>List</code> of <code>Issue</code>s to a <code>List</code> of <code>Release</code>s.
     *
     * @param issues The issues
     * @return A list of releases
     */
public List<Release> getReleases(List<Issue> issues) {
    // A Map of releases keyed by fixVersion
    Map<String, Release> releasesMap = new HashMap<String, Release>();
    // Loop through all issues looking for fixVersions
    for (Issue issue : issues) {
        // Do NOT create a release for issues that lack a fixVersion
        if (issue.getFixVersions() != null) {
            for (String fixVersion : issue.getFixVersions()) {
                // Try to get a matching Release from the map
                Release release = releasesMap.get(fixVersion);
                if (release == null) {
                    // Add a new Release to the Map if it wasn't there
                    release = new Release();
                    release.setVersion(fixVersion);
                    releasesMap.put(fixVersion, release);
                }
                // Add this issue as an Action to this release
                Action action = createAction(issue);
                release.addAction(action);
            }
        }
    }
    // Extract the releases from the Map to a List
    List<Release> releasesList = new ArrayList<Release>();
    for (Release release : releasesMap.values()) {
        releasesList.add(release);
    }
    return releasesList;
}
Also used : Action(org.apache.maven.plugins.changes.model.Action) Issue(org.apache.maven.plugins.issues.Issue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Release(org.apache.maven.plugins.changes.model.Release)

Example 10 with Release

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

the class ChangesXMLTest method testParseChangesFile.

public void testParseChangesFile() throws Exception {
    File changesFile = new File(getBasedir() + "/src/test/unit/changes.xml");
    ChangesXML changesXML = new ChangesXML(changesFile, new MockLog());
    assertNotNull(changesXML.getChangesDocument());
    assertEquals("Changes report Project", changesXML.getTitle());
    List<Release> releases = changesXML.getReleaseList();
    assertEquals(2, releases.size());
    for (Release release : releases) {
        if ("1.0".equals(release.getVersion())) {
            Action action = release.getActions().get(0);
            assertEquals(2, action.getFixedIssues().size());
            assertEquals("JIRA-XXX", action.getFixedIssues().get(0).getIssue());
            assertEquals("JIRA-YYY", action.getFixedIssues().get(1).getIssue());
            assertEquals(2, action.getDueTos().size());
        }
    }
}
Also used : Action(org.apache.maven.plugins.changes.model.Action) ChangesXML(org.apache.maven.plugins.changes.ChangesXML) File(java.io.File) 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