Initial version of jira issues status report
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114671 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
5
jira/.cvsignore
Normal file
5
jira/.cvsignore
Normal file
@@ -0,0 +1,5 @@
|
||||
target
|
||||
velocity.log
|
||||
maven.log
|
||||
.classpath
|
||||
.project
|
||||
3
jira/maven.xml
Normal file
3
jira/maven.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<project default="jar:jar">
|
||||
|
||||
</project>
|
||||
56
jira/plugin.jelly
Normal file
56
jira/plugin.jelly
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:define="jelly:define"
|
||||
xmlns:jira="jira"
|
||||
xmlns:maven="jelly:maven"
|
||||
xmlns:doc="doc">
|
||||
|
||||
<goal name="maven-jira-plugin:register">
|
||||
<doc:registerReport
|
||||
name="Jira Report"
|
||||
pluginName="maven-jira-plugin"
|
||||
link="linkcheck"
|
||||
description="Report all issues defined in Jira."/>
|
||||
</goal>
|
||||
|
||||
<goal name="maven-jira-plugin:deregister">
|
||||
<doc:deregisterReport name="Jira Report"/>
|
||||
</goal>
|
||||
|
||||
<define:taglib uri="jira">
|
||||
<define:jellybean
|
||||
name="jira"
|
||||
className="org.apache.maven.jira.JiraDownloader"
|
||||
method="doExecute"
|
||||
/>
|
||||
</define:taglib>
|
||||
|
||||
<goal
|
||||
name="maven-jira-plugin:report"
|
||||
description="Generate report with all entries defined in Jira">
|
||||
<mkdir dir="${maven.build.dir}/jira"/>
|
||||
|
||||
<jira:jira
|
||||
project="${pom}"
|
||||
output="${maven.build.dir}/jira/jira-results.xml"
|
||||
nbEntries="${maven.jira.nbentries}"
|
||||
/>
|
||||
|
||||
<doc:jslFile
|
||||
input="${maven.build.dir}/jira/jira-results.xml"
|
||||
output="${maven.gen.docs}/jira.xml"
|
||||
stylesheet="${plugin.resources}/jira.jsl"
|
||||
outputMode="xml"
|
||||
prettyPrint="true"
|
||||
/>
|
||||
|
||||
<copy todir="${maven.docs.dest}/images/jira" overwrite="yes" filtering="yes">
|
||||
<fileset dir="${plugin.resources}/images">
|
||||
<include name="**/*.gif"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
4
jira/plugin.properties
Normal file
4
jira/plugin.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
# -------------------------------------------------------------------
|
||||
# P L U G I N P R O P E R I E S
|
||||
# -------------------------------------------------------------------
|
||||
maven.jira.nbentries=1000
|
||||
9
jira/project.properties
Normal file
9
jira/project.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
# -------------------------------------------------------------------
|
||||
# P R O J E C T P R O P E R T I E S
|
||||
# -------------------------------------------------------------------
|
||||
maven.xdoc.date=left
|
||||
## maven.xdoc.version=${pom.currentVersion}
|
||||
maven.license.licenseFile=${basedir}/../LICENSE.txt
|
||||
maven.checkstyle.header.file=${basedir}/../LICENSE.txt
|
||||
maven.checkstyle.format = turbine
|
||||
maven.checkstyle.properties = ${basedir}/../checkstyle.xml
|
||||
46
jira/project.xml
Normal file
46
jira/project.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project>
|
||||
<extend>../project.xml</extend>
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>maven-jira-plugin</id>
|
||||
<name>Maven JIRA Plug-in</name>
|
||||
<currentVersion>1.0-SNAPSHOT</currentVersion>
|
||||
<description/>
|
||||
<shortDescription>Download issue from Jira</shortDescription>
|
||||
<url>http://maven.apache.org/reference/plugins/jira/</url>
|
||||
<siteDirectory>/www/maven.apache.org/reference/plugins/jira/</siteDirectory>
|
||||
<repository>
|
||||
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven/src/plugins-build/jira/</connection>
|
||||
<url>http://cvs.apache.org/viewcvs/maven/src/plugins-build/jira/</url>
|
||||
</repository>
|
||||
<developers/>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>2.0-rc2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly</artifactId>
|
||||
<version>20030902.160215</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- Required for commons-httpclient -->
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven</artifactId>
|
||||
<version>1.0-rc1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
239
jira/src/main/org/apache/maven/jira/JiraDownloader.java
Normal file
239
jira/src/main/org/apache/maven/jira/JiraDownloader.java
Normal file
@@ -0,0 +1,239 @@
|
||||
package org.apache.maven.jira;
|
||||
|
||||
/* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2003 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||
* "Apache Maven" must not be used to endorse or promote products
|
||||
* derived from this software without prior written permission. For
|
||||
* written permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* "Apache Maven", nor may "Apache" appear in their name, without
|
||||
* prior written permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HostConfiguration;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpState;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.StatusLine;
|
||||
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.apache.maven.jelly.MavenJellyContext;
|
||||
import org.apache.maven.project.Project;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class JiraDownloader
|
||||
{
|
||||
/**
|
||||
* Log for debug output
|
||||
*/
|
||||
private static Log LOG = LogFactory.getLog(JiraDownloader.class);
|
||||
|
||||
/** Output file for xml document */
|
||||
private File output;
|
||||
|
||||
/** Number of entries max */
|
||||
private int nbEntriesMax;
|
||||
|
||||
private Project project;
|
||||
|
||||
/**
|
||||
* Set the output file for the log.
|
||||
* @param output the output file
|
||||
*/
|
||||
public void setOutput(File output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Project
|
||||
*/
|
||||
public Object getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the project.
|
||||
* @param project The project to set
|
||||
*/
|
||||
public void setProject(Object project)
|
||||
{
|
||||
//System.out.println("Setting project: " + project);
|
||||
this.project = (Project) project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of entries.
|
||||
* @param nbEntries The number of entries
|
||||
*/
|
||||
public void setNbEntries(int nbEntries)
|
||||
{
|
||||
nbEntriesMax = nbEntries;
|
||||
}
|
||||
|
||||
public void doExecute() throws Exception
|
||||
{
|
||||
MavenJellyContext ctx;
|
||||
String proxyHost;
|
||||
String proxyPort;
|
||||
String proxyUser;
|
||||
String proxyPass;
|
||||
String link;
|
||||
|
||||
if (getProject() == null)
|
||||
{
|
||||
throw new Exception("No project set.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((Project) getProject()).getIssueTrackingUrl() == null)
|
||||
{
|
||||
throw new Exception("No issue tracking url set.");
|
||||
}
|
||||
else
|
||||
{
|
||||
String url = ((Project) getProject()).getIssueTrackingUrl();
|
||||
int pos = url.indexOf("?");
|
||||
String id = url.substring(pos+4);
|
||||
url = url.substring(0, url.lastIndexOf("/"));
|
||||
link = url + "/secure/IssueNavigator.jspa?view=rss&pid=" + id + "&sorter/field=issuekey&sorter/order=DESC&sorter/field=status&sorter/order=DESC&tempMax=" + String.valueOf(nbEntriesMax) + "&reset=true";
|
||||
}
|
||||
}
|
||||
|
||||
ctx = ((Project) getProject()).getContext();
|
||||
|
||||
proxyHost = ctx.getProxyHost();
|
||||
proxyPort = ctx.getProxyPort();
|
||||
proxyUser = ctx.getProxyUserName();
|
||||
proxyPass = ctx.getProxyPassword();
|
||||
|
||||
try
|
||||
{
|
||||
HttpClient cl = new HttpClient();
|
||||
HostConfiguration hc = new HostConfiguration();
|
||||
|
||||
if (proxyHost != null)
|
||||
{
|
||||
hc.setProxy(proxyHost, Integer.parseInt(proxyPort));
|
||||
}
|
||||
HttpState state = new HttpState();
|
||||
|
||||
if (proxyUser != null && proxyPass != null)
|
||||
{
|
||||
state.setProxyCredentials(null, null, new UsernamePasswordCredentials(proxyUser, proxyPass));
|
||||
}
|
||||
|
||||
cl.setHostConfiguration(hc);
|
||||
cl.setState(state);
|
||||
|
||||
// execute the GET
|
||||
GetMethod gm = download(cl, link);
|
||||
StatusLine sl = gm.getStatusLine();
|
||||
|
||||
if (sl == null) {
|
||||
LOG.info("Unknown error validating link : " + link);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY)
|
||||
{
|
||||
Header locationHeader = gm.getResponseHeader("Location");
|
||||
if (locationHeader == null) {
|
||||
LOG.info("Site sent redirect, but did not set Location header");
|
||||
} else {
|
||||
String newLink = locationHeader.getValue();
|
||||
LOG.debug("Following 1 redirect to " + newLink);
|
||||
gm = download(cl, newLink);
|
||||
}
|
||||
}
|
||||
|
||||
if (gm.getStatusCode() != HttpStatus.SC_OK)
|
||||
{
|
||||
String msg = "Received: [" + gm.getStatusCode() + "] for " + link;
|
||||
LOG.info(msg);
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Error accessing " + link);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private GetMethod download(HttpClient cl, String link)
|
||||
{
|
||||
GetMethod gm = new GetMethod(link);
|
||||
try
|
||||
{
|
||||
System.out.println("Downloading " + link);
|
||||
gm.setFollowRedirects(true);
|
||||
cl.executeMethod(gm);
|
||||
final String strGetResponseBody = gm.getResponseBodyAsString();
|
||||
PrintWriter pw = new PrintWriter(new FileWriter(output));
|
||||
pw.print(strGetResponseBody);
|
||||
pw.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Error downloading " + link);
|
||||
}
|
||||
return gm;
|
||||
}
|
||||
}
|
||||
BIN
jira/src/plugin-resources/images/status_closed.gif
Normal file
BIN
jira/src/plugin-resources/images/status_closed.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 340 B |
BIN
jira/src/plugin-resources/images/status_inprogress.gif
Normal file
BIN
jira/src/plugin-resources/images/status_inprogress.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 341 B |
BIN
jira/src/plugin-resources/images/status_open.gif
Normal file
BIN
jira/src/plugin-resources/images/status_open.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 339 B |
BIN
jira/src/plugin-resources/images/status_reopened.gif
Normal file
BIN
jira/src/plugin-resources/images/status_reopened.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 346 B |
BIN
jira/src/plugin-resources/images/status_resolved.gif
Normal file
BIN
jira/src/plugin-resources/images/status_resolved.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 340 B |
75
jira/src/plugin-resources/jira.jsl
Normal file
75
jira/src/plugin-resources/jira.jsl
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
|
||||
<jsl:stylesheet
|
||||
select="$doc"
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:util="jelly:util"
|
||||
xmlns:jsl="jelly:jsl"
|
||||
xmlns:x="jelly:xml"
|
||||
xmlns="dummy"
|
||||
trim="false">
|
||||
|
||||
<jsl:template match="rss">
|
||||
<document>
|
||||
<properties>
|
||||
<title>Jira Report</title>
|
||||
</properties>
|
||||
<body>
|
||||
<section name="Jira Report">
|
||||
<x:forEach var="entry" select="channel">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:150px">Key</th>
|
||||
<th>Summary</th>
|
||||
<th style="width:150px">Status</th>
|
||||
<th style="width:150px">Resolution</th>
|
||||
<th style="width:150px">By</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<x:forEach var="entry" select="item">
|
||||
<j:set var="key"><x:expr select="$entry/key"/></j:set>
|
||||
<j:set var="link"><x:expr select="$entry/link"/></j:set>
|
||||
<j:set var="status"><x:expr select="$entry/status"/></j:set>
|
||||
<j:set var="summary"><x:expr select="$entry/summary"/></j:set>
|
||||
<j:set var="assignee"><x:expr select="$entry/assignee"/></j:set>
|
||||
<j:set var="resolution"><x:expr select="$entry/resolution"/></j:set>
|
||||
<tr>
|
||||
<td><a href="${link}">${key}</a></td>
|
||||
<td>${summary}</td>
|
||||
<td>
|
||||
<j:choose>
|
||||
<j:when test="${status.equalsIgnoreCase('Closed')}">
|
||||
<img src="./images/jira/status_closed.gif"/>
|
||||
</j:when>
|
||||
<j:when test="${status.equalsIgnoreCase('In Progress')}">
|
||||
<img src="./images/jira/status_inprogress.gif"/>
|
||||
</j:when>
|
||||
<j:when test="${status.equalsIgnoreCase('Open')}">
|
||||
<img src="./images/jira/status_open.gif"/>
|
||||
</j:when>
|
||||
<j:when test="${status.equalsIgnoreCase('Reopened')}">
|
||||
<img src="./images/jira/status_reopened.gif"/>
|
||||
</j:when>
|
||||
<j:when test="${status.equalsIgnoreCase('Resolved')}">
|
||||
<img src="./images/jira/status_resolved.gif"/>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
${status}
|
||||
</td>
|
||||
<td>${resolution}</td>
|
||||
<td>${assignee}</td>
|
||||
</tr>
|
||||
</x:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</x:forEach>
|
||||
</section>
|
||||
</body>
|
||||
</document>
|
||||
</jsl:template>
|
||||
|
||||
</jsl:stylesheet>
|
||||
Reference in New Issue
Block a user