Skip to content

Commit

Permalink
Fixed code inconsistencies with Javadoc, code structure and whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Pigram committed Sep 10, 2013
1 parent 80bb88e commit 5e58750
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 311 deletions.
84 changes: 42 additions & 42 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.foxopen.jira.changelog</groupId>
<artifactId>jira-changelog-builder</artifactId>
<version>1.04.00</version>
<packaging>jar</packaging>

<name>JIRAChangelogBuilder</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>atlassian</id>
<name>Atlassian Public Repository</name>
<layout>default</layout>
<url>http://maven.atlassian.com/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<repositories>
<repository>
<id>atlassian</id>
<name>Atlassian Public Repository</name>
<layout>default</layout>
<url>http://maven.atlassian.com/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
Expand Down Expand Up @@ -52,30 +52,30 @@
</dependency>
</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>net.foxopen.jira.changelog.Changelog</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>net.foxopen.jira.changelog.Changelog</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
45 changes: 20 additions & 25 deletions src/net/foxopen/jira/changelog/Change.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,55 @@

/**
* Represents a JIRA issue for display in the changelog.
*
*
* @author apigram
*/
public class Change
{
public class Change {

private String issueKey;
private String issueType;
private String description;

/**
* Default constructor that accepts a name and changelog description for a
* JIRA issue.
*
*
* @param issueKey Issue name.
* @param description Issue changelog description.
* @param issueType Issue type.
* @param description Issue changelog description.
* @param issueType Issue type.
*/
public Change(String issueKey, String description, String issueType)
{
public Change(String issueKey, String description, String issueType) {
this.issueKey = issueKey;
this.description = description;
this.issueType = issueType;
}

/**
* Obtain the JIRA identifier of the issue
*
*
* @return JIRA issue identifier
*/
final String getKey()
{
final String getKey() {
// this is package level visibility as this function is only used internally
// for comparisons and templating, and as such should not be overridden.
return issueKey;
}

/**
* Obtain the type of issue (e.g. Bug, New Feature, etc.)
*
*
* @return The issue type.
*/
final String getType()
{
final String getType() {
return issueType;
}

/**
* Obtain the changelog description for the issue
*
*
* @return Changelog description
*/
final String getDescription()
{
final String getDescription() {
// this is package level visibility as this function is only used internally
// for templating, and as such should not be overridden.
return description;
Expand All @@ -66,22 +62,21 @@ final String getDescription()
/**
* Simple comparison class for comparing issue identifiers. Because all issues
* should have the same project, this will sort based on trailing number.
*
*
* @author apigram
*/
class ChangeComparator implements Comparator<Change>
{
class ChangeComparator implements Comparator<Change> {

/**
* Compare the identifiers of two changes. Used when generating the changelog
* to sort the changes by issue ID.
*
*
* @param c1 The first change.
* @param c2 The second change.
* @return 0 if the identifiers are identical, otherwise the value of c1.name
* - c2.name
* - c2.name
*/
public int compare(Change c1, Change c2)
{
public int compare(Change c1, Change c2) {
return c1.getKey().compareTo(c2.getKey());
}
}
39 changes: 18 additions & 21 deletions src/net/foxopen/jira/changelog/Changelog.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

/**
* Main class for creating a changelog from JIRA.
*
*
* @author apigram
*/
public class Changelog
{
public class Changelog {

/**
* Show usage of the application.
*/
public static void showUsage()
{
public static void showUsage() {
System.out.println("Usage:");
System.out.println("java -jar jira-changelog-builder.jar <JIRA_URL> <JIRA_username> <JIRA_password> <JIRA_project_name> <version> <template_list> [<flags>]");
System.out.println("<JIRA_URL>: The URL of the JIRA instance (e.g. https://somecompany.atlassian.net).");
Expand All @@ -28,16 +27,15 @@ public static void showUsage()
System.out.println("\t--jql 'some arbitrary JQL': Append the given JQL to the issue filter. eg 'status = \"Ready for Build\"'");
System.out.println("\t--object-cache-path /some/path: The path on disk to the cache, if you do not use this, no cache will be used. Using a cache is highly recommended.");
System.out.println("\t--debug: Print debug/logging information to standard out. This will also force errors to go to the standard out and exit with code 0 rather than 1.");
System.out.println("\t--changelog-description-field 'field_name': The name of the field in JIRA you wish to use as the changelog description field. If you do not use this, it will default to the summary field.");
System.out.println("\t--changelog-description-field 'field_name': The name of the field in JIRA you wish to use as the changelog description field. If you do not use this, it will default to the summary field.");
}

/**
* Main function.
*
*
* @param args Arguments passed in from the command line
*/
public static void main(String[] args)
{
public static void main(String[] args) {
if (args.length == 1 && args[0].equals("--help")) {
showUsage();
System.exit(0);
Expand All @@ -63,7 +61,7 @@ public static void main(String[] args)
String filenameList = null;
String files[] = null;
String objectCachePath = null;
String descriptionField = null;
String descriptionField = null;
for (; currentArgument < args.length; currentArgument++) {
try {
if (args[currentArgument].equals("--debug")) {
Expand All @@ -87,9 +85,9 @@ public static void main(String[] args)
System.exit(2);
}
Logger.log("--changelog-file-name found. Using " + filenameList + " as changelog files.");
} else if (args[currentArgument].equals("--changelog-description-field")) {
descriptionField = args[++currentArgument];
Logger.log("--changelog-description-field found. Using " + descriptionField + " as the Changelog Description field.");
} else if (args[currentArgument].equals("--changelog-description-field")) {
descriptionField = args[++currentArgument];
Logger.log("--changelog-description-field found. Using " + descriptionField + " as the Changelog Description field.");
} else {
Logger.err("Unknown argument: " + args[currentArgument]);
System.exit(2);
Expand All @@ -101,14 +99,13 @@ public static void main(String[] args)
System.exit(3);
}
}
Logger.log("Starting with parameters: " +
"\n Version: " + versionName +
"\n JIRA Project Key: " + jiraProjectKey +
"\n JIRA URL: " + jiraURL +
"\n JIRA username: " + jiraUsername +
"\n JIRA password: " + jiraPassword.substring(0, 1) + "*****" + jiraPassword.substring(jiraPassword.length() - 1) +
"\n Template files: " + templateList
);
Logger.log("Starting with parameters: "
+ "\n Version: " + versionName
+ "\n JIRA Project Key: " + jiraProjectKey
+ "\n JIRA URL: " + jiraURL
+ "\n JIRA username: " + jiraUsername
+ "\n JIRA password: " + jiraPassword.substring(0, 1) + "*****" + jiraPassword.substring(jiraPassword.length() - 1)
+ "\n Template files: " + templateList);

File f = null;
for (int i = 0; i < templates.length; i++) {
Expand Down
20 changes: 9 additions & 11 deletions src/net/foxopen/jira/changelog/ChangelogBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@

/**
* Build the changelog as text from a given list of VersionInfo instances.
*
*
* @author mleonard87
*
*
*/
public class ChangelogBuilder
{
public class ChangelogBuilder {

/**
* Iterates over a list of JIRA project versions and creates a changelog.
*
*
* @param versionInfoList The list of JIRA versions to build the changelog for
* as VersionInfo objects.
* as VersionInfo objects.
* @param files A collection of file names to use when writing the changelog
* files.
* files.
* @param templates A collection of template files to use for writing the
* changelog files. The change log will be generated in the order
* that the VersionInfo objects are in the list.
* changelog files. The change log will be generated in the order that the
* VersionInfo objects are in the list.
*/
public void build(List<VersionInfo> versionInfoList, String[] files, String[] templates)
{
public void build(List<VersionInfo> versionInfoList, String[] files, String[] templates) {
FileWriter writer = null;
int fileIndex = 0;

Expand Down
13 changes: 6 additions & 7 deletions src/net/foxopen/jira/changelog/ChangelogTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@
/**
* Incorporates the base logic for Mustache templates for changelogs saved as
* either a file or into a FOX module.
*
*
* @author apigram
*/
public class ChangelogTemplate
{
public class ChangelogTemplate {

static HashMap<String, Object> scopes = new HashMap<String, Object>();

/**
* Generate and output a changelog based off a template file
*
*
* @param versions A collection of JIRA versions with their respective issues
* @param output The output stream
* @param templateFile The filename of the template file to use.
* @param templateFile The filename of the template file to use.
*/
public static void createChangelog(List<VersionInfo> versions, Writer output, String templateFile)
{
public static void createChangelog(List<VersionInfo> versions, Writer output, String templateFile) {
// assemble the JSON hash map
scopes.put("versions", versions);

Expand Down
Loading

0 comments on commit 5e58750

Please sign in to comment.