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);
}
}
}
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");
}
}
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());
}
}
}
Aggregations