Add a jira-roadmap report.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@367705 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
ltheussl 2006-01-10 17:52:11 +00:00
parent 594db1221b
commit 4a2a8c45ab
6 changed files with 142 additions and 20 deletions

View File

@ -32,10 +32,19 @@
pluginName="maven-jira-plugin" pluginName="maven-jira-plugin"
link="jira" link="jira"
description="Report all issues defined in Jira."/> description="Report all issues defined in Jira."/>
<j:if test="${maven.jira.roadmap}">
<doc:registerReport
name="Jira Roadmap Report"
pluginName=""
link="jira-roadmap"
description="Report all issues that are scheduled for the next release."
/>
</j:if>
</goal> </goal>
<goal name="maven-jira-plugin:deregister"> <goal name="maven-jira-plugin:deregister">
<doc:deregisterReport name="Jira Report"/> <doc:deregisterReport name="Jira Report"/>
<doc:deregisterReport name="Jira Roadmap Report"/>
</goal> </goal>
<define:taglib uri="jira"> <define:taglib uri="jira">
@ -50,7 +59,7 @@
name="maven-jira-plugin:report" name="maven-jira-plugin:report"
description="Generate report with all entries defined in Jira"> description="Generate report with all entries defined in Jira">
<mkdir dir="${maven.build.dir}/jira"/> <mkdir dir="${maven.build.dir}/jira"/>
<jira:jira <jira:jira
project="${pom}" project="${pom}"
output="${maven.build.dir}/jira/jira-results.xml" output="${maven.build.dir}/jira/jira-results.xml"
@ -64,11 +73,17 @@
jiraUser="${maven.jira.jiraUser}" jiraUser="${maven.jira.jiraUser}"
jiraPassword="${maven.jira.jiraPassword}" jiraPassword="${maven.jira.jiraPassword}"
component="${maven.jira.component}" component="${maven.jira.component}"
roadmap="${maven.jira.roadmap}"
/> />
<mkdir dir="${maven.gen.docs}"/> <mkdir dir="${maven.gen.docs}"/>
<j:catch var="parseresult"> <j:catch var="parseresult">
<j:set var="title" value="Jira Report"/>
<j:set var="description" value="Report all issues defined in Jira."/>
<j:remove var="roadmapUrl"/>
<doc:jslFile <doc:jslFile
input="${maven.build.dir}/jira/jira-results.xml" input="${maven.build.dir}/jira/jira-results.xml"
output="${maven.gen.docs}/jira.xml" output="${maven.gen.docs}/jira.xml"
@ -94,7 +109,44 @@
</copy> </copy>
</j:otherwise> </j:otherwise>
</j:choose> </j:choose>
<j:if test="${maven.jira.roadmap}">
<j:catch var="parseresult">
<j:set var="title" value="Jira Roadmap Report"/>
<j:set var="description" value="Report all issues that are scheduled for the next release."/>
<j:set var="roadmapUrl" value="${pom.issueTrackingUrl}?report=com.atlassian.jira.plugin.system.project:roadmap-panel"/>
<doc:jslFile
input="${maven.build.dir}/jira/jira-roadmap.xml"
output="${maven.gen.docs}/jira-roadmap.xml"
stylesheet="${plugin.resources}/jira.jsl"
outputMode="xml"
prettyPrint="true"
/>
<j:remove var="roadmapUrl"/>
</j:catch>
<!-- FIXME: Hack, taken from announcement/plugin.jelly -->
<ant:replace file="${maven.gen.docs}/jira-roadmap.xml" token="&amp;amp;" value="&amp;"/>
<j:choose>
<j:when test="${!empty(parseresult)}">
<ant:echo>Error: unable to parse jira results due to an error: ${parseresult.message}. Jira roadmap report will not be generated</ant:echo>
</j:when>
<j:otherwise>
<!-- go on -->
<copy todir="${maven.docs.dest}/images/jira" overwrite="no" filtering="no">
<fileset dir="${plugin.resources}/images">
<include name="**/*.gif"/>
</fileset>
</copy>
</j:otherwise>
</j:choose>
</j:if>
</goal> </goal>
</project> </project>

View File

@ -27,3 +27,4 @@ maven.jira.status=Open,In Progress,Reopened
maven.jira.resolution=Unresolved maven.jira.resolution=Unresolved
maven.jira.priority= maven.jira.priority=
maven.jira.component= maven.jira.component=
maven.jira.roadmap=true

View File

@ -90,6 +90,10 @@ public final class JiraDownloader {
/** The maven project. */ /** The maven project. */
private Project project; private Project project;
/** Include a Jira roadmap. */
private boolean roadmap;
/** Mapping containing all JIRA status values. */ /** Mapping containing all JIRA status values. */
private static Map statusMap = new HashMap(); private static Map statusMap = new HashMap();
@ -212,7 +216,7 @@ public final class JiraDownloader {
if (pos >= 0) { if (pos >= 0) {
// url // url
id = url.substring(url.lastIndexOf("=") + 1); id = url.substring(url.lastIndexOf("=") + 1);
} }
String jiraUrl = url.substring(0, url.lastIndexOf("/")); String jiraUrl = url.substring(0, url.lastIndexOf("/"));
if (jiraUrl.endsWith("secure") || jiraUrl.endsWith("browse")) { if (jiraUrl.endsWith("secure") || jiraUrl.endsWith("browse")) {
@ -220,26 +224,37 @@ public final class JiraDownloader {
} }
log.info("Jira lives at: " + jiraUrl); log.info("Jira lives at: " + jiraUrl);
doAuthentication(cl, jiraUrl); doAuthentication(cl, jiraUrl);
String projectPage = "";
if (id == null) {
GetMethod gm = new GetMethod(url); if ( id == null || roadmap)
log.info("Jira URL " + url + " doesn't include a pid, trying to get it"); {
try { GetMethod gm = new GetMethod( url + "?report=com.atlassian.jira.plugin.system.project:roadmap-panel" );
try
{
cl.executeMethod(gm); cl.executeMethod(gm);
log.info("Succesfully reached JIRA."); log.info("Succesfully reached JIRA.");
} }
catch (Exception e) { catch (Exception e)
if (log.isDebugEnabled()) { {
if (log.isDebugEnabled())
{
log.error("Unable to reach JIRA project page:", e); log.error("Unable to reach JIRA project page:", e);
} }
else { else
{
log.error("Unable to reach JIRA project page. Cause is: " + e.getLocalizedMessage()); log.error("Unable to reach JIRA project page. Cause is: " + e.getLocalizedMessage());
} }
} }
String projectPage = gm.getResponseBodyAsString(); projectPage = gm.getResponseBodyAsString();
}
if ( id == null )
{
log.info("Jira URL " + url + " doesn't include a pid, trying to get it");
int pidIndex = projectPage.indexOf("pid="); // @todo, a safer way to get the PID int pidIndex = projectPage.indexOf("pid="); // @todo, a safer way to get the PID
if (pidIndex == -1) { if (pidIndex == -1)
{
// fail // fail
log.error("Unable to get JIRA pid using url " + project.getIssueTrackingUrl()); log.error("Unable to get JIRA pid using url " + project.getIssueTrackingUrl());
return; return;
@ -249,7 +264,6 @@ public final class JiraDownloader {
Number pidNumber = nf.parse(projectPage, new ParsePosition(pidIndex + 4)); Number pidNumber = nf.parse(projectPage, new ParsePosition(pidIndex + 4));
id = Integer.toString(pidNumber.intValue()); id = Integer.toString(pidNumber.intValue());
} }
// create the URL for getting the proper iussues from JIRA // create the URL for getting the proper iussues from JIRA
String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" + id; String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" + id;
@ -257,7 +271,33 @@ public final class JiraDownloader {
fullURL += "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none"; fullURL += "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none";
// execute the GET // execute the GET
download(cl, fullURL); download(cl, fullURL, output);
if ( roadmap )
{
int fixforIndex = projectPage.indexOf("fixfor="); // @todo, a safer way to get the PID
if (fixforIndex == -1)
{
// fail
log.error("Unable to get JIRA roadmap using url " + project.getIssueTrackingUrl());
return;
}
NumberFormat nf = NumberFormat.getInstance();
Number fixforNumber = nf.parse(projectPage, new ParsePosition(fixforIndex + 7));
String fixfor = Integer.toString(fixforNumber.intValue());
setFilter("&&fixfor=" + fixfor + "&sorter/field=status&sorter/order=ASC");
fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" + id;
fullURL += createFilter();
fullURL += "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none";
String outFile = output.getAbsolutePath();
int endIndex = outFile.lastIndexOf( '/' );
outFile = outFile.substring( 0, endIndex ) + "/jira-roadmap.xml";
// execute the GET
download(cl, fullURL, new File( outFile ) );
}
} catch (Exception e) { } catch (Exception e) {
log.error("Error accessing " + project.getIssueTrackingUrl(), e); log.error("Error accessing " + project.getIssueTrackingUrl(), e);
} }
@ -349,7 +389,7 @@ public final class JiraDownloader {
* the JiraUrl * the JiraUrl
* @return * @return
*/ */
private void download(final HttpClient cl, final String link) { private void download(final HttpClient cl, final String link, final File outFile) {
try { try {
GetMethod gm = new GetMethod(link); GetMethod gm = new GetMethod(link);
log.info("Downloading " + link); log.info("Downloading " + link);
@ -357,7 +397,7 @@ public final class JiraDownloader {
cl.executeMethod(gm); cl.executeMethod(gm);
final String strGetResponseBody = gm.getResponseBodyAsString(); final String strGetResponseBody = gm.getResponseBodyAsString();
// write the reponse to file // write the reponse to file
PrintWriter pw = new PrintWriter(new FileWriter(output)); PrintWriter pw = new PrintWriter(new FileWriter(outFile));
pw.print(strGetResponseBody); pw.print(strGetResponseBody);
pw.close(); pw.close();
StatusLine sl = gm.getStatusLine(); StatusLine sl = gm.getStatusLine();
@ -374,7 +414,7 @@ public final class JiraDownloader {
} else { } else {
String newLink = locationHeader.getValue(); String newLink = locationHeader.getValue();
log.debug("Following redirect to " + newLink); log.debug("Following redirect to " + newLink);
download(cl, newLink); download(cl, newLink, outFile);
} }
} }
@ -516,4 +556,12 @@ public final class JiraDownloader {
this.component = theseComponents; this.component = theseComponents;
} }
/**
* Sets the roadmap property.
* @param thisRoadmap The roadmap.
*/
public void setRoadmap(final boolean thisRoadmap) {
this.roadmap = thisRoadmap;
}
} }

View File

@ -32,10 +32,17 @@
<jsl:template match="rss"> <jsl:template match="rss">
<document> <document>
<properties> <properties>
<title>Jira Report</title> <title>${title}</title>
</properties> </properties>
<body> <body>
<section name="Jira Report"> <section name="${title}">
<p>
${description}
<j:if test="${roadmapUrl != null}">
For the latest list, please check the Jira
<a href="${roadmapUrl}">roadmap</a>.
</j:if>
</p>
<x:forEach var="entry" select="channel"> <x:forEach var="entry" select="channel">
<table> <table>
<thead> <thead>

View File

@ -24,6 +24,7 @@
</properties> </properties>
<body> <body>
<release version="1.3-SNAPSHOT" date="in SVN"> <release version="1.3-SNAPSHOT" date="in SVN">
<action dev="ltheussl" type="add">Add a jira-roadmap report.</action>
<action dev="ltheussl" type="update">Layout changes: mimic default JIRA appearance, also show votes.</action> <action dev="ltheussl" type="update">Layout changes: mimic default JIRA appearance, also show votes.</action>
<action dev="aheritier" type="fix">Icons are corrupted (images are filtered during the copy).</action> <action dev="aheritier" type="fix">Icons are corrupted (images are filtered during the copy).</action>
</release> </release>

View File

@ -164,6 +164,19 @@
</td> </td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>maven.jira.roadmap</td>
<td>Yes</td>
<td>
<p>
If set to <code>true</code>, a report on issues in the Jira
roadmap is generated. This includes issues
that are fixed in the current development version and issues
that are scheduled to be fixed in the next release.
</p>
</td>
<td><p><code>true</code></p></td>
</tr>
</table> </table>
</section> </section>
</body> </body>