Search in sources :

Example 1 with ChangesXML

use of org.apache.maven.plugins.changes.ChangesXML 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 ChangesXML

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

the class ChangesXMLTest method testParseInvalidChangesFile.

public void testParseInvalidChangesFile() {
    File changesFile = new File(getBasedir() + "/src/test/unit/invalid-changes.xml");
    try {
        new ChangesXML(changesFile, new MockLog());
        fail("Should have thrown a ChangesXMLRuntimeException due to the invalid changes.xml file");
    } catch (ChangesXMLRuntimeException e) {
        assertEquals("An error occurred when parsing the changes.xml file", e.getMessage());
    } catch (Throwable e) {
        fail("Wrong type of Throwable object was thrown, expected ChangesXMLRuntimeException");
    }
}
Also used : ChangesXML(org.apache.maven.plugins.changes.ChangesXML) File(java.io.File) ChangesXMLRuntimeException(org.apache.maven.plugins.changes.ChangesXMLRuntimeException)

Example 3 with ChangesXML

use of org.apache.maven.plugins.changes.ChangesXML 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

ChangesXML (org.apache.maven.plugins.changes.ChangesXML)3 File (java.io.File)2 Release (org.apache.maven.plugins.changes.model.Release)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ChangesXMLRuntimeException (org.apache.maven.plugins.changes.ChangesXMLRuntimeException)1 Action (org.apache.maven.plugins.changes.model.Action)1