diff --git a/pom.xml b/pom.xml
index d57d189e..7117ee33 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
-
-
+
-
4.0.0
- maven-plugins
org.apache.maven.plugins
+ maven-plugins
41
-
+
maven-changes-plugin
@@ -55,8 +53,8 @@ under the License.
scm:git:https://gitbox.apache.org/repos/asf/maven-changes-plugin.git
scm:git:https://gitbox.apache.org/repos/asf/maven-changes-plugin.git
- https://github.com/apache/maven-changes-plugin/tree/${project.scm.tag}
HEAD
+ https://github.com/apache/maven-changes-plugin/tree/${project.scm.tag}
jira
@@ -309,7 +307,7 @@ under the License.
-
+
org.apache.cxf
cxf-rt-frontend-jaxrs
@@ -436,14 +434,22 @@ under the License.
org.codehaus.modello
modello-maven-plugin
- 1.0.1
+ 1.0.1
+
+ true
+ 1.0.0
+
+ src/main/mdo/changes.mdo
+
+
+
site-docs
- pre-site
xdoc
+ pre-site
standard
@@ -455,32 +461,25 @@ under the License.
generate-xsd
- generate-resources
xsd
+ generate-resources
${project.build.outputDirectory}/META-INF/changes/xsd
generate-xsd-site
- pre-site
xsd
+ pre-site
${project.reporting.outputDirectory}/xsd
-
- true
- 1.0.0
-
- src/main/mdo/changes.mdo
-
-
org.codehaus.plexus
@@ -502,10 +501,10 @@ under the License.
patch-changes-xsd
- process-resources
execute
+ process-resources
${project.basedir}/src/main/script/patch-modello.groovy
diff --git a/src/main/java/org/apache/maven/plugins/announcement/AbstractAnnouncementMojo.java b/src/main/java/org/apache/maven/plugins/announcement/AbstractAnnouncementMojo.java
index 26cd7ac9..0427f810 100644
--- a/src/main/java/org/apache/maven/plugins/announcement/AbstractAnnouncementMojo.java
+++ b/src/main/java/org/apache/maven/plugins/announcement/AbstractAnnouncementMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.announcement;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.announcement;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.changes.AbstractChangesMojo;
@@ -28,15 +27,13 @@
* @version $Id$
* @since 2.3
*/
-public abstract class AbstractAnnouncementMojo
- extends AbstractChangesMojo
-{
+public abstract class AbstractAnnouncementMojo extends AbstractChangesMojo {
/**
* This will cause the execution to be run only at the top of a given module tree. That is, run in the project
* contained in the same folder where the mvn execution was launched.
*
* @since 2.3
*/
- @Parameter( property = "announcement.runOnlyAtExecutionRoot", defaultValue = "false" )
+ @Parameter(property = "announcement.runOnlyAtExecutionRoot", defaultValue = "false")
protected boolean runOnlyAtExecutionRoot;
}
diff --git a/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMailMojo.java b/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMailMojo.java
index 62267c8b..9a9ede96 100644
--- a/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMailMojo.java
+++ b/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMailMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.announcement;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.announcement;
+
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
import java.io.File;
import java.io.FileInputStream;
@@ -27,9 +29,6 @@
import java.io.UnsupportedEncodingException;
import java.util.List;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
-
import org.apache.maven.model.Developer;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Execute;
@@ -51,11 +50,9 @@
* @version $Id$
* @since 2.0-beta-2
*/
-@Mojo( name = "announcement-mail", threadSafe = true )
-@Execute( goal = "announcement-generate" )
-public class AnnouncementMailMojo
- extends AbstractAnnouncementMojo
-{
+@Mojo(name = "announcement-mail", threadSafe = true)
+@Execute(goal = "announcement-generate")
+public class AnnouncementMailMojo extends AbstractAnnouncementMojo {
// =========================================
// announcement-mail goal fields
// =========================================
@@ -63,7 +60,7 @@ public class AnnouncementMailMojo
/**
* Possible senders.
*/
- @Parameter( property = "project.developers", required = true, readonly = true )
+ @Parameter(property = "project.developers", required = true, readonly = true)
private List from;
/**
@@ -71,7 +68,7 @@ public class AnnouncementMailMojo
* In this case, this should match the id of one of the developers in the pom. If a matching developer is not found,
* then the first developer in the pom will be used.
*/
- @Parameter( property = "changes.fromDeveloperId" )
+ @Parameter(property = "changes.fromDeveloperId")
private String fromDeveloperId;
/**
@@ -79,27 +76,27 @@ public class AnnouncementMailMojo
*
* @since 2.1
*/
- @Parameter( defaultValue = "text/plain", required = true )
+ @Parameter(defaultValue = "text/plain", required = true)
private String mailContentType;
/**
* Defines the sender of the announcement email. This takes precedence over the list of developers specified in the
* POM. if the sender is not a member of the development team. Note that since this is a bean type, you cannot
* specify it from command level with
- *
+ *
*
* -D
*
- *
+ *
* . Use
- *
+ *
*
* -Dchanges.sender='Your Name <you@domain>'
*
- *
+ *
* instead.
*/
- @Parameter( property = "changes.mailSender" )
+ @Parameter(property = "changes.mailSender")
private MailSender mailSender;
/**
@@ -107,45 +104,45 @@ public class AnnouncementMailMojo
* developers in the POM.
*
* This parameter parses an email address in standard RFC822 format, e.g.
- *
+ *
*
* -Dchanges.sender='Your Name <you@domain>'
*
- *
+ *
* .
*
* @since 2.7
*/
- @Parameter( property = "changes.sender" )
+ @Parameter(property = "changes.sender")
private String senderString;
/**
* The password used to send the email.
*/
- @Parameter( property = "changes.password" )
+ @Parameter(property = "changes.password")
private String password;
/**
*/
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
/**
* Smtp Server.
*/
- @Parameter( property = "changes.smtpHost", required = true )
+ @Parameter(property = "changes.smtpHost", required = true)
private String smtpHost;
/**
* Port.
*/
- @Parameter( property = "changes.smtpPort", defaultValue = "25", required = true )
+ @Parameter(property = "changes.smtpPort", defaultValue = "25", required = true)
private int smtpPort;
/**
* If the email should be sent in SSL mode.
*/
- @Parameter( property = "changes.sslMode", defaultValue = "false" )
+ @Parameter(property = "changes.sslMode", defaultValue = "false")
private boolean sslMode;
/**
@@ -153,14 +150,17 @@ public class AnnouncementMailMojo
*
* @since 2.10
*/
- @Parameter( property = "changes.startTls", defaultValue = "false" )
+ @Parameter(property = "changes.startTls", defaultValue = "false")
private boolean startTls;
/**
* Subject for the email.
*/
// CHECKSTYLE_OFF: LineLength
- @Parameter( property = "changes.subject", defaultValue = "[ANNOUNCEMENT] - ${project.name} ${project.version} released", required = true )
+ @Parameter(
+ property = "changes.subject",
+ defaultValue = "[ANNOUNCEMENT] - ${project.name} ${project.version} released",
+ required = true)
private String subject;
// CHECKSTYLE_ON: LineLength
@@ -169,7 +169,7 @@ public class AnnouncementMailMojo
*
* @since 2.10
*/
- @Parameter( property = "changes.announcementFile", defaultValue = "announcement.vm", required = true )
+ @Parameter(property = "changes.announcementFile", defaultValue = "announcement.vm", required = true)
private String announcementFile;
/**
@@ -177,7 +177,7 @@ public class AnnouncementMailMojo
*
* @since 2.10
*/
- @Parameter( defaultValue = "${project.build.directory}/announcement", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/announcement", required = true)
private File announcementDirectory;
/**
@@ -185,7 +185,7 @@ public class AnnouncementMailMojo
*
* @since 2.10
*/
- @Parameter( property = "changes.templateEncoding", defaultValue = "${project.build.sourceEncoding}" )
+ @Parameter(property = "changes.templateEncoding", defaultValue = "${project.build.sourceEncoding}")
private String templateEncoding;
/**
@@ -200,7 +200,7 @@ public class AnnouncementMailMojo
/**
* Recipient email address.
*/
- @Parameter( required = true )
+ @Parameter(required = true)
private List toAddresses;
/**
@@ -222,71 +222,58 @@ public class AnnouncementMailMojo
/**
* The username used to send the email.
*/
- @Parameter( property = "changes.username" )
+ @Parameter(property = "changes.username")
private String username;
private ProjectJavamailMailSender mailer = new ProjectJavamailMailSender();
- public void execute()
- throws MojoExecutionException
- {
+ public void execute() throws MojoExecutionException {
// Fail build fast if it is using deprecated parameters
- if ( templateOutputDirectory != null )
- {
- throw new MojoExecutionException( "You are using the old parameter 'templateOutputDirectory'. "
- + "You must use 'announcementDirectory' instead." );
+ if (templateOutputDirectory != null) {
+ throw new MojoExecutionException("You are using the old parameter 'templateOutputDirectory'. "
+ + "You must use 'announcementDirectory' instead.");
}
// Run only at the execution root
- if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
- {
- getLog().info( "Skipping the announcement mail in this project because it's not the Execution Root" );
- }
- else
- {
- File file = new File( announcementDirectory, announcementFile );
+ if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
+ getLog().info("Skipping the announcement mail in this project because it's not the Execution Root");
+ } else {
+ File file = new File(announcementDirectory, announcementFile);
- ConsoleLogger logger = new ConsoleLogger( Logger.LEVEL_INFO, "base" );
+ ConsoleLogger logger = new ConsoleLogger(Logger.LEVEL_INFO, "base");
- if ( getLog().isDebugEnabled() )
- {
- logger.setThreshold( Logger.LEVEL_DEBUG );
+ if (getLog().isDebugEnabled()) {
+ logger.setThreshold(Logger.LEVEL_DEBUG);
}
- mailer.enableLogging( logger );
+ mailer.enableLogging(logger);
- mailer.setSmtpHost( getSmtpHost() );
+ mailer.setSmtpHost(getSmtpHost());
- mailer.setSmtpPort( getSmtpPort() );
+ mailer.setSmtpPort(getSmtpPort());
- mailer.setSslMode( sslMode, startTls );
+ mailer.setSslMode(sslMode, startTls);
- if ( username != null )
- {
- mailer.setUsername( username );
+ if (username != null) {
+ mailer.setUsername(username);
}
- if ( password != null )
- {
- mailer.setPassword( password );
+ if (password != null) {
+ mailer.setPassword(password);
}
mailer.initialize();
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "fromDeveloperId: " + getFromDeveloperId() );
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("fromDeveloperId: " + getFromDeveloperId());
}
- if ( file.isFile() )
- {
- getLog().info( "Connecting to Host: " + getSmtpHost() + ":" + getSmtpPort() );
+ if (file.isFile()) {
+ getLog().info("Connecting to Host: " + getSmtpHost() + ":" + getSmtpPort());
sendMessage();
- }
- else
- {
- throw new MojoExecutionException( "Announcement file " + file + " not found..." );
+ } else {
+ throw new MojoExecutionException("Announcement file " + file + " not found...");
}
}
}
@@ -296,60 +283,49 @@ public void execute()
*
* @throws MojoExecutionException if the mail could not be sent
*/
- protected void sendMessage()
- throws MojoExecutionException
- {
- File file = new File( announcementDirectory, announcementFile );
+ protected void sendMessage() throws MojoExecutionException {
+ File file = new File(announcementDirectory, announcementFile);
String email = "";
final MailSender ms = getActualMailSender();
final String fromName = ms.getName();
final String fromAddress = ms.getEmail();
- if ( fromAddress == null || fromAddress.equals( "" ) )
- {
- throw new MojoExecutionException( "Invalid mail sender: name and email is mandatory (" + ms + ")." );
+ if (fromAddress == null || fromAddress.equals("")) {
+ throw new MojoExecutionException("Invalid mail sender: name and email is mandatory (" + ms + ").");
}
- getLog().info( "Using this sender for email announcement: " + fromAddress + " < " + fromName + " > " );
- try
- {
+ getLog().info("Using this sender for email announcement: " + fromAddress + " < " + fromName + " > ");
+ try {
MailMessage mailMsg = new MailMessage();
- mailMsg.setSubject( getSubject() );
- mailMsg.setContent( readAnnouncement( file ) );
- mailMsg.setContentType( this.mailContentType );
- mailMsg.setFrom( fromAddress, fromName );
+ mailMsg.setSubject(getSubject());
+ mailMsg.setContent(readAnnouncement(file));
+ mailMsg.setContentType(this.mailContentType);
+ mailMsg.setFrom(fromAddress, fromName);
- for ( Object o1 : getToAddresses() )
- {
+ for (Object o1 : getToAddresses()) {
email = o1.toString();
- getLog().info( "Sending mail to " + email + "..." );
- mailMsg.addTo( email, "" );
+ getLog().info("Sending mail to " + email + "...");
+ mailMsg.addTo(email, "");
}
- if ( getCcAddresses() != null )
- {
- for ( Object o : getCcAddresses() )
- {
+ if (getCcAddresses() != null) {
+ for (Object o : getCcAddresses()) {
email = o.toString();
- getLog().info( "Sending cc mail to " + email + "..." );
- mailMsg.addCc( email, "" );
+ getLog().info("Sending cc mail to " + email + "...");
+ mailMsg.addCc(email, "");
}
}
- if ( getBccAddresses() != null )
- {
- for ( Object o : getBccAddresses() )
- {
+ if (getBccAddresses() != null) {
+ for (Object o : getBccAddresses()) {
email = o.toString();
- getLog().info( "Sending bcc mail to " + email + "..." );
- mailMsg.addBcc( email, "" );
+ getLog().info("Sending bcc mail to " + email + "...");
+ mailMsg.addBcc(email, "");
}
}
- mailer.send( mailMsg );
- getLog().info( "Sent..." );
- }
- catch ( MailSenderException e )
- {
- throw new MojoExecutionException( "Failed to send email < " + email + " >", e );
+ mailer.send(mailMsg);
+ getLog().info("Sent...");
+ } catch (MailSenderException e) {
+ throw new MojoExecutionException("Failed to send email < " + email + " >", e);
}
}
@@ -360,35 +336,23 @@ protected void sendMessage()
* @return Return the announcement text
* @throws MojoExecutionException if the file could not be found, or if the encoding is unsupported
*/
- protected String readAnnouncement( File file )
- throws MojoExecutionException
- {
- try
- {
- if ( templateEncoding == null || templateEncoding.isEmpty() )
- {
+ protected String readAnnouncement(File file) throws MojoExecutionException {
+ try {
+ if (templateEncoding == null || templateEncoding.isEmpty()) {
templateEncoding = ReaderFactory.FILE_ENCODING;
- getLog().warn( "File encoding has not been set, using platform encoding '" + templateEncoding
- + "', i.e. build is platform dependent!" );
-
+ getLog().warn("File encoding has not been set, using platform encoding '" + templateEncoding
+ + "', i.e. build is platform dependent!");
}
- try ( InputStreamReader reader = new InputStreamReader( new FileInputStream( file ), templateEncoding ) )
- {
- return IOUtil.toString( reader );
+ try (InputStreamReader reader = new InputStreamReader(new FileInputStream(file), templateEncoding)) {
+ return IOUtil.toString(reader);
}
- }
- catch ( FileNotFoundException fnfe )
- {
- throw new MojoExecutionException( "File not found. " + file );
- }
- catch ( UnsupportedEncodingException uee )
- {
- throw new MojoExecutionException( "Unsupported encoding: '" + templateEncoding + "'" );
- }
- catch ( IOException ioe )
- {
- throw new MojoExecutionException( "Failed to read the announcement file.", ioe );
+ } catch (FileNotFoundException fnfe) {
+ throw new MojoExecutionException("File not found. " + file);
+ } catch (UnsupportedEncodingException uee) {
+ throw new MojoExecutionException("Unsupported encoding: '" + templateEncoding + "'");
+ } catch (IOException ioe) {
+ throw new MojoExecutionException("Failed to read the announcement file.", ioe);
}
}
@@ -404,46 +368,31 @@ protected String readAnnouncement( File file )
* @return the mail sender to use
* @throws MojoExecutionException if the mail sender could not be retrieved
*/
- protected MailSender getActualMailSender()
- throws MojoExecutionException
- {
- if ( senderString != null )
- {
- try
- {
- InternetAddress ia = new InternetAddress( senderString, true );
- return new MailSender( ia.getPersonal(), ia.getAddress() );
- }
- catch ( AddressException e )
- {
- throw new MojoExecutionException( "Invalid value for change.sender: ", e );
+ protected MailSender getActualMailSender() throws MojoExecutionException {
+ if (senderString != null) {
+ try {
+ InternetAddress ia = new InternetAddress(senderString, true);
+ return new MailSender(ia.getPersonal(), ia.getAddress());
+ } catch (AddressException e) {
+ throw new MojoExecutionException("Invalid value for change.sender: ", e);
}
}
- if ( mailSender != null && mailSender.getEmail() != null )
- {
+ if (mailSender != null && mailSender.getEmail() != null) {
return mailSender;
- }
- else if ( from == null || from.isEmpty() )
- {
- throw new MojoExecutionException( "The section in your pom should not be empty. "
- + "Add a entry or set the mailSender parameter." );
- }
- else if ( fromDeveloperId == null )
- {
- final Developer dev = from.get( 0 );
- return new MailSender( dev.getName(), dev.getEmail() );
- }
- else
- {
- for ( Developer developer : from )
- {
- if ( fromDeveloperId.equals( developer.getId() ) )
- {
- return new MailSender( developer.getName(), developer.getEmail() );
+ } else if (from == null || from.isEmpty()) {
+ throw new MojoExecutionException("The section in your pom should not be empty. "
+ + "Add a entry or set the mailSender parameter.");
+ } else if (fromDeveloperId == null) {
+ final Developer dev = from.get(0);
+ return new MailSender(dev.getName(), dev.getEmail());
+ } else {
+ for (Developer developer : from) {
+ if (fromDeveloperId.equals(developer.getId())) {
+ return new MailSender(developer.getName(), developer.getEmail());
}
}
- throw new MojoExecutionException( "Missing developer with id '" + fromDeveloperId
- + "' in the section in your pom." );
+ throw new MojoExecutionException(
+ "Missing developer with id '" + fromDeveloperId + "' in the section in your pom.");
}
}
@@ -451,163 +400,131 @@ else if ( fromDeveloperId == null )
// announcement-mail accessors
// ================================
- public List getBccAddresses()
- {
+ public List getBccAddresses() {
return bccAddresses;
}
- public void setBccAddresses( List bccAddresses )
- {
+ public void setBccAddresses(List bccAddresses) {
this.bccAddresses = bccAddresses;
}
- public List getCcAddresses()
- {
+ public List getCcAddresses() {
return ccAddresses;
}
- public void setCcAddresses( List ccAddresses )
- {
+ public void setCcAddresses(List ccAddresses) {
this.ccAddresses = ccAddresses;
}
- public List getFrom()
- {
+ public List getFrom() {
return from;
}
- public void setFrom( List from )
- {
+ public void setFrom(List from) {
this.from = from;
}
- public String getFromDeveloperId()
- {
+ public String getFromDeveloperId() {
return fromDeveloperId;
}
- public void setFromDeveloperId( String fromDeveloperId )
- {
+ public void setFromDeveloperId(String fromDeveloperId) {
this.fromDeveloperId = fromDeveloperId;
}
- public MailSender getMailSender()
- {
+ public MailSender getMailSender() {
return mailSender;
}
- public void setMailSender( MailSender mailSender )
- {
+ public void setMailSender(MailSender mailSender) {
this.mailSender = mailSender;
}
- public String getPassword()
- {
+ public String getPassword() {
return password;
}
- public void setPassword( String password )
- {
+ public void setPassword(String password) {
this.password = password;
}
- public MavenProject getProject()
- {
+ public MavenProject getProject() {
return project;
}
- public void setProject( MavenProject project )
- {
+ public void setProject(MavenProject project) {
this.project = project;
}
- public String getSmtpHost()
- {
+ public String getSmtpHost() {
return smtpHost;
}
- public void setSmtpHost( String smtpHost )
- {
+ public void setSmtpHost(String smtpHost) {
this.smtpHost = smtpHost;
}
- public int getSmtpPort()
- {
+ public int getSmtpPort() {
return smtpPort;
}
- public void setSmtpPort( int smtpPort )
- {
+ public void setSmtpPort(int smtpPort) {
this.smtpPort = smtpPort;
}
- public boolean isSslMode()
- {
+ public boolean isSslMode() {
return sslMode;
}
- public void setSslMode( boolean sslMode )
- {
+ public void setSslMode(boolean sslMode) {
this.sslMode = sslMode;
}
- public boolean isStartTls()
- {
+ public boolean isStartTls() {
return startTls;
}
- public void setStartTls( boolean startTls )
- {
+ public void setStartTls(boolean startTls) {
this.startTls = startTls;
}
- public String getSubject()
- {
+ public String getSubject() {
return subject;
}
- public void setSubject( String subject )
- {
+ public void setSubject(String subject) {
this.subject = subject;
}
- public String getAnnouncementFile()
- {
+ public String getAnnouncementFile() {
return announcementFile;
}
- public void setAnnouncementFile( String announcementFile )
- {
+ public void setAnnouncementFile(String announcementFile) {
this.announcementFile = announcementFile;
}
- public File getAnnouncementDirectory()
- {
+ public File getAnnouncementDirectory() {
return announcementDirectory;
}
- public void setAnnouncementDirectory( File announcementDirectory )
- {
+ public void setAnnouncementDirectory(File announcementDirectory) {
this.announcementDirectory = announcementDirectory;
}
- public List getToAddresses()
- {
+ public List getToAddresses() {
return toAddresses;
}
- public void setToAddresses( List toAddresses )
- {
+ public void setToAddresses(List toAddresses) {
this.toAddresses = toAddresses;
}
- public String getUsername()
- {
+ public String getUsername() {
return username;
}
- public void setUsername( String username )
- {
+ public void setUsername(String username) {
this.username = username;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java b/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java
index ea5fe139..a2aa13ad 100644
--- a/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java
+++ b/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.announcement;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.announcement;
import java.io.File;
import java.io.FileOutputStream;
@@ -67,10 +66,8 @@
* @version $Id$
* @since 2.0-beta-2
*/
-@Mojo( name = "announcement-generate", threadSafe = true )
-public class AnnouncementMojo
- extends AbstractAnnouncementMojo
-{
+@Mojo(name = "announcement-generate", threadSafe = true)
+public class AnnouncementMojo extends AbstractAnnouncementMojo {
private static final String CHANGES_XML = "changes.xml";
private static final String JIRA = "JIRA";
@@ -85,7 +82,7 @@ public class AnnouncementMojo
*
* @since 2.4
*/
- @Parameter( property = "changes.announcementFile" )
+ @Parameter(property = "changes.announcementFile")
private String announcementFile;
/**
@@ -98,30 +95,30 @@ public class AnnouncementMojo
/**
*/
- @Parameter( property = "project.artifactId", readonly = true )
+ @Parameter(property = "project.artifactId", readonly = true)
private String artifactId;
/**
* Name of the team that develops the artifact. This parameter will be passed to the template.
*/
- @Parameter( property = "changes.developmentTeam", defaultValue = "${project.name} team", required = true )
+ @Parameter(property = "changes.developmentTeam", defaultValue = "${project.name} team", required = true)
private String developmentTeam;
/**
* The name of the artifact to be used in the announcement.
*/
- @Parameter( property = "changes.finalName", defaultValue = "${project.build.finalName}", required = true )
+ @Parameter(property = "changes.finalName", defaultValue = "${project.build.finalName}", required = true)
private String finalName;
/**
*/
- @Parameter( property = "project.groupId", readonly = true )
+ @Parameter(property = "project.groupId", readonly = true)
private String groupId;
/**
* Short description or introduction of the released artifact. This parameter will be passed to the template.
*/
- @Parameter( defaultValue = "${project.description}" )
+ @Parameter(defaultValue = "${project.description}")
private String introduction;
/**
@@ -156,7 +153,7 @@ public class AnnouncementMojo
*
* @since 2.10
*/
- @Parameter( defaultValue = "${project.build.directory}/announcement", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/announcement", required = true)
private File announcementDirectory;
/**
@@ -171,19 +168,19 @@ public class AnnouncementMojo
/**
* Packaging structure for the artifact.
*/
- @Parameter( property = "project.packaging", readonly = true )
+ @Parameter(property = "project.packaging", readonly = true)
private String packaging;
/**
* The Maven Project.
*/
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
/**
* The Velocity template used to format the announcement.
*/
- @Parameter( property = "changes.template", defaultValue = "announcement.vm", required = true )
+ @Parameter(property = "changes.template", defaultValue = "announcement.vm", required = true)
private String template;
/**
@@ -194,7 +191,10 @@ public class AnnouncementMojo
*
*/
// CHECKSTYLE_OFF: LineLength
- @Parameter( property = "changes.templateDirectory", defaultValue = "org/apache/maven/plugins/announcement", required = true )
+ @Parameter(
+ property = "changes.templateDirectory",
+ defaultValue = "org/apache/maven/plugins/announcement",
+ required = true)
private String templateDirectory;
// CHECKSTYLE_ON: LineLength
@@ -203,7 +203,7 @@ public class AnnouncementMojo
*
* @since 2.1
*/
- @Parameter( property = "changes.templateEncoding", defaultValue = "${project.build.sourceEncoding}" )
+ @Parameter(property = "changes.templateEncoding", defaultValue = "${project.build.sourceEncoding}")
private String templateEncoding;
/**
@@ -213,13 +213,13 @@ public class AnnouncementMojo
*
* @since 2.10
*/
- @Parameter( property = "changes.useJql", defaultValue = "false" )
+ @Parameter(property = "changes.useJql", defaultValue = "false")
private boolean useJql;
/**
* Distribution URL of the artifact. This parameter will be passed to the template.
*/
- @Parameter( property = "project.url" )
+ @Parameter(property = "project.url")
private String url;
/**
@@ -232,7 +232,7 @@ public class AnnouncementMojo
/**
* Velocity Component.
*/
- @Component( role = VelocityComponent.class, hint = "maven-changes-plugin" )
+ @Component(role = VelocityComponent.class, hint = "maven-changes-plugin")
private VelocityComponent velocity;
/**
@@ -244,7 +244,7 @@ public class AnnouncementMojo
/**
* Version of the artifact.
*/
- @Parameter( property = "changes.version", defaultValue = "${project.version}", required = true )
+ @Parameter(property = "changes.version", defaultValue = "${project.version}", required = true)
private String version;
/**
@@ -253,7 +253,7 @@ public class AnnouncementMojo
* @parameter expression="${basedir}/src/changes/changes.xml"
* @required
*/
- @Parameter( defaultValue = "${basedir}/src/changes/changes.xml" )
+ @Parameter(defaultValue = "${basedir}/src/changes/changes.xml")
private File xmlPath;
// =======================================//
@@ -275,7 +275,7 @@ public class AnnouncementMojo
* @deprecated Since version 2.4 this parameter has been deprecated. Please use the issueManagementSystems parameter
* instead.
*/
- @Parameter( property = "generateJiraAnnouncement" )
+ @Parameter(property = "generateJiraAnnouncement")
private Boolean generateJiraAnnouncement;
/**
@@ -285,7 +285,7 @@ public class AnnouncementMojo
* @deprecated Since version 2.4 this parameter has been deprecated. Please use the issueManagementSystems parameter
* instead.
*/
- @Parameter( property = "changes.jiraMerge" )
+ @Parameter(property = "changes.jiraMerge")
private Boolean jiraMerge;
/**
@@ -293,7 +293,7 @@ public class AnnouncementMojo
*
* @since 2.1
*/
- @Parameter( property = "changes.jiraPassword" )
+ @Parameter(property = "changes.jiraPassword")
private String jiraPassword;
/**
@@ -301,7 +301,7 @@ public class AnnouncementMojo
*
* @since 2.1
*/
- @Parameter( property = "changes.jiraUser" )
+ @Parameter(property = "changes.jiraUser")
private String jiraUser;
/**
@@ -309,13 +309,13 @@ public class AnnouncementMojo
*
* @since 3.0.0
*/
- @Parameter( property = "changes.jiraServerId" )
+ @Parameter(property = "changes.jiraServerId")
private String jiraServerId;
/**
* Path to the JIRA XML file, which will be parsed.
*/
- @Parameter( defaultValue = "${project.build.directory}/jira-announcement.xml", required = true, readonly = true )
+ @Parameter(defaultValue = "${project.build.directory}/jira-announcement.xml", required = true, readonly = true)
private File jiraXML;
/**
@@ -324,7 +324,7 @@ public class AnnouncementMojo
* Note: In versions 2.0-beta-3 and earlier this parameter was called "nbEntries".
*
*/
- @Parameter( property = "changes.maxEntries", defaultValue = "25", required = true )
+ @Parameter(property = "changes.maxEntries", defaultValue = "25", required = true)
private int maxEntries;
/**
@@ -334,13 +334,13 @@ public class AnnouncementMojo
* Note: In versions 2.0-beta-3 and earlier this parameter was called "resolutionId".
*
*/
- @Parameter( property = "changes.resolutionIds", defaultValue = "Fixed" )
+ @Parameter(property = "changes.resolutionIds", defaultValue = "Fixed")
private String resolutionIds;
/**
* Settings XML configuration.
*/
- @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+ @Parameter(defaultValue = "${settings}", readonly = true, required = true)
private Settings settings;
/**
@@ -350,7 +350,7 @@ public class AnnouncementMojo
* Note: In versions 2.0-beta-3 and earlier this parameter was called "statusId".
*
*/
- @Parameter( property = "changes.statusIds", defaultValue = "Closed" )
+ @Parameter(property = "changes.statusIds", defaultValue = "Closed")
private String statusIds;
/**
@@ -358,7 +358,7 @@ public class AnnouncementMojo
*
* @since 2.4
*/
- @Parameter( property = "changes.webUser" )
+ @Parameter(property = "changes.webUser")
private String webUser;
/**
@@ -366,7 +366,7 @@ public class AnnouncementMojo
*
* @since 2.4
*/
- @Parameter( property = "changes.webPassword" )
+ @Parameter(property = "changes.webPassword")
private String webPassword;
/**
@@ -379,7 +379,7 @@ public class AnnouncementMojo
*
* @since 2.5
*/
- @Parameter( property = "changes.versionPrefix" )
+ @Parameter(property = "changes.versionPrefix")
private String versionPrefix;
/**
@@ -390,7 +390,7 @@ public class AnnouncementMojo
*
* @since 2.11
*/
- @Parameter( property = "changes.jiraConnectionTimeout", defaultValue = "36000" )
+ @Parameter(property = "changes.jiraConnectionTimeout", defaultValue = "36000")
private int jiraConnectionTimeout;
/**
@@ -401,7 +401,7 @@ public class AnnouncementMojo
*
* @since 2.11
*/
- @Parameter( property = "changes.jiraReceiveTimout", defaultValue = "32000" )
+ @Parameter(property = "changes.jiraReceiveTimout", defaultValue = "32000")
private int jiraReceiveTimout;
// =======================================//
@@ -413,7 +413,7 @@ public class AnnouncementMojo
*
* @since 2.4
*/
- @Parameter( property = "changes.tracPassword" )
+ @Parameter(property = "changes.tracPassword")
private String tracPassword;
/**
@@ -421,7 +421,7 @@ public class AnnouncementMojo
*
* @since 2.4
*/
- @Parameter( defaultValue = "order=id" )
+ @Parameter(defaultValue = "order=id")
private String tracQuery;
/**
@@ -429,7 +429,7 @@ public class AnnouncementMojo
*
* @since 2.4
*/
- @Parameter( property = "changes.tracUser" )
+ @Parameter(property = "changes.tracUser")
private String tracUser;
// =======================================//
@@ -438,18 +438,18 @@ public class AnnouncementMojo
/**
* The scheme of your github api domain. Only use if using github enterprise.
- *
+ *
* @since 2.9
*/
- @Parameter( defaultValue = "http", property = "changes.githubAPIScheme" )
+ @Parameter(defaultValue = "http", property = "changes.githubAPIScheme")
private String githubAPIScheme;
/**
* The port of your github api domain. Only use if using github enterprise.
- *
+ *
* @since 2.9
*/
- @Parameter( defaultValue = "80", property = "changes.githubAPIPort" )
+ @Parameter(defaultValue = "80", property = "changes.githubAPIPort")
private int githubAPIPort;
/**
@@ -458,16 +458,16 @@ public class AnnouncementMojo
*
* @since 2.12
*/
- @Parameter( defaultValue = "github" )
+ @Parameter(defaultValue = "github")
private String githubAPIServerId;
/**
* Boolean which says if we should include open github issues in the announcement.
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean includeOpenIssues;
- private ReleaseUtils releaseUtils = new ReleaseUtils( getLog() );
+ private ReleaseUtils releaseUtils = new ReleaseUtils(getLog());
private ChangesXML xml;
@@ -480,94 +480,70 @@ public class AnnouncementMojo
*
* @throws MojoExecutionException in case of errors
*/
- public void execute()
- throws MojoExecutionException
- {
+ 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 " );
+ 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 )
- {
+ 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<>();
}
- if ( issueManagementSystems.isEmpty() )
- {
- issueManagementSystems.add( CHANGES_XML );
+ if (issueManagementSystems.isEmpty()) {
+ issueManagementSystems.add(CHANGES_XML);
}
// Fetch releases from the configured issue management systems
List releases = null;
- if ( issueManagementSystems.contains( CHANGES_XML ) )
- {
- if ( getXmlPath().exists() )
- {
- ChangesXML changesXML = new ChangesXML( getXmlPath(), getLog() );
+ if (issueManagementSystems.contains(CHANGES_XML)) {
+ if (getXmlPath().exists()) {
+ ChangesXML changesXML = new ChangesXML(getXmlPath(), getLog());
List 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." );
+ 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 )
- {
+ if (issueManagementSystems.contains(JIRA)) {
+ String message = ProjectUtils.validateIssueManagement(project, JIRA, "JIRA announcement");
+ if (message == null) {
List 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 );
+ 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 )
- {
+ if (issueManagementSystems.contains(TRAC)) {
+ String message = ProjectUtils.validateIssueManagement(project, TRAC, "Trac announcement");
+ if (message == null) {
List 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 );
+ 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 )
- {
+ if (issueManagementSystems.contains(GIT_HUB)) {
+ String message = ProjectUtils.validateIssueManagement(project, GIT_HUB, "GitHub announcement");
+ if (message == null) {
List 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 );
+ 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);
}
}
@@ -581,25 +557,20 @@ public void execute()
// For help with these steps, you can have a look at how this has been done for JIRA or Trac
// 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 );
+ if (releases == null || releases.isEmpty()) {
+ throw new MojoExecutionException(
+ "No releases found in any of the " + "configured issue management systems.");
+ } else {
+ doGenerate(releases);
}
}
}
- private void failIfUsingDeprecatedParameter( Object value, String name, String replacement )
- throws MojoExecutionException
- {
- if ( value != null )
- {
- throw new MojoExecutionException( "You are using the old parameter '" + name + "'. " + "You must use '"
- + replacement + "' instead." );
+ private void failIfUsingDeprecatedParameter(Object value, String name, String replacement)
+ throws MojoExecutionException {
+ if (value != null) {
+ throw new MojoExecutionException(
+ "You are using the old parameter '" + name + "'. " + "You must use '" + replacement + "' instead.");
}
}
@@ -609,73 +580,60 @@ private void failIfUsingDeprecatedParameter( Object value, String name, String r
* @param releases A List
of Release
s
* @throws MojoExecutionException in case of errors
*/
- public void doGenerate( List releases )
- throws MojoExecutionException
- {
- String version = ( versionPrefix == null ? "" : versionPrefix ) + getVersion();
+ public void doGenerate(List releases) throws MojoExecutionException {
+ String version = (versionPrefix == null ? "" : versionPrefix) + getVersion();
- getLog().debug( "Generating announcement for version [" + version + "]. Found these releases: "
- + ReleaseUtils.toString( releases ) );
+ getLog().debug("Generating announcement for version [" + version + "]. Found these releases: "
+ + ReleaseUtils.toString(releases));
- doGenerate( releases, releaseUtils.getLatestRelease( releases, version ) );
+ doGenerate(releases, releaseUtils.getLatestRelease(releases, version));
}
- protected void doGenerate( List releases, Release release )
- throws MojoExecutionException
- {
- try
- {
- ToolManager toolManager = new ToolManager( true );
+ protected void doGenerate(List releases, Release release) throws MojoExecutionException {
+ try {
+ ToolManager toolManager = new ToolManager(true);
Context context = toolManager.createContext();
- if ( getIntroduction() == null || getIntroduction().equals( "" ) )
- {
- setIntroduction( getUrl() );
+ if (getIntroduction() == null || getIntroduction().equals("")) {
+ setIntroduction(getUrl());
}
- context.put( "releases", releases );
+ context.put("releases", releases);
- context.put( "groupId", getGroupId() );
+ context.put("groupId", getGroupId());
- context.put( "artifactId", getArtifactId() );
+ context.put("artifactId", getArtifactId());
- context.put( "version", getVersion() );
+ context.put("version", getVersion());
- context.put( "packaging", getPackaging() );
+ context.put("packaging", getPackaging());
- context.put( "url", getUrl() );
+ context.put("url", getUrl());
- context.put( "release", release );
+ context.put("release", release);
- context.put( "introduction", getIntroduction() );
+ context.put("introduction", getIntroduction());
- context.put( "developmentTeam", getDevelopmentTeam() );
+ context.put("developmentTeam", getDevelopmentTeam());
- context.put( "finalName", getFinalName() );
+ context.put("finalName", getFinalName());
- context.put( "urlDownload", getUrlDownload() );
+ context.put("urlDownload", getUrlDownload());
- context.put( "project", project );
+ context.put("project", project);
- if ( announceParameters == null )
- {
+ if (announceParameters == null) {
// empty Map to prevent NPE in velocity execution
- context.put( "announceParameters", Collections.emptyMap() );
- }
- else
- {
- context.put( "announceParameters", announceParameters );
+ context.put("announceParameters", Collections.emptyMap());
+ } else {
+ context.put("announceParameters", announceParameters);
}
- processTemplate( context, announcementDirectory, template, announcementFile );
- }
- catch ( ResourceNotFoundException rnfe )
- {
- throw new MojoExecutionException( "Resource not found.", rnfe );
- }
- catch ( VelocityException ve )
- {
- throw new MojoExecutionException( ve.toString(), ve );
+ processTemplate(context, announcementDirectory, template, announcementFile);
+ } catch (ResourceNotFoundException rnfe) {
+ throw new MojoExecutionException("Resource not found.", rnfe);
+ } catch (VelocityException ve) {
+ throw new MojoExecutionException(ve.toString(), ve);
}
}
@@ -689,192 +647,153 @@ protected void doGenerate( List releases, Release release )
* @throws VelocityException in case of errors.
* @throws MojoExecutionException in case of errors.
*/
- public void processTemplate( Context context, File outputDirectory, String template, String announcementFile )
- throws VelocityException, MojoExecutionException
- {
+ public void processTemplate(Context context, File outputDirectory, String template, String announcementFile)
+ throws VelocityException, MojoExecutionException {
File f;
// Use the name of the template as a default value
- if ( announcementFile == null || announcementFile.isEmpty() )
- {
+ if (announcementFile == null || announcementFile.isEmpty()) {
announcementFile = template;
}
- try
- {
- f = new File( outputDirectory, announcementFile );
+ try {
+ f = new File(outputDirectory, announcementFile);
- if ( !f.getParentFile().exists() )
- {
+ if (!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
VelocityEngine engine = velocity.getEngine();
- engine.setApplicationAttribute( "baseDirectory", basedir );
+ engine.setApplicationAttribute("baseDirectory", basedir);
- if ( templateEncoding == null || templateEncoding.isEmpty() )
- {
+ if (templateEncoding == null || templateEncoding.isEmpty()) {
templateEncoding = ReaderFactory.FILE_ENCODING;
- getLog().warn( "File encoding has not been set, using platform encoding " + templateEncoding
- + ", i.e. build is platform dependent!" );
+ getLog().warn("File encoding has not been set, using platform encoding " + templateEncoding
+ + ", i.e. build is platform dependent!");
}
- Writer writer = new OutputStreamWriter( new FileOutputStream( f ), templateEncoding );
+ Writer writer = new OutputStreamWriter(new FileOutputStream(f), templateEncoding);
- Template velocityTemplate = engine.getTemplate( templateDirectory + "/" + template, templateEncoding );
+ Template velocityTemplate = engine.getTemplate(templateDirectory + "/" + template, templateEncoding);
- velocityTemplate.merge( context, writer );
+ velocityTemplate.merge(context, writer);
writer.flush();
writer.close();
- getLog().info( "Created template " + f );
- }
-
- catch ( ResourceNotFoundException rnfe )
- {
- throw new ResourceNotFoundException( "Template not found. ( " + templateDirectory + "/" + template + " )" );
- }
- catch ( VelocityException ve )
- {
- throw new VelocityException( ve.toString() );
- }
-
- catch ( Exception e )
- {
- if ( e.getCause() != null )
- {
- getLog().warn( e.getCause() );
+ getLog().info("Created template " + f);
+ } catch (ResourceNotFoundException rnfe) {
+ throw new ResourceNotFoundException("Template not found. ( " + templateDirectory + "/" + template + " )");
+ } catch (VelocityException ve) {
+ throw new VelocityException(ve.toString());
+ } catch (Exception e) {
+ if (e.getCause() != null) {
+ getLog().warn(e.getCause());
}
- throw new MojoExecutionException( e.toString(), e.getCause() );
+ throw new MojoExecutionException(e.toString(), e.getCause());
}
}
- protected List getJiraReleases()
- throws MojoExecutionException
- {
+ protected List getJiraReleases() throws MojoExecutionException {
AbstractJiraDownloader jiraDownloader = new AdaptiveJiraDownloader();
File jiraXMLFile = jiraXML;
- jiraDownloader.setLog( getLog() );
+ jiraDownloader.setLog(getLog());
- jiraDownloader.setOutput( jiraXMLFile );
+ jiraDownloader.setOutput(jiraXMLFile);
- jiraDownloader.setStatusIds( statusIds );
+ jiraDownloader.setStatusIds(statusIds);
- jiraDownloader.setResolutionIds( resolutionIds );
+ jiraDownloader.setResolutionIds(resolutionIds);
- jiraDownloader.setMavenProject( project );
+ jiraDownloader.setMavenProject(project);
- jiraDownloader.setSettings( settings );
+ jiraDownloader.setSettings(settings);
- jiraDownloader.setNbEntries( maxEntries );
+ jiraDownloader.setNbEntries(maxEntries);
- jiraDownloader.setFilter( filter );
+ jiraDownloader.setFilter(filter);
- if ( jiraServerId != null )
- {
- final Server server = mavenSession.getSettings().getServer( jiraServerId );
- jiraDownloader.setJiraUser( server.getUsername() );
- jiraDownloader.setJiraPassword( server.getPassword() );
- }
- else
- {
- jiraDownloader.setJiraUser( jiraUser );
- jiraDownloader.setJiraPassword( jiraPassword );
+ if (jiraServerId != null) {
+ final Server server = mavenSession.getSettings().getServer(jiraServerId);
+ jiraDownloader.setJiraUser(server.getUsername());
+ jiraDownloader.setJiraPassword(server.getPassword());
+ } else {
+ jiraDownloader.setJiraUser(jiraUser);
+ jiraDownloader.setJiraPassword(jiraPassword);
}
- jiraDownloader.setUseJql( useJql );
+ jiraDownloader.setUseJql(useJql);
- jiraDownloader.setWebUser( webUser );
+ jiraDownloader.setWebUser(webUser);
- jiraDownloader.setWebPassword( webPassword );
+ jiraDownloader.setWebPassword(webPassword);
- jiraDownloader.setConnectionTimeout( jiraConnectionTimeout );
+ jiraDownloader.setConnectionTimeout(jiraConnectionTimeout);
- jiraDownloader.setReceiveTimout( jiraReceiveTimout );
+ jiraDownloader.setReceiveTimout(jiraReceiveTimout);
- try
- {
+ try {
jiraDownloader.doExecute();
List issueList = jiraDownloader.getIssueList();
- if ( versionPrefix != null && !versionPrefix.isEmpty() )
- {
+ if (versionPrefix != null && !versionPrefix.isEmpty()) {
int originalNumberOfIssues = issueList.size();
- issueList = IssueUtils.filterIssuesWithVersionPrefix( issueList, versionPrefix );
- getLog().debug( "Filtered out " + issueList.size() + " issues of " + originalNumberOfIssues
- + " that matched the versionPrefix '" + versionPrefix + "'." );
+ issueList = IssueUtils.filterIssuesWithVersionPrefix(issueList, versionPrefix);
+ getLog().debug("Filtered out " + issueList.size() + " issues of " + originalNumberOfIssues
+ + " that matched the versionPrefix '" + versionPrefix + "'.");
}
- return getReleases( issueList, new JIRAIssueManagmentSystem() );
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( "Failed to extract issues from JIRA.", e );
+ return getReleases(issueList, new JIRAIssueManagmentSystem());
+ } catch (Exception e) {
+ throw new MojoExecutionException("Failed to extract issues from JIRA.", e);
}
}
- private List getReleases( List issues, IssueManagementSystem ims )
- throws MojoExecutionException
- {
- if ( issueTypes != null )
- {
- ims.applyConfiguration( issueTypes );
+ private List getReleases(List issues, IssueManagementSystem ims) throws MojoExecutionException {
+ if (issueTypes != null) {
+ ims.applyConfiguration(issueTypes);
}
- if ( issues.isEmpty() )
- {
+ if (issues.isEmpty()) {
return Collections.emptyList();
- }
- else
- {
- IssueAdapter adapter = new IssueAdapter( ims );
- return adapter.getReleases( issues );
+ } else {
+ IssueAdapter adapter = new IssueAdapter(ims);
+ return adapter.getReleases(issues);
}
}
- protected List getTracReleases()
- throws MojoExecutionException
- {
+ protected List getTracReleases() throws MojoExecutionException {
TracDownloader issueDownloader = new TracDownloader();
- issueDownloader.setProject( project );
+ issueDownloader.setProject(project);
- issueDownloader.setQuery( tracQuery );
+ issueDownloader.setQuery(tracQuery);
- issueDownloader.setTracPassword( tracPassword );
+ issueDownloader.setTracPassword(tracPassword);
- issueDownloader.setTracUser( tracUser );
+ issueDownloader.setTracUser(tracUser);
- try
- {
- return getReleases( issueDownloader.getIssueList(), new TracIssueManagmentSystem() );
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( "Failed to extract issues from Trac.", e );
+ try {
+ return getReleases(issueDownloader.getIssueList(), new TracIssueManagmentSystem());
+ } catch (Exception e) {
+ throw new MojoExecutionException("Failed to extract issues from Trac.", e);
}
}
- protected List getGitHubReleases()
- throws MojoExecutionException
- {
- try
- {
+ protected List getGitHubReleases() throws MojoExecutionException {
+ try {
GitHubDownloader issueDownloader =
- new GitHubDownloader( project, githubAPIScheme, githubAPIPort, includeOpenIssues, true );
+ new GitHubDownloader(project, githubAPIScheme, githubAPIPort, includeOpenIssues, true);
- issueDownloader.configureAuthentication( settingsDecrypter, githubAPIServerId, settings, getLog() );
+ issueDownloader.configureAuthentication(settingsDecrypter, githubAPIServerId, settings, getLog());
- return getReleases( issueDownloader.getIssueList(), new GitHubIssueManagementSystem() );
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( "Failed to extract issues from GitHub.", e );
+ return getReleases(issueDownloader.getIssueList(), new GitHubIssueManagementSystem());
+ } catch (Exception e) {
+ throw new MojoExecutionException("Failed to extract issues from GitHub.", e);
}
}
@@ -882,143 +801,115 @@ protected List getGitHubReleases()
* accessors
*/
- public String getArtifactId()
- {
+ public String getArtifactId() {
return artifactId;
}
- public void setArtifactId( String artifactId )
- {
+ public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
- public String getDevelopmentTeam()
- {
+ public String getDevelopmentTeam() {
return developmentTeam;
}
- public void setDevelopmentTeam( String developmentTeam )
- {
+ public void setDevelopmentTeam(String developmentTeam) {
this.developmentTeam = developmentTeam;
}
- public String getFinalName()
- {
+ public String getFinalName() {
return finalName;
}
- public void setFinalName( String finalName )
- {
+ public void setFinalName(String finalName) {
this.finalName = finalName;
}
- public String getGroupId()
- {
+ public String getGroupId() {
return groupId;
}
- public void setGroupId( String groupId )
- {
+ public void setGroupId(String groupId) {
this.groupId = groupId;
}
- public String getIntroduction()
- {
+ public String getIntroduction() {
return introduction;
}
- public void setIntroduction( String introduction )
- {
+ public void setIntroduction(String introduction) {
this.introduction = introduction;
}
- public void setIssueTypes( Map issueTypes )
- {
+ public void setIssueTypes(Map issueTypes) {
this.issueTypes = issueTypes;
}
- public Map getIssueTypes()
- {
+ public Map getIssueTypes() {
return issueTypes;
}
- public File getAnnouncementDirectory()
- {
+ public File getAnnouncementDirectory() {
return announcementDirectory;
}
- public void setAnnouncementDirectory( File announcementDirectory )
- {
+ public void setAnnouncementDirectory(File announcementDirectory) {
this.announcementDirectory = announcementDirectory;
}
- public String getPackaging()
- {
+ public String getPackaging() {
return packaging;
}
- public void setPackaging( String packaging )
- {
+ public void setPackaging(String packaging) {
this.packaging = packaging;
}
- public String getUrl()
- {
+ public String getUrl() {
return url;
}
- public void setUrl( String url )
- {
+ public void setUrl(String url) {
this.url = url;
}
- public String getUrlDownload()
- {
+ public String getUrlDownload() {
return urlDownload;
}
- public void setUrlDownload( String urlDownload )
- {
+ public void setUrlDownload(String urlDownload) {
this.urlDownload = urlDownload;
}
- public VelocityComponent getVelocity()
- {
+ public VelocityComponent getVelocity() {
return velocity;
}
- public void setVelocity( VelocityComponent velocity )
- {
+ public void setVelocity(VelocityComponent velocity) {
this.velocity = velocity;
}
- public String getVersion()
- {
+ public String getVersion() {
return version;
}
- public void setVersion( String version )
- {
+ public void setVersion(String version) {
this.version = version;
}
- public ChangesXML getXml()
- {
+ public ChangesXML getXml() {
return xml;
}
- public void setXml( ChangesXML xml )
- {
+ public void setXml(ChangesXML xml) {
this.xml = xml;
}
- public File getXmlPath()
- {
+ public File getXmlPath() {
return xmlPath;
}
- public void setXmlPath( File xmlPath )
- {
+ public void setXmlPath(File xmlPath) {
this.xmlPath = xmlPath;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/announcement/MailSender.java b/src/main/java/org/apache/maven/plugins/announcement/MailSender.java
index bfb5eaab..6e25d9fc 100644
--- a/src/main/java/org/apache/maven/plugins/announcement/MailSender.java
+++ b/src/main/java/org/apache/maven/plugins/announcement/MailSender.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.announcement;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.announcement;
/**
* Defines the sender of the announcement if the list of developer is empty or if the sender is not a member of the
@@ -25,46 +24,38 @@
*
* @author Stephane Nicoll
*/
-public class MailSender
-{
+public class MailSender {
private String name;
private String email;
- public MailSender()
- {
+ public MailSender() {
super();
}
- public MailSender( String name, String email )
- {
+ public MailSender(String name, String email) {
this.name = name;
this.email = email;
}
- public String getName()
- {
+ public String getName() {
return name;
}
- public void setName( String name )
- {
+ public void setName(String name) {
this.name = name;
}
- public String getEmail()
- {
+ public String getEmail() {
return email;
}
- public void setEmail( String email )
- {
+ public void setEmail(String email) {
this.email = email;
}
- public String toString()
- {
+ public String toString() {
return getName() + " (" + getEmail() + ")";
}
}
diff --git a/src/main/java/org/apache/maven/plugins/announcement/mailsender/ProjectJavamailMailSender.java b/src/main/java/org/apache/maven/plugins/announcement/mailsender/ProjectJavamailMailSender.java
index a95414df..0b73b5de 100644
--- a/src/main/java/org/apache/maven/plugins/announcement/mailsender/ProjectJavamailMailSender.java
+++ b/src/main/java/org/apache/maven/plugins/announcement/mailsender/ProjectJavamailMailSender.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.announcement.mailsender;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import java.util.Date;
-import java.util.Properties;
+package org.apache.maven.plugins.announcement.mailsender;
import javax.mail.Authenticator;
import javax.mail.Message;
@@ -31,6 +27,9 @@
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
+import java.util.Date;
+import java.util.Properties;
+
import org.codehaus.plexus.mailsender.AbstractMailSender;
import org.codehaus.plexus.mailsender.MailMessage;
import org.codehaus.plexus.mailsender.MailSenderException;
@@ -40,9 +39,7 @@
/**
* Helper class for sending email.
*/
-public class ProjectJavamailMailSender
- extends AbstractMailSender
-{
+public class ProjectJavamailMailSender extends AbstractMailSender {
private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
// ----------------------------------------------------------------------
@@ -57,54 +54,46 @@ public class ProjectJavamailMailSender
// Component Lifecycle
// ----------------------------------------------------------------------
- public void initialize()
- {
- if ( StringUtils.isEmpty( getSmtpHost() ) )
- {
- System.out.println( "Error in configuration: Missing smtpHost." );
+ public void initialize() {
+ if (StringUtils.isEmpty(getSmtpHost())) {
+ System.out.println("Error in configuration: Missing smtpHost.");
}
- if ( getSmtpPort() == 0 )
- {
- setSmtpPort( DEFAULT_SMTP_PORT );
+ if (getSmtpPort() == 0) {
+ setSmtpPort(DEFAULT_SMTP_PORT);
}
props = new Properties();
- props.put( "mail.smtp.host", getSmtpHost() );
+ props.put("mail.smtp.host", getSmtpHost());
- props.put( "mail.smtp.port", String.valueOf( getSmtpPort() ) );
+ props.put("mail.smtp.port", String.valueOf(getSmtpPort()));
- if ( getUsername() != null )
- {
- props.put( "mail.smtp.auth", "true" );
+ if (getUsername() != null) {
+ props.put("mail.smtp.auth", "true");
}
- props.put( "mail.debug", String.valueOf( getLogger().isDebugEnabled() ) );
+ props.put("mail.debug", String.valueOf(getLogger().isDebugEnabled()));
- if ( isSslMode() )
- {
- props.put( "mail.smtp.socketFactory.port", String.valueOf( getSmtpPort() ) );
+ if (isSslMode()) {
+ props.put("mail.smtp.socketFactory.port", String.valueOf(getSmtpPort()));
- props.put( "mail.smtp.socketFactory.class", SSL_FACTORY );
+ props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
- props.put( "mail.smtp.socketFactory.fallback", "false" );
- }
+ props.put("mail.smtp.socketFactory.fallback", "false");
+ }
- if ( isTlsEnabled() )
- {
- props.put( "mail.smtp.starttls.enable", "true" );
+ if (isTlsEnabled()) {
+ props.put("mail.smtp.starttls.enable", "true");
}
- if ( userProperties != null )
- {
- for ( Object o : userProperties.keySet() )
- {
+ if (userProperties != null) {
+ for (Object o : userProperties.keySet()) {
String key = (String) o;
- String value = userProperties.getProperty( key );
+ String value = userProperties.getProperty(key);
- props.put( key, value );
+ props.put(key, value);
}
}
}
@@ -113,89 +102,75 @@ public void initialize()
// MailSender Implementation
// ----------------------------------------------------------------------
- public void send( MailMessage mail )
- throws MailSenderException
- {
- verify( mail );
+ public void send(MailMessage mail) throws MailSenderException {
+ verify(mail);
- try
- {
+ try {
Authenticator auth = null;
- if ( getUsername() != null )
- {
- auth = new Authenticator()
- {
- protected PasswordAuthentication getPasswordAuthentication()
- {
- return new PasswordAuthentication( getUsername(), getPassword() );
+ if (getUsername() != null) {
+ auth = new Authenticator() {
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(getUsername(), getPassword());
}
};
}
- Session session = Session.getDefaultInstance( props, auth );
+ Session session = Session.getDefaultInstance(props, auth);
- session.setDebug( getLogger().isDebugEnabled() );
+ session.setDebug(getLogger().isDebugEnabled());
- Message msg = new MimeMessage( session );
- InternetAddress addressFrom = new InternetAddress( mail.getFrom().getRfc2822Address() );
- msg.setFrom( addressFrom );
+ Message msg = new MimeMessage(session);
+ InternetAddress addressFrom = new InternetAddress(mail.getFrom().getRfc2822Address());
+ msg.setFrom(addressFrom);
- if ( mail.getToAddresses().size() > 0 )
- {
- InternetAddress[] addressTo = new InternetAddress[mail.getToAddresses().size()];
+ if (mail.getToAddresses().size() > 0) {
+ InternetAddress[] addressTo =
+ new InternetAddress[mail.getToAddresses().size()];
int count = 0;
- for ( Object o : mail.getToAddresses() )
- {
- String address = ( (MailMessage.Address) o ).getRfc2822Address();
- addressTo[count++] = new InternetAddress( address );
+ for (Object o : mail.getToAddresses()) {
+ String address = ((MailMessage.Address) o).getRfc2822Address();
+ addressTo[count++] = new InternetAddress(address);
}
- msg.setRecipients( Message.RecipientType.TO, addressTo );
+ msg.setRecipients(Message.RecipientType.TO, addressTo);
}
- if ( mail.getCcAddresses().size() > 0 )
- {
- InternetAddress[] addressCc = new InternetAddress[mail.getCcAddresses().size()];
+ if (mail.getCcAddresses().size() > 0) {
+ InternetAddress[] addressCc =
+ new InternetAddress[mail.getCcAddresses().size()];
int count = 0;
- for ( Object o : mail.getCcAddresses() )
- {
- String address = ( (MailMessage.Address) o ).getRfc2822Address();
- addressCc[count++] = new InternetAddress( address );
+ for (Object o : mail.getCcAddresses()) {
+ String address = ((MailMessage.Address) o).getRfc2822Address();
+ addressCc[count++] = new InternetAddress(address);
}
- msg.setRecipients( Message.RecipientType.CC, addressCc );
+ msg.setRecipients(Message.RecipientType.CC, addressCc);
}
- if ( mail.getBccAddresses().size() > 0 )
- {
- InternetAddress[] addressBcc = new InternetAddress[mail.getBccAddresses().size()];
+ if (mail.getBccAddresses().size() > 0) {
+ InternetAddress[] addressBcc =
+ new InternetAddress[mail.getBccAddresses().size()];
int count = 0;
- for ( Object o : mail.getBccAddresses() )
- {
- String address = ( (MailMessage.Address ) o ).getRfc2822Address();
- addressBcc[count++] = new InternetAddress( address );
+ for (Object o : mail.getBccAddresses()) {
+ String address = ((MailMessage.Address) o).getRfc2822Address();
+ addressBcc[count++] = new InternetAddress(address);
}
- msg.setRecipients( Message.RecipientType.BCC, addressBcc );
+ msg.setRecipients(Message.RecipientType.BCC, addressBcc);
}
// Setting the Subject and Content Type
- msg.setSubject( mail.getSubject() );
- msg.setContent( mail.getContent(), mail.getContentType() == null ? "text/plain" : mail.getContentType() );
+ msg.setSubject(mail.getSubject());
+ msg.setContent(mail.getContent(), mail.getContentType() == null ? "text/plain" : mail.getContentType());
- if ( mail.getSendDate() != null )
- {
- msg.setHeader( "Date", DateFormatUtils.getDateHeader( mail.getSendDate() ) );
- }
- else
- {
- msg.setHeader( "Date", DateFormatUtils.getDateHeader( new Date() ) );
+ if (mail.getSendDate() != null) {
+ msg.setHeader("Date", DateFormatUtils.getDateHeader(mail.getSendDate()));
+ } else {
+ msg.setHeader("Date", DateFormatUtils.getDateHeader(new Date()));
}
// Send the message
- Transport.send( msg );
- }
- catch ( MessagingException e )
- {
- throw new MailSenderException( "Error while sending mail.", e );
+ Transport.send(msg);
+ } catch (MessagingException e) {
+ throw new MailSenderException("Error while sending mail.", e);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/AbstractChangesMojo.java b/src/main/java/org/apache/maven/plugins/changes/AbstractChangesMojo.java
index 19683942..4e56293e 100644
--- a/src/main/java/org/apache/maven/plugins/changes/AbstractChangesMojo.java
+++ b/src/main/java/org/apache/maven/plugins/changes/AbstractChangesMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
@@ -29,15 +28,13 @@
* @version $Id$
* @since 2.9
*/
-public abstract class AbstractChangesMojo
- extends AbstractMojo
-{
+public abstract class AbstractChangesMojo extends AbstractMojo {
/**
* The current project base directory.
*
* @since 2.1
*/
- @Parameter( property = "basedir", required = true )
+ @Parameter(property = "basedir", required = true)
protected String basedir;
/**
@@ -45,7 +42,7 @@ public abstract class AbstractChangesMojo
*
* @since 2.3
*/
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
protected MavenSession mavenSession;
/**
@@ -54,7 +51,7 @@ public abstract class AbstractChangesMojo
*
* @since 2.9
*/
- @Parameter( property = "changes.runOnlyAtExecutionRoot", defaultValue = "false" )
+ @Parameter(property = "changes.runOnlyAtExecutionRoot", defaultValue = "false")
protected boolean runOnlyAtExecutionRoot;
/**
@@ -63,18 +60,14 @@ public abstract class AbstractChangesMojo
*
* @return true
if the current project is at the Execution Root
*/
- protected boolean isThisTheExecutionRoot()
- {
- getLog().debug( "Root Folder:" + mavenSession.getExecutionRootDirectory() );
- getLog().debug( "Current Folder:" + basedir );
- boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase( basedir );
- if ( result )
- {
- getLog().debug( "This is the execution root." );
- }
- else
- {
- getLog().debug( "This is NOT the execution root." );
+ protected boolean isThisTheExecutionRoot() {
+ getLog().debug("Root Folder:" + mavenSession.getExecutionRootDirectory());
+ getLog().debug("Current Folder:" + basedir);
+ boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase(basedir);
+ if (result) {
+ getLog().debug("This is the execution root.");
+ } else {
+ getLog().debug("This is NOT the execution root.");
}
return result;
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java b/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java
index 54cd9cd7..60249de4 100644
--- a/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java
+++ b/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.maven.artifact.Artifact;
@@ -44,30 +52,19 @@
import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.util.ReaderFactory;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
/**
* Base class with the things that should be in AbstractMavenReport anyway. Note: This file was copied from r415312 of
* AbstractProjectInfoReport in maven-project-info-reports, as a work-around to MCHANGES-88.
*
* @author Brett Porter
*/
-public abstract class AbstractChangesReport
- extends AbstractMavenReport
-{
+public abstract class AbstractChangesReport extends AbstractMavenReport {
/**
* The current project base directory.
*
* @since 2.10
*/
- @Parameter( property = "basedir", required = true )
+ @Parameter(property = "basedir", required = true)
protected String basedir;
/**
@@ -75,7 +72,7 @@ public abstract class AbstractChangesReport
* from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output
* directory configured in the Maven Site Plugin is used instead.
*/
- @Parameter( defaultValue = "${project.reporting.outputDirectory}" )
+ @Parameter(defaultValue = "${project.reporting.outputDirectory}")
private File outputDirectory;
/**
@@ -85,7 +82,7 @@ public abstract class AbstractChangesReport
*
* @since 2.4
*/
- @Parameter( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" )
+ @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}")
private String outputEncoding;
/**
@@ -94,7 +91,7 @@ public abstract class AbstractChangesReport
*
* @since 2.10
*/
- @Parameter( property = "changes.runOnlyAtExecutionRoot", defaultValue = "false" )
+ @Parameter(property = "changes.runOnlyAtExecutionRoot", defaultValue = "false")
protected boolean runOnlyAtExecutionRoot;
/**
@@ -102,7 +99,7 @@ public abstract class AbstractChangesReport
*
* @since 2.10
*/
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
protected MavenSession mavenSession;
/**
@@ -114,7 +111,7 @@ public abstract class AbstractChangesReport
/**
* The Maven Project.
*/
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;
/**
@@ -128,80 +125,66 @@ public abstract class AbstractChangesReport
@Component
protected I18N i18n;
- private Artifact getSkinArtifact()
- throws MojoExecutionException
- {
+ private Artifact getSkinArtifact() throws MojoExecutionException {
Skin skin = Skin.getDefaultSkin();
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
- coordinate.setGroupId( skin.getGroupId() );
- coordinate.setArtifactId( skin.getArtifactId() );
- coordinate.setVersion( skin.getVersion() );
- ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest( mavenSession.getProjectBuildingRequest() );
- pbr.setRemoteRepositories( project.getRemoteArtifactRepositories() );
- try
- {
- return resolver.resolveArtifact( pbr, coordinate ).getArtifact();
- }
- catch ( ArtifactResolverException e )
- {
- throw new MojoExecutionException( "Couldn't resolve the skin.", e );
+ coordinate.setGroupId(skin.getGroupId());
+ coordinate.setArtifactId(skin.getArtifactId());
+ coordinate.setVersion(skin.getVersion());
+ ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest(mavenSession.getProjectBuildingRequest());
+ pbr.setRemoteRepositories(project.getRemoteArtifactRepositories());
+ try {
+ return resolver.resolveArtifact(pbr, coordinate).getArtifact();
+ } catch (ArtifactResolverException e) {
+ throw new MojoExecutionException("Couldn't resolve the skin.", e);
}
}
- public void execute()
- throws MojoExecutionException
- {
- if ( !canGenerateReport() )
- {
+ public void execute() throws MojoExecutionException {
+ if (!canGenerateReport()) {
return;
}
// TODO: push to a helper? Could still be improved by taking more of the site information from the site plugin
Writer writer = null;
- try
- {
+ try {
DecorationModel model = new DecorationModel();
- model.setBody( new Body() );
+ model.setBody(new Body());
Map attributes = new HashMap<>();
- attributes.put( "outputEncoding", getOutputEncoding() );
+ attributes.put("outputEncoding", getOutputEncoding());
Locale locale = Locale.getDefault();
- SiteRenderingContext siteContext = siteRenderer.createContextForSkin( getSkinArtifact(), attributes,
- model, getName( locale ), locale );
- siteContext.setOutputEncoding( getOutputEncoding() );
+ SiteRenderingContext siteContext =
+ siteRenderer.createContextForSkin(getSkinArtifact(), attributes, model, getName(locale), locale);
+ siteContext.setOutputEncoding(getOutputEncoding());
- RenderingContext context = new RenderingContext( outputDirectory, getOutputName() + ".html" );
+ RenderingContext context = new RenderingContext(outputDirectory, getOutputName() + ".html");
- SiteRendererSink sink = new SiteRendererSink( context );
- generate( sink, null, locale );
+ SiteRendererSink sink = new SiteRendererSink(context);
+ generate(sink, null, locale);
outputDirectory.mkdirs();
- File file = new File( outputDirectory, getOutputName() + ".html" );
- writer = new OutputStreamWriter( new FileOutputStream( file ), getOutputEncoding() );
+ File file = new File(outputDirectory, getOutputName() + ".html");
+ writer = new OutputStreamWriter(new FileOutputStream(file), getOutputEncoding());
- siteRenderer.generateDocument( writer, sink, siteContext );
+ siteRenderer.generateDocument(writer, sink, siteContext);
writer.close();
writer = null;
- siteRenderer.copyResources( siteContext, outputDirectory );
- }
- catch ( RendererException | IOException | MavenReportException e )
- {
- throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
- + " report generation.", e );
- }
- finally
- {
- IOUtils.closeQuietly( writer );
+ siteRenderer.copyResources(siteContext, outputDirectory);
+ } catch (RendererException | IOException | MavenReportException e) {
+ throw new MojoExecutionException(
+ "An error has occurred in " + getName(Locale.ENGLISH) + " report generation.", e);
+ } finally {
+ IOUtils.closeQuietly(writer);
}
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
*/
- protected String getOutputDirectory()
- {
+ protected String getOutputDirectory() {
return outputDirectory.getAbsolutePath();
}
@@ -211,24 +194,21 @@ protected String getOutputDirectory()
* @return The effective reporting output file encoding, never null
.
* @since 2.4
*/
- protected String getOutputEncoding()
- {
- return ( outputEncoding != null ) ? outputEncoding : ReaderFactory.UTF_8;
+ protected String getOutputEncoding() {
+ return (outputEncoding != null) ? outputEncoding : ReaderFactory.UTF_8;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getProject()
*/
- protected MavenProject getProject()
- {
+ protected MavenProject getProject() {
return project;
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
*/
- protected Renderer getSiteRenderer()
- {
+ protected Renderer getSiteRenderer() {
return siteRenderer;
}
@@ -238,18 +218,14 @@ protected Renderer getSiteRenderer()
*
* @return true
if the current project is at the Execution Root
*/
- protected boolean isThisTheExecutionRoot()
- {
- getLog().debug( "Root Folder:" + mavenSession.getExecutionRootDirectory() );
- getLog().debug( "Current Folder:" + basedir );
- boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase( basedir );
- if ( result )
- {
- getLog().debug( "This is the execution root." );
- }
- else
- {
- getLog().debug( "This is NOT the execution root." );
+ protected boolean isThisTheExecutionRoot() {
+ getLog().debug("Root Folder:" + mavenSession.getExecutionRootDirectory());
+ getLog().debug("Current Folder:" + basedir);
+ boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase(basedir);
+ if (result) {
+ getLog().debug("This is the execution root.");
+ } else {
+ getLog().debug("This is NOT the execution root.");
}
return result;
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java b/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java
index 1c60d0e4..0ec1232e 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import java.io.File;
import java.text.ParseException;
@@ -38,14 +37,12 @@
* @author Dennis Lundberg
* @since 2.4
*/
-@Mojo( name = "changes-check", threadSafe = true )
-public class ChangesCheckMojo
- extends AbstractChangesMojo
-{
+@Mojo(name = "changes-check", threadSafe = true)
+public class ChangesCheckMojo extends AbstractChangesMojo {
/**
* The format that a correct release date should have. This value will be used as a pattern to try to parse a date.
*/
- @Parameter( property = "changes.releaseDateFormat", defaultValue = "yyyy-MM-dd" )
+ @Parameter(property = "changes.releaseDateFormat", defaultValue = "yyyy-MM-dd")
private String releaseDateFormat;
/**
@@ -53,19 +50,19 @@ public class ChangesCheckMojo
*
* @since 2.10
*/
- @Parameter( property = "changes.releaseDateLocale" )
+ @Parameter(property = "changes.releaseDateLocale")
private String releaseDateLocale;
/**
* Version of the artifact.
*/
- @Parameter( property = "changes.version", defaultValue = "${project.version}", required = true )
+ @Parameter(property = "changes.version", defaultValue = "${project.version}", required = true)
private String version;
/**
* The path of the changes.xml
file that will be checked.
*/
- @Parameter( property = "changes.xmlPath", defaultValue = "src/changes/changes.xml" )
+ @Parameter(property = "changes.xmlPath", defaultValue = "src/changes/changes.xml")
private File xmlPath;
/**
@@ -73,7 +70,7 @@ public class ChangesCheckMojo
*
* @since 2.7
*/
- @Parameter( property = "changes.skipSnapshots", defaultValue = "false" )
+ @Parameter(property = "changes.skipSnapshots", defaultValue = "false")
private boolean skipSnapshots;
/**
@@ -81,37 +78,24 @@ public class ChangesCheckMojo
*
* @throws MojoExecutionException in case of errors.
*/
- public void execute()
- throws MojoExecutionException
- {
+ public void execute() throws MojoExecutionException {
// Run only at the execution root
- if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
- {
- getLog().info( "Skipping the changes check in this project because it's not the Execution Root" );
- }
- else
- {
- if ( this.version.endsWith( "-SNAPSHOT" ) && this.skipSnapshots )
- {
- getLog().info( "Skipping snapshot version '" + this.version + "'." );
- }
- else if ( xmlPath.exists() )
- {
- ChangesXML xml = new ChangesXML( xmlPath, getLog() );
- ReleaseUtils releaseUtils = new ReleaseUtils( getLog() );
- Release release =
- releaseUtils.getLatestRelease( xml.getReleaseList(), version );
-
- if ( !isValidDate( release.getDateRelease(), releaseDateFormat, releaseDateLocale ) )
- {
- throw new MojoExecutionException( "The file " + xmlPath.getAbsolutePath()
- + " has an invalid release date." );
-
+ if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
+ getLog().info("Skipping the changes check in this project because it's not the Execution Root");
+ } else {
+ if (this.version.endsWith("-SNAPSHOT") && this.skipSnapshots) {
+ getLog().info("Skipping snapshot version '" + this.version + "'.");
+ } else if (xmlPath.exists()) {
+ ChangesXML xml = new ChangesXML(xmlPath, getLog());
+ ReleaseUtils releaseUtils = new ReleaseUtils(getLog());
+ Release release = releaseUtils.getLatestRelease(xml.getReleaseList(), version);
+
+ if (!isValidDate(release.getDateRelease(), releaseDateFormat, releaseDateLocale)) {
+ throw new MojoExecutionException(
+ "The file " + xmlPath.getAbsolutePath() + " has an invalid release date.");
}
- }
- else
- {
- getLog().warn( "The file " + xmlPath.getAbsolutePath() + " does not exist." );
+ } else {
+ getLog().warn("The file " + xmlPath.getAbsolutePath() + " does not exist.");
}
}
}
@@ -124,9 +108,8 @@ else if ( xmlPath.exists() )
* @param pattern A pattern that can be used by {@link SimpleDateFormat}
* @return true
if the string can be parsed as a date using the pattern, otherwise false
*/
- protected static boolean isValidDate( String string, String pattern )
- {
- return isValidDate( string, pattern, null );
+ protected static boolean isValidDate(String string, String pattern) {
+ return isValidDate(string, pattern, null);
}
/**
@@ -137,55 +120,43 @@ protected static boolean isValidDate( String string, String pattern )
* @param locale A locale that can be used by {@link SimpleDateFormat}
* @return true
if the string can be parsed as a date using the pattern, otherwise false
*/
- protected static boolean isValidDate( String string, String pattern, String locale )
- {
- if ( StringUtils.isEmpty( string ) )
- {
+ protected static boolean isValidDate(String string, String pattern, String locale) {
+ if (StringUtils.isEmpty(string)) {
return false;
}
- if ( StringUtils.isEmpty( pattern ) )
- {
+ if (StringUtils.isEmpty(pattern)) {
return false;
}
- try
- {
+ try {
Locale usedLocale = null;
- if ( StringUtils.isEmpty( locale ) )
- {
+ if (StringUtils.isEmpty(locale)) {
// No locale specified, use the default locale as default value
// The same behavior as before the locale parameter was added
usedLocale = Locale.getDefault();
- }
- else
- {
+ } else {
// Try to find the specified locale on this system
Locale[] locales = Locale.getAvailableLocales();
- for ( Locale value : locales )
- {
- if ( value.toString().equals( locale ) )
- {
+ for (Locale value : locales) {
+ if (value.toString().equals(locale)) {
usedLocale = value;
break;
}
}
- if ( usedLocale == null )
- {
+ if (usedLocale == null) {
// The use specified locale was not found on this system,
// use the default locale as default value
usedLocale = Locale.getDefault();
}
}
- SimpleDateFormat df = new SimpleDateFormat( pattern, usedLocale );
- df.parse( string );
+ SimpleDateFormat df = new SimpleDateFormat(pattern, usedLocale);
+ df.parse(string);
return true;
- }
- catch ( ParseException e )
- {
+ } catch (ParseException e) {
return false;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesMojo.java b/src/main/java/org/apache/maven/plugins/changes/ChangesMojo.java
index 56fa1360..58307fdc 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ChangesMojo.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ChangesMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import java.io.File;
import java.io.FileWriter;
@@ -54,17 +53,15 @@
* @author Johnny R. Ruiz III
* @version $Id$
*/
-@Mojo( name = "changes-report", threadSafe = true )
-public class ChangesMojo
- extends AbstractChangesReport
-{
+@Mojo(name = "changes-report", threadSafe = true)
+public class ChangesMojo extends AbstractChangesReport {
/**
* A flag whether the report should also include changes from child modules. If set to false
, only the
* changes from current project will be written to the report.
*
* @since 2.5
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean aggregated;
/**
@@ -73,7 +70,7 @@ public class ChangesMojo
*
* @since 2.1
*/
- @Parameter( property = "changes.addActionDate", defaultValue = "false" )
+ @Parameter(property = "changes.addActionDate", defaultValue = "false")
private boolean addActionDate;
/**
@@ -98,7 +95,7 @@ public class ChangesMojo
*
* @since 2.2
*/
- @Parameter( defaultValue = "${project.build.directory}/changes", required = true, readonly = true )
+ @Parameter(defaultValue = "${project.build.directory}/changes", required = true, readonly = true)
private File filteredOutputDirectory;
/**
@@ -106,7 +103,7 @@ public class ChangesMojo
*
* @since 2.2
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean filteringChanges;
/**
@@ -122,7 +119,7 @@ public class ChangesMojo
* @since 2.0-beta-2
* @deprecated As of 2.1 use issueLinkTemplatePerSystem: this one will be with system default
*/
- @Parameter( property = "changes.issueLinkTemplate" )
+ @Parameter(property = "changes.issueLinkTemplate")
private String issueLinkTemplate;
/**
@@ -159,7 +156,7 @@ public class ChangesMojo
* @see java.text.SimpleDateFormat
* @since 2.2
*/
- @Parameter( defaultValue = "yyyy-MM-dd" )
+ @Parameter(defaultValue = "yyyy-MM-dd")
private String publishDateFormat;
/**
@@ -168,19 +165,19 @@ public class ChangesMojo
* @see java.util.Locale
* @since 2.2
*/
- @Parameter( defaultValue = "en" )
+ @Parameter(defaultValue = "en")
private String publishDateLocale;
/**
* @since 2.2
*/
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
protected MavenSession session;
/**
* @since 2.4
*/
- @Parameter( defaultValue = "${project.issueManagement.system}", readonly = true )
+ @Parameter(defaultValue = "${project.issueManagement.system}", readonly = true)
private String system;
/**
@@ -189,12 +186,12 @@ public class ChangesMojo
*
* @since 2.4
*/
- @Parameter( defaultValue = "team.html" )
+ @Parameter(defaultValue = "team.html")
private String team;
/**
*/
- @Parameter( defaultValue = "${project.issueManagement.url}", readonly = true )
+ @Parameter(defaultValue = "${project.issueManagement.url}", readonly = true)
private String url;
/**
@@ -215,10 +212,10 @@ public class ChangesMojo
/**
* The path of the changes.xml
file that will be converted into an HTML report.
*/
- @Parameter( property = "changes.xmlPath", defaultValue = "src/changes/changes.xml" )
+ @Parameter(property = "changes.xmlPath", defaultValue = "src/changes/changes.xml")
private File xmlPath;
- private ReleaseUtils releaseUtils = new ReleaseUtils( getLog() );
+ private ReleaseUtils releaseUtils = new ReleaseUtils(getLog());
private CaseInsensitiveMap caseInsensitiveIssueLinkTemplatePerSystem;
@@ -226,154 +223,136 @@ public class ChangesMojo
/* Public methods */
/* --------------------------------------------------------------------- */
- public boolean canGenerateReport()
- {
+ public boolean canGenerateReport() {
// Run only at the execution root
- if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
- {
- getLog().info( "Skipping the Changes Report in this project because it's not the Execution Root" );
+ if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
+ getLog().info("Skipping the Changes Report in this project because it's not the Execution Root");
return false;
}
return xmlPath.isFile();
}
- public void executeReport( Locale locale )
- throws MavenReportException
- {
- failIfUsingDeprecatedParameter( escapeHTML, "escapeHTML",
- "Using markup inside CDATA sections does not work for all output formats!" );
- failIfUsingDeprecatedParameter( issueLinkTemplate, "issueLinkTemplate",
- "You must use 'issueLinkTemplatePerSystem' for the system '"
- + ChangesReportGenerator.DEFAULT_ISSUE_SYSTEM_KEY + "' instead." );
+ public void executeReport(Locale locale) throws MavenReportException {
+ failIfUsingDeprecatedParameter(
+ escapeHTML, "escapeHTML", "Using markup inside CDATA sections does not work for all output formats!");
+ failIfUsingDeprecatedParameter(
+ issueLinkTemplate,
+ "issueLinkTemplate",
+ "You must use 'issueLinkTemplatePerSystem' for the system '"
+ + ChangesReportGenerator.DEFAULT_ISSUE_SYSTEM_KEY + "' instead.");
Date now = new Date();
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat( publishDateFormat, new Locale( publishDateLocale ) );
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat(publishDateFormat, new Locale(publishDateLocale));
Properties additionalProperties = new Properties();
- additionalProperties.put( "publishDate", simpleDateFormat.format( now ) );
+ additionalProperties.put("publishDate", simpleDateFormat.format(now));
- ChangesXML changesXml = getChangesFromFile( xmlPath, project, additionalProperties );
- if ( changesXml == null )
- {
+ ChangesXML changesXml = getChangesFromFile(xmlPath, project, additionalProperties);
+ if (changesXml == null) {
return;
}
- if ( aggregated )
- {
+ if (aggregated) {
final String basePath = project.getBasedir().getAbsolutePath();
final String absolutePath = xmlPath.getAbsolutePath();
- if ( !absolutePath.startsWith( basePath ) )
- {
- getLog().warn( "xmlPath should be within the project dir for aggregated changes report." );
+ if (!absolutePath.startsWith(basePath)) {
+ getLog().warn("xmlPath should be within the project dir for aggregated changes report.");
return;
}
- final String relativePath = absolutePath.substring( basePath.length() );
+ final String relativePath = absolutePath.substring(basePath.length());
List releaseList = changesXml.getReleaseList();
- for ( Object o : project.getCollectedProjects() )
- {
+ for (Object o : project.getCollectedProjects()) {
final MavenProject childProject = (MavenProject) o;
- final File changesFile = new File( childProject.getBasedir(), relativePath );
- final ChangesXML childXml = getChangesFromFile( changesFile, childProject, additionalProperties );
- if ( childXml != null )
- {
+ final File changesFile = new File(childProject.getBasedir(), relativePath);
+ final ChangesXML childXml = getChangesFromFile(changesFile, childProject, additionalProperties);
+ if (childXml != null) {
releaseList =
- releaseUtils.mergeReleases( releaseList, childProject.getName(), childXml.getReleaseList() );
+ releaseUtils.mergeReleases(releaseList, childProject.getName(), childXml.getReleaseList());
}
}
- changesXml.setReleaseList( releaseList );
+ changesXml.setReleaseList(releaseList);
}
- ChangesReportGenerator report = new ChangesReportGenerator( changesXml.getReleaseList() );
+ ChangesReportGenerator report = new ChangesReportGenerator(changesXml.getReleaseList());
- report.setAuthor( changesXml.getAuthor() );
- report.setTitle( changesXml.getTitle() );
+ report.setAuthor(changesXml.getAuthor());
+ report.setTitle(changesXml.getTitle());
- report.setEscapeHTML( true );
+ report.setEscapeHTML(true);
// Create a case insensitive version of issueLinkTemplatePerSystem
// We need something case insensitive to maintain backward compatibility
- if ( issueLinkTemplatePerSystem == null )
- {
+ if (issueLinkTemplatePerSystem == null) {
caseInsensitiveIssueLinkTemplatePerSystem = new CaseInsensitiveMap();
- }
- else
- {
- caseInsensitiveIssueLinkTemplatePerSystem = new CaseInsensitiveMap( issueLinkTemplatePerSystem );
+ } else {
+ caseInsensitiveIssueLinkTemplatePerSystem = new CaseInsensitiveMap(issueLinkTemplatePerSystem);
}
// Set good default values for issue management systems here
- addIssueLinkTemplate( ChangesReportGenerator.DEFAULT_ISSUE_SYSTEM_KEY, "%URL%/ViewIssue.jspa?key=%ISSUE%" );
- addIssueLinkTemplate( "Bitbucket", "%URL%/issue/%ISSUE%" );
- addIssueLinkTemplate( "Bugzilla", "%URL%/show_bug.cgi?id=%ISSUE%" );
- addIssueLinkTemplate( "GitHub", "%URL%/%ISSUE%" );
- addIssueLinkTemplate( "GoogleCode", "%URL%/detail?id=%ISSUE%" );
- addIssueLinkTemplate( "JIRA", "%URL%/%ISSUE%" );
- addIssueLinkTemplate( "Mantis", "%URL%/view.php?id=%ISSUE%" );
- addIssueLinkTemplate( "MKS", "%URL%/viewissue?selection=%ISSUE%" );
- addIssueLinkTemplate( "Redmine", "%URL%/issues/show/%ISSUE%" );
- addIssueLinkTemplate( "Scarab", "%URL%/issues/id/%ISSUE%" );
- addIssueLinkTemplate( "SourceForge", "http://sourceforge.net/support/tracker.php?aid=%ISSUE%" );
- addIssueLinkTemplate( "SourceForge2", "%URL%/%ISSUE%" );
- addIssueLinkTemplate( "Trac", "%URL%/ticket/%ISSUE%" );
- addIssueLinkTemplate( "Trackplus", "%URL%/printItem.action?key=%ISSUE%" );
- addIssueLinkTemplate( "Tuleap", "%URL%/?aid=%ISSUE%" );
- addIssueLinkTemplate( "YouTrack", "%URL%/issue/%ISSUE%" );
+ addIssueLinkTemplate(ChangesReportGenerator.DEFAULT_ISSUE_SYSTEM_KEY, "%URL%/ViewIssue.jspa?key=%ISSUE%");
+ addIssueLinkTemplate("Bitbucket", "%URL%/issue/%ISSUE%");
+ addIssueLinkTemplate("Bugzilla", "%URL%/show_bug.cgi?id=%ISSUE%");
+ addIssueLinkTemplate("GitHub", "%URL%/%ISSUE%");
+ addIssueLinkTemplate("GoogleCode", "%URL%/detail?id=%ISSUE%");
+ addIssueLinkTemplate("JIRA", "%URL%/%ISSUE%");
+ addIssueLinkTemplate("Mantis", "%URL%/view.php?id=%ISSUE%");
+ addIssueLinkTemplate("MKS", "%URL%/viewissue?selection=%ISSUE%");
+ addIssueLinkTemplate("Redmine", "%URL%/issues/show/%ISSUE%");
+ addIssueLinkTemplate("Scarab", "%URL%/issues/id/%ISSUE%");
+ addIssueLinkTemplate("SourceForge", "http://sourceforge.net/support/tracker.php?aid=%ISSUE%");
+ addIssueLinkTemplate("SourceForge2", "%URL%/%ISSUE%");
+ addIssueLinkTemplate("Trac", "%URL%/ticket/%ISSUE%");
+ addIssueLinkTemplate("Trackplus", "%URL%/printItem.action?key=%ISSUE%");
+ addIssueLinkTemplate("Tuleap", "%URL%/?aid=%ISSUE%");
+ addIssueLinkTemplate("YouTrack", "%URL%/issue/%ISSUE%");
// @todo Add more issue management systems here
// Remember to also add documentation in usage.apt.vm
// Show the current issueLinkTemplatePerSystem configuration
- logIssueLinkTemplatePerSystem( caseInsensitiveIssueLinkTemplatePerSystem );
+ logIssueLinkTemplatePerSystem(caseInsensitiveIssueLinkTemplatePerSystem);
- report.setIssueLinksPerSystem( caseInsensitiveIssueLinkTemplatePerSystem );
+ report.setIssueLinksPerSystem(caseInsensitiveIssueLinkTemplatePerSystem);
- report.setSystem( system );
+ report.setSystem(system);
- report.setTeam( team );
+ report.setTeam(team);
- report.setUrl( url );
+ report.setUrl(url);
- report.setAddActionDate( addActionDate );
+ report.setAddActionDate(addActionDate);
- if ( url == null || url.isEmpty() )
- {
- getLog().warn( "No issue management URL defined in POM. Links to your issues will not work correctly." );
+ if (url == null || url.isEmpty()) {
+ getLog().warn("No issue management URL defined in POM. Links to your issues will not work correctly.");
}
boolean feedGenerated = false;
- if ( feedType != null && !feedType.isEmpty() )
- {
- feedGenerated = generateFeed( changesXml, locale );
+ if (feedType != null && !feedType.isEmpty()) {
+ feedGenerated = generateFeed(changesXml, locale);
}
- report.setLinkToFeed( feedGenerated );
+ report.setLinkToFeed(feedGenerated);
- report.doGenerateReport( getBundle( locale ), getSink() );
+ report.doGenerateReport(getBundle(locale), getSink());
// Copy the images
copyStaticResources();
}
- private void failIfUsingDeprecatedParameter( Object value, String name, String message )
- throws MavenReportException
- {
- if ( value != null )
- {
- throw new MavenReportException( "You are using the old parameter '" + name + "'. " + message );
+ private void failIfUsingDeprecatedParameter(Object value, String name, String message) throws MavenReportException {
+ if (value != null) {
+ throw new MavenReportException("You are using the old parameter '" + name + "'. " + message);
}
}
- public String getDescription( Locale locale )
- {
- return getBundle( locale ).getString( "report.issues.description" );
+ public String getDescription(Locale locale) {
+ return getBundle(locale).getString("report.issues.description");
}
- public String getName( Locale locale )
- {
- return getBundle( locale ).getString( "report.issues.name" );
+ public String getName(Locale locale) {
+ return getBundle(locale).getString("report.issues.name");
}
- public String getOutputName()
- {
+ public String getOutputName() {
return "changes-report";
}
@@ -391,44 +370,43 @@ public String getOutputName()
* @return parsed ChangesXML
instance or null if file doesn't exist
* @throws MavenReportException if any errors occurs while parsing
*/
- private ChangesXML getChangesFromFile( File changesXml, MavenProject project, Properties additionalProperties )
- throws MavenReportException
- {
- if ( !changesXml.exists() )
- {
- getLog().warn( "changes.xml file " + changesXml.getAbsolutePath() + " does not exist." );
+ private ChangesXML getChangesFromFile(File changesXml, MavenProject project, Properties additionalProperties)
+ throws MavenReportException {
+ if (!changesXml.exists()) {
+ getLog().warn("changes.xml file " + changesXml.getAbsolutePath() + " does not exist.");
return null;
}
- if ( filteringChanges )
- {
- if ( !filteredOutputDirectory.exists() )
- {
+ if (filteringChanges) {
+ if (!filteredOutputDirectory.exists()) {
filteredOutputDirectory.mkdirs();
}
- try
- {
+ try {
// so we get encoding from the file itself
- try ( XmlStreamReader xmlStreamReader = new XmlStreamReader( changesXml ) )
- {
+ try (XmlStreamReader xmlStreamReader = new XmlStreamReader(changesXml)) {
String encoding = xmlStreamReader.getEncoding();
- File resultFile = new File( filteredOutputDirectory,
- project.getGroupId() + "." + project.getArtifactId() + "-changes.xml" );
-
- final MavenFileFilterRequest mavenFileFilterRequest =
- new MavenFileFilterRequest( changesXml, resultFile, true, project,
- Collections.emptyList(), false, encoding, session, additionalProperties );
- mavenFileFilter.copyFile( mavenFileFilterRequest );
+ File resultFile = new File(
+ filteredOutputDirectory,
+ project.getGroupId() + "." + project.getArtifactId() + "-changes.xml");
+
+ final MavenFileFilterRequest mavenFileFilterRequest = new MavenFileFilterRequest(
+ changesXml,
+ resultFile,
+ true,
+ project,
+ Collections.emptyList(),
+ false,
+ encoding,
+ session,
+ additionalProperties);
+ mavenFileFilter.copyFile(mavenFileFilterRequest);
changesXml = resultFile;
}
+ } catch (IOException | MavenFilteringException e) {
+ throw new MavenReportException("Exception during filtering changes file : " + e.getMessage(), e);
}
- catch ( IOException | MavenFilteringException e )
- {
- throw new MavenReportException( "Exception during filtering changes file : " + e.getMessage(), e );
- }
-
}
- return new ChangesXML( changesXml, getLog() );
+ return new ChangesXML(changesXml, getLog());
}
/**
@@ -439,105 +417,85 @@ private ChangesXML getChangesFromFile( File changesXml, MavenProject project, Pr
* @param issueLinkTemplate The issue link template to use
* @since 2.4
*/
- private void addIssueLinkTemplate( String system, String issueLinkTemplate )
- {
- if ( caseInsensitiveIssueLinkTemplatePerSystem == null )
- {
+ private void addIssueLinkTemplate(String system, String issueLinkTemplate) {
+ if (caseInsensitiveIssueLinkTemplatePerSystem == null) {
caseInsensitiveIssueLinkTemplatePerSystem = new CaseInsensitiveMap();
}
- if ( !caseInsensitiveIssueLinkTemplatePerSystem.containsKey( system ) )
- {
- caseInsensitiveIssueLinkTemplatePerSystem.put( system, issueLinkTemplate );
+ if (!caseInsensitiveIssueLinkTemplatePerSystem.containsKey(system)) {
+ caseInsensitiveIssueLinkTemplatePerSystem.put(system, issueLinkTemplate);
}
}
- private void copyStaticResources()
- throws MavenReportException
- {
+ private void copyStaticResources() throws MavenReportException {
final String pluginResourcesBase = "org/apache/maven/plugins/changes";
- String[] resourceNames = { "images/add.gif", "images/fix.gif", "images/icon_help_sml.gif", "images/remove.gif",
- "images/rss.png", "images/update.gif" };
- try
- {
- getLog().debug( "Copying static resources." );
- for ( String resourceName : resourceNames )
- {
- URL url = this.getClass().getClassLoader().getResource( pluginResourcesBase + "/" + resourceName );
- FileUtils.copyURLToFile( url, new File( getReportOutputDirectory(), resourceName ) );
+ String[] resourceNames = {
+ "images/add.gif",
+ "images/fix.gif",
+ "images/icon_help_sml.gif",
+ "images/remove.gif",
+ "images/rss.png",
+ "images/update.gif"
+ };
+ try {
+ getLog().debug("Copying static resources.");
+ for (String resourceName : resourceNames) {
+ URL url = this.getClass().getClassLoader().getResource(pluginResourcesBase + "/" + resourceName);
+ FileUtils.copyURLToFile(url, new File(getReportOutputDirectory(), resourceName));
}
- }
- catch ( IOException e )
- {
- throw new MavenReportException( "Unable to copy static resources." );
+ } catch (IOException e) {
+ throw new MavenReportException("Unable to copy static resources.");
}
}
- private ResourceBundle getBundle( Locale locale )
- {
- return ResourceBundle.getBundle( "changes-report", locale, this.getClass().getClassLoader() );
+ private ResourceBundle getBundle(Locale locale) {
+ return ResourceBundle.getBundle(
+ "changes-report", locale, this.getClass().getClassLoader());
}
- protected String getTeam()
- {
+ protected String getTeam() {
return team;
}
- private void logIssueLinkTemplatePerSystem( Map issueLinkTemplatePerSystem )
- {
- if ( getLog().isDebugEnabled() )
- {
- if ( issueLinkTemplatePerSystem == null )
- {
- getLog().debug( "No issueLinkTemplatePerSystem configuration was found" );
- }
- else
- {
- for ( Entry entry : issueLinkTemplatePerSystem.entrySet() )
- {
- getLog().debug( "issueLinkTemplatePerSystem[" + entry.getKey() + "] = " + entry.getValue() );
+ private void logIssueLinkTemplatePerSystem(Map issueLinkTemplatePerSystem) {
+ if (getLog().isDebugEnabled()) {
+ if (issueLinkTemplatePerSystem == null) {
+ getLog().debug("No issueLinkTemplatePerSystem configuration was found");
+ } else {
+ for (Entry entry : issueLinkTemplatePerSystem.entrySet()) {
+ getLog().debug("issueLinkTemplatePerSystem[" + entry.getKey() + "] = " + entry.getValue());
}
}
}
}
- private boolean generateFeed( final ChangesXML changesXml, final Locale locale )
- {
- getLog().debug( "Generating " + feedType + " feed." );
+ private boolean generateFeed(final ChangesXML changesXml, final Locale locale) {
+ getLog().debug("Generating " + feedType + " feed.");
boolean success = true;
- final FeedGenerator feed = new FeedGenerator( locale );
- feed.setLink( project.getUrl() + "/changes-report.html" ); // TODO: better way?
- feed.setTitle( project.getName() + ": " + changesXml.getTitle() );
- feed.setAuthor( changesXml.getAuthor() );
- feed.setDateFormat( new SimpleDateFormat( publishDateFormat, new Locale( publishDateLocale ) ) );
+ final FeedGenerator feed = new FeedGenerator(locale);
+ feed.setLink(project.getUrl() + "/changes-report.html"); // TODO: better way?
+ feed.setTitle(project.getName() + ": " + changesXml.getTitle());
+ feed.setAuthor(changesXml.getAuthor());
+ feed.setDateFormat(new SimpleDateFormat(publishDateFormat, new Locale(publishDateLocale)));
Writer writer = null;
- try
- {
- writer = new FileWriter( new File( getReportOutputDirectory(), "changes.rss" ) );
- feed.export( changesXml.getReleaseList(), feedType, writer );
- }
- catch ( IOException ex )
- {
+ try {
+ writer = new FileWriter(new File(getReportOutputDirectory(), "changes.rss"));
+ feed.export(changesXml.getReleaseList(), feedType, writer);
+ } catch (IOException ex) {
success = false;
- getLog().warn( "Failed to create rss feed: " + ex.getMessage() );
- getLog().debug( ex );
- }
- finally
- {
- try
- {
- if ( writer != null )
- {
+ getLog().warn("Failed to create rss feed: " + ex.getMessage());
+ getLog().debug(ex);
+ } finally {
+ try {
+ if (writer != null) {
writer.close();
}
- }
- catch ( IOException ex )
- {
- getLog().warn( "Failed to close writer: " + ex.getMessage() );
- getLog().debug( ex );
+ } catch (IOException ex) {
+ getLog().warn("Failed to close writer: " + ex.getMessage());
+ getLog().debug(ex);
}
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java b/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java
index d962f734..a1ff1dfb 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import java.util.HashMap;
import java.util.Iterator;
@@ -27,7 +26,6 @@
import java.util.ResourceBundle;
import org.apache.commons.lang.StringUtils;
-
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
@@ -44,9 +42,7 @@
*
* @version $Id$
*/
-public class ChangesReportGenerator
- extends AbstractIssuesReportGenerator
-{
+public class ChangesReportGenerator extends AbstractIssuesReportGenerator {
/**
* The token in {@link #issueLinksPerSystem} denoting the base URL for the issue management.
@@ -89,88 +85,71 @@ public class ChangesReportGenerator
*/
private List releaseList;
- public ChangesReportGenerator()
- {
+ public ChangesReportGenerator() {
issueLinksPerSystem = new HashMap<>();
}
- public ChangesReportGenerator( List releaseList )
- {
+ public ChangesReportGenerator(List releaseList) {
this();
this.releaseList = releaseList;
}
- public boolean isEscapeHTML()
- {
+ public boolean isEscapeHTML() {
return escapeHTML;
}
- public void setEscapeHTML( boolean escapeHTML )
- {
+ public void setEscapeHTML(boolean escapeHTML) {
this.escapeHTML = escapeHTML;
}
- public String getSystem()
- {
+ public String getSystem() {
return system;
}
- public void setSystem( String system )
- {
+ public void setSystem(String system) {
this.system = system;
}
- public void setTeam( final String team )
- {
+ public void setTeam(final String team) {
this.team = team;
}
- public String getTeam()
- {
+ public String getTeam() {
return team;
}
- public void setUrl( String url )
- {
+ public void setUrl(String url) {
this.url = url;
}
- public String getUrl()
- {
+ public String getUrl() {
return url;
}
- public Map getIssueLinksPerSystem()
- {
+ public Map getIssueLinksPerSystem() {
return issueLinksPerSystem;
}
- public void setIssueLinksPerSystem( Map issueLinksPerSystem )
- {
- if ( this.issueLinksPerSystem != null && issueLinksPerSystem == null )
- {
+ public void setIssueLinksPerSystem(Map issueLinksPerSystem) {
+ if (this.issueLinksPerSystem != null && issueLinksPerSystem == null) {
return;
}
this.issueLinksPerSystem = issueLinksPerSystem;
}
- public boolean isAddActionDate()
- {
+ public boolean isAddActionDate() {
return addActionDate;
}
- public void setAddActionDate( boolean addActionDate )
- {
+ public void setAddActionDate(boolean addActionDate) {
this.addActionDate = addActionDate;
}
- public boolean isLinkToFeed()
- {
+ public boolean isLinkToFeed() {
return linkToFeed;
}
- public void setLinkToFeed( boolean generateLinkTofeed )
- {
+ public void setLinkToFeed(boolean generateLinkTofeed) {
this.linkToFeed = generateLinkTofeed;
}
@@ -180,46 +159,40 @@ public void setLinkToFeed( boolean generateLinkTofeed )
* @param system The issue management system
* @return true
if issue links can be generated, false
otherwise.
*/
- public boolean canGenerateIssueLinks( String system )
- {
- if ( !this.issueLinksPerSystem.containsKey( system ) )
- {
+ public boolean canGenerateIssueLinks(String system) {
+ if (!this.issueLinksPerSystem.containsKey(system)) {
return false;
}
- String issueLink = this.issueLinksPerSystem.get( system );
+ String issueLink = this.issueLinksPerSystem.get(system);
// If the issue link entry is blank then no links are possible
- if ( StringUtils.isBlank( issueLink ) )
- {
+ if (StringUtils.isBlank(issueLink)) {
return false;
}
// If the %URL% token is used then the issue management system URL must be set.
- if ( issueLink.contains( URL_TOKEN ) && StringUtils.isBlank( getUrl() ) )
- {
+ if (issueLink.contains(URL_TOKEN) && StringUtils.isBlank(getUrl())) {
return false;
}
return true;
}
- public void doGenerateEmptyReport( ResourceBundle bundle, Sink sink, String message )
- {
- sinkBeginReport( sink, bundle );
+ public void doGenerateEmptyReport(ResourceBundle bundle, Sink sink, String message) {
+ sinkBeginReport(sink, bundle);
- sink.text( message );
+ sink.text(message);
- sinkEndReport( sink );
+ sinkEndReport(sink);
}
- public void doGenerateReport( ResourceBundle bundle, Sink sink )
- {
- sinkBeginReport( sink, bundle );
+ public void doGenerateReport(ResourceBundle bundle, Sink sink) {
+ sinkBeginReport(sink, bundle);
- constructReleaseHistory( sink, bundle, releaseList );
+ constructReleaseHistory(sink, bundle, releaseList);
- constructReleases( sink, bundle, releaseList );
+ constructReleases(sink, bundle, releaseList);
- sinkEndReport( sink );
+ sinkEndReport(sink);
}
/**
@@ -229,76 +202,61 @@ public void doGenerateReport( ResourceBundle bundle, Sink sink )
* @param bundle Resource bundle
* @param action Action to generate content for
*/
- private void constructAction( Sink sink, ResourceBundle bundle, Action action )
- {
+ private void constructAction(Sink sink, ResourceBundle bundle, Action action) {
sink.tableRow();
- sinkShowTypeIcon( sink, action.getType() );
+ sinkShowTypeIcon(sink, action.getType());
sink.tableCell();
String actionDescription = action.getAction();
- if ( escapeHTML )
- {
- sink.text( actionDescription );
- }
- else
- {
- sink.rawText( actionDescription );
+ if (escapeHTML) {
+ sink.text(actionDescription);
+ } else {
+ sink.rawText(actionDescription);
}
// no null check needed classes from modello return a new ArrayList
- if ( StringUtils.isNotEmpty( action.getIssue() ) || ( !action.getFixedIssues().isEmpty() ) )
- {
- if ( StringUtils.isNotBlank( actionDescription ) && !actionDescription.endsWith( "." ) )
- {
- sink.text( "." );
+ if (StringUtils.isNotEmpty(action.getIssue())
+ || (!action.getFixedIssues().isEmpty())) {
+ if (StringUtils.isNotBlank(actionDescription) && !actionDescription.endsWith(".")) {
+ sink.text(".");
}
- sink.text( " " + bundle.getString( "report.changes.text.fixes" ) + " " );
+ sink.text(" " + bundle.getString("report.changes.text.fixes") + " ");
// Try to get the issue management system specified in the changes.xml file
String system = action.getSystem();
// Try to get the issue management system configured in the POM
- if ( StringUtils.isEmpty( system ) )
- {
+ if (StringUtils.isEmpty(system)) {
system = this.system;
}
// Use the default issue management system
- if ( StringUtils.isEmpty( system ) )
- {
+ if (StringUtils.isEmpty(system)) {
system = DEFAULT_ISSUE_SYSTEM_KEY;
}
- if ( !canGenerateIssueLinks( system ) )
- {
- constructIssueText( action.getIssue(), sink, action.getFixedIssues() );
- }
- else
- {
- constructIssueLink( action.getIssue(), system, sink, action.getFixedIssues() );
+ if (!canGenerateIssueLinks(system)) {
+ constructIssueText(action.getIssue(), sink, action.getFixedIssues());
+ } else {
+ constructIssueLink(action.getIssue(), system, sink, action.getFixedIssues());
}
- sink.text( "." );
+ sink.text(".");
}
- if ( StringUtils.isNotEmpty( action.getDueTo() ) || ( !action.getDueTos().isEmpty() ) )
- {
- constructDueTo( sink, action, bundle, action.getDueTos() );
+ if (StringUtils.isNotEmpty(action.getDueTo()) || (!action.getDueTos().isEmpty())) {
+ constructDueTo(sink, action, bundle, action.getDueTos());
}
sink.tableCell_();
- if ( NO_TEAM.equals( team ) )
- {
- sinkCell( sink, action.getDev() );
- }
- else
- {
- sinkCellLink( sink, action.getDev(), team + "#" + action.getDev() );
+ if (NO_TEAM.equals(team)) {
+ sinkCell(sink, action.getDev());
+ } else {
+ sinkCellLink(sink, action.getDev(), team + "#" + action.getDev());
}
- if ( this.isAddActionDate() )
- {
- sinkCell( sink, action.getDate() );
+ if (this.isAddActionDate()) {
+ sinkCell(sink, action.getDate());
}
sink.tableRow_();
@@ -312,51 +270,42 @@ private void constructAction( Sink sink, ResourceBundle bundle, Action action )
* @param bundle A resource bundle for i18n
* @param dueTos Other people that helped with an action
*/
- private void constructDueTo( Sink sink, Action action, ResourceBundle bundle, List dueTos )
- {
+ private void constructDueTo(Sink sink, Action action, ResourceBundle bundle, List dueTos) {
// Create a Map with key : dueTo name, value : dueTo email
Map namesEmailMap = new LinkedHashMap<>();
// Only add the dueTo specified as attributes, if it has either a dueTo or a dueToEmail
- if ( StringUtils.isNotEmpty( action.getDueTo() ) || StringUtils.isNotEmpty( action.getDueToEmail() ) )
- {
- namesEmailMap.put( action.getDueTo(), action.getDueToEmail() );
+ if (StringUtils.isNotEmpty(action.getDueTo()) || StringUtils.isNotEmpty(action.getDueToEmail())) {
+ namesEmailMap.put(action.getDueTo(), action.getDueToEmail());
}
- for ( DueTo dueTo : dueTos )
- {
- namesEmailMap.put( dueTo.getName(), dueTo.getEmail() );
+ for (DueTo dueTo : dueTos) {
+ namesEmailMap.put(dueTo.getName(), dueTo.getEmail());
}
- if ( namesEmailMap.isEmpty() )
- {
+ if (namesEmailMap.isEmpty()) {
return;
}
- sink.text( " " + bundle.getString( "report.changes.text.thanx" ) + " " );
+ sink.text(" " + bundle.getString("report.changes.text.thanx") + " ");
int i = 0;
- for ( String currentDueTo : namesEmailMap.keySet() )
- {
- String currentDueToEmail = namesEmailMap.get( currentDueTo );
+ for (String currentDueTo : namesEmailMap.keySet()) {
+ String currentDueToEmail = namesEmailMap.get(currentDueTo);
i++;
- if ( StringUtils.isNotEmpty( currentDueToEmail ) )
- {
- sinkLink( sink, currentDueTo, "mailto:" + currentDueToEmail );
- }
- else if ( StringUtils.isNotEmpty( currentDueTo ) )
- {
- sink.text( currentDueTo );
+ if (StringUtils.isNotEmpty(currentDueToEmail)) {
+ sinkLink(sink, currentDueTo, "mailto:" + currentDueToEmail);
+ } else if (StringUtils.isNotEmpty(currentDueTo)) {
+ sink.text(currentDueTo);
}
- if ( i < namesEmailMap.size() )
- {
- sink.text( ", " );
+ if (i < namesEmailMap.size()) {
+ sink.text(", ");
}
}
- sink.text( "." );
+ sink.text(".");
}
/**
@@ -367,38 +316,32 @@ else if ( StringUtils.isNotEmpty( currentDueTo ) )
* @param sink The sink
* @param fixes The List of issues specified as fixes elements
*/
- private void constructIssueLink( String issue, String system, Sink sink, List fixes )
- {
- if ( StringUtils.isNotEmpty( issue ) )
- {
- sink.link( parseIssueLink( issue, system ) );
+ private void constructIssueLink(String issue, String system, Sink sink, List fixes) {
+ if (StringUtils.isNotEmpty(issue)) {
+ sink.link(parseIssueLink(issue, system));
- sink.text( issue );
+ sink.text(issue);
sink.link_();
- if ( !fixes.isEmpty() )
- {
- sink.text( ", " );
+ if (!fixes.isEmpty()) {
+ sink.text(", ");
}
}
- for ( Iterator iterator = fixes.iterator(); iterator.hasNext(); )
- {
+ for (Iterator iterator = fixes.iterator(); iterator.hasNext(); ) {
FixedIssue fixedIssue = iterator.next();
String currentIssueId = fixedIssue.getIssue();
- if ( StringUtils.isNotEmpty( currentIssueId ) )
- {
- sink.link( parseIssueLink( currentIssueId, system ) );
+ if (StringUtils.isNotEmpty(currentIssueId)) {
+ sink.link(parseIssueLink(currentIssueId, system));
- sink.text( currentIssueId );
+ sink.text(currentIssueId);
sink.link_();
}
- if ( iterator.hasNext() )
- {
- sink.text( ", " );
+ if (iterator.hasNext()) {
+ sink.text(", ");
}
}
}
@@ -410,64 +353,56 @@ private void constructIssueLink( String issue, String system, Sink sink, List fixes )
- {
- if ( StringUtils.isNotEmpty( issue ) )
- {
- sink.text( issue );
-
- if ( !fixes.isEmpty() )
- {
- sink.text( ", " );
+ private void constructIssueText(String issue, Sink sink, List fixes) {
+ if (StringUtils.isNotEmpty(issue)) {
+ sink.text(issue);
+
+ if (!fixes.isEmpty()) {
+ sink.text(", ");
}
}
- for ( Iterator iterator = fixes.iterator(); iterator.hasNext(); )
- {
+ for (Iterator iterator = fixes.iterator(); iterator.hasNext(); ) {
FixedIssue fixedIssue = iterator.next();
String currentIssueId = fixedIssue.getIssue();
- if ( StringUtils.isNotEmpty( currentIssueId ) )
- {
- sink.text( currentIssueId );
+ if (StringUtils.isNotEmpty(currentIssueId)) {
+ sink.text(currentIssueId);
}
- if ( iterator.hasNext() )
- {
- sink.text( ", " );
+ if (iterator.hasNext()) {
+ sink.text(", ");
}
}
}
- private void constructReleaseHistory( Sink sink, ResourceBundle bundle, List releaseList )
- {
+ private void constructReleaseHistory(Sink sink, ResourceBundle bundle, List releaseList) {
sink.section2();
sink.sectionTitle2();
- sink.text( bundle.getString( "report.changes.label.releasehistory" ) );
+ sink.text(bundle.getString("report.changes.label.releasehistory"));
sink.sectionTitle2_();
sink.table();
sink.tableRow();
- sinkHeader( sink, bundle.getString( "report.issues.label.fixVersion" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.fixVersion"));
- sinkHeader( sink, bundle.getString( "report.changes.label.releaseDate" ) );
+ sinkHeader(sink, bundle.getString("report.changes.label.releaseDate"));
- sinkHeader( sink, bundle.getString( "report.changes.label.releaseDescription" ) );
+ sinkHeader(sink, bundle.getString("report.changes.label.releaseDescription"));
sink.tableRow_();
- for ( Release release : releaseList )
- {
+ for (Release release : releaseList) {
sink.tableRow();
- sinkCellLink( sink, release.getVersion(), "#" + HtmlTools.encodeId( release.getVersion() ) );
+ sinkCellLink(sink, release.getVersion(), "#" + HtmlTools.encodeId(release.getVersion()));
- sinkCell( sink, release.getDateRelease() );
+ sinkCell(sink, release.getDateRelease());
- sinkCell( sink, release.getDescription() );
+ sinkCell(sink, release.getDescription());
sink.tableRow_();
}
@@ -475,13 +410,12 @@ private void constructReleaseHistory( Sink sink, ResourceBundle bundle, List releaseList )
- {
- for ( Release release : releaseList )
- {
- constructRelease( sink, bundle, release );
+ private void constructReleases(Sink sink, ResourceBundle bundle, List releaseList) {
+ for (Release release : releaseList) {
+ constructRelease(sink, bundle, release);
}
}
@@ -511,47 +443,40 @@ private void constructReleases( Sink sink, ResourceBundle bundle, List
* @param bundle Resource bundle
* @param release Release to create document section for
*/
- private void constructRelease( Sink sink, ResourceBundle bundle, Release release )
- {
+ private void constructRelease(Sink sink, ResourceBundle bundle, Release release) {
sink.section2();
- final String date = ( release.getDateRelease() == null ) ? "" : " \u2013 " + release.getDateRelease();
+ final String date = (release.getDateRelease() == null) ? "" : " \u2013 " + release.getDateRelease();
SinkEventAttributes attrs = new SinkEventAttributeSet();
- attrs.addAttribute( SinkEventAttributes.ID, HtmlTools.encodeId( release.getVersion() ) );
- sink.sectionTitle( Sink.SECTION_LEVEL_2, attrs );
- sink.text( bundle.getString( "report.changes.label.release" ) + " " + release.getVersion() + date );
- sink.sectionTitle_( Sink.SECTION_LEVEL_2 );
+ attrs.addAttribute(SinkEventAttributes.ID, HtmlTools.encodeId(release.getVersion()));
+ sink.sectionTitle(Sink.SECTION_LEVEL_2, attrs);
+ sink.text(bundle.getString("report.changes.label.release") + " " + release.getVersion() + date);
+ sink.sectionTitle_(Sink.SECTION_LEVEL_2);
- if ( isReleaseEmpty( release ) )
- {
+ if (isReleaseEmpty(release)) {
sink.paragraph();
- sink.text( bundle.getString( "report.changes.text.no.changes" ) );
+ sink.text(bundle.getString("report.changes.text.no.changes"));
sink.paragraph_();
- }
- else
- {
+ } else {
sink.table();
sink.tableRow();
- sinkHeader( sink, bundle.getString( "report.issues.label.type" ) );
- sinkHeader( sink, bundle.getString( "report.issues.label.summary" ) );
- sinkHeader( sink, bundle.getString( "report.issues.label.assignee" ) );
- if ( this.isAddActionDate() )
- {
- sinkHeader( sink, bundle.getString( "report.issues.label.updated" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.type"));
+ sinkHeader(sink, bundle.getString("report.issues.label.summary"));
+ sinkHeader(sink, bundle.getString("report.issues.label.assignee"));
+ if (this.isAddActionDate()) {
+ sinkHeader(sink, bundle.getString("report.issues.label.updated"));
}
sink.tableRow_();
- for ( Action action : release.getActions() )
- {
- constructAction( sink, bundle, action );
+ for (Action action : release.getActions()) {
+ constructAction(sink, bundle, action);
}
- for ( Object o : release.getComponents() )
- {
+ for (Object o : release.getComponents()) {
Component component = (Component) o;
- constructComponent( sink, bundle, component );
+ constructComponent(sink, bundle, component);
}
sink.table_();
@@ -568,33 +493,29 @@ private void constructRelease( Sink sink, ResourceBundle bundle, Release release
* @param bundle Resource bundle
* @param component Release component to generate content for.
*/
- private void constructComponent( Sink sink, ResourceBundle bundle, Component component )
- {
- if ( !component.getActions().isEmpty() )
- {
+ private void constructComponent(Sink sink, ResourceBundle bundle, Component component) {
+ if (!component.getActions().isEmpty()) {
sink.tableRow();
sink.tableHeaderCell();
sink.tableHeaderCell_();
sink.tableHeaderCell();
- sink.text( component.getName() );
+ sink.text(component.getName());
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.tableHeaderCell_();
- if ( isAddActionDate() )
- {
+ if (isAddActionDate()) {
sink.tableHeaderCell();
sink.tableHeaderCell_();
}
sink.tableRow_();
- for ( Action action : component.getActions() )
- {
- constructAction( sink, bundle, action );
+ for (Action action : component.getActions()) {
+ constructAction(sink, bundle, action);
}
}
}
@@ -605,18 +526,14 @@ private void constructComponent( Sink sink, ResourceBundle bundle, Component com
* @param release Release to check
* @return true
if release doesn't contain any issues, false
otherwise
*/
- private boolean isReleaseEmpty( Release release )
- {
- if ( !release.getActions().isEmpty() )
- {
+ private boolean isReleaseEmpty(Release release) {
+ if (!release.getActions().isEmpty()) {
return false;
}
- for ( Object o : release.getComponents() )
- {
+ for (Object o : release.getComponents()) {
Component component = (Component) o;
- if ( !component.getActions().isEmpty() )
- {
+ if (!component.getActions().isEmpty()) {
return false;
}
}
@@ -631,18 +548,15 @@ private boolean isReleaseEmpty( Release release )
* @param system The issue management system
* @return An interpolated issue link
*/
- private String parseIssueLink( String issue, String system )
- {
+ private String parseIssueLink(String issue, String system) {
String parseLink;
- String issueLink = this.issueLinksPerSystem.get( system );
- parseLink = issueLink.replaceFirst( ISSUE_TOKEN, issue );
- if ( parseLink.contains( URL_TOKEN ) )
- {
- String url = this.url.substring( 0, this.url.lastIndexOf( "/" ) );
- parseLink = parseLink.replaceFirst( URL_TOKEN, url );
+ String issueLink = this.issueLinksPerSystem.get(system);
+ parseLink = issueLink.replaceFirst(ISSUE_TOKEN, issue);
+ if (parseLink.contains(URL_TOKEN)) {
+ String url = this.url.substring(0, this.url.lastIndexOf("/"));
+ parseLink = parseLink.replaceFirst(URL_TOKEN, url);
}
return parseLink;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesValidatorMojo.java b/src/main/java/org/apache/maven/plugins/changes/ChangesValidatorMojo.java
index b79e353b..469c3bef 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ChangesValidatorMojo.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ChangesValidatorMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import java.io.File;
import java.util.List;
@@ -33,96 +32,78 @@
/**
* Goal which validate the changes.xml
file.
- *
+ *
* @author Olivier Lamy
* @version $Id$
* @since 2.1
*/
-@Mojo( name = "changes-validate", threadSafe = true )
-public class ChangesValidatorMojo
- extends AbstractChangesMojo
-{
+@Mojo(name = "changes-validate", threadSafe = true)
+public class ChangesValidatorMojo extends AbstractChangesMojo {
/**
*/
- @Component( role = ChangesSchemaValidator.class, hint = "default" )
+ @Component(role = ChangesSchemaValidator.class, hint = "default")
private ChangesSchemaValidator changesSchemaValidator;
/**
* The changes xsd version.
*/
- @Parameter( property = "changes.xsdVersion", defaultValue = "1.0.0" )
+ @Parameter(property = "changes.xsdVersion", defaultValue = "1.0.0")
private String changesXsdVersion;
/**
* Mojo failure if validation failed. If not and validation failed only a warning will be logged.
*/
- @Parameter( property = "changes.validate.failed", defaultValue = "false" )
+ @Parameter(property = "changes.validate.failed", defaultValue = "false")
private boolean failOnError;
/**
* The path of the changes.xml
file that will be converted into an HTML report.
*/
- @Parameter( property = "changes.xmlPath", defaultValue = "src/changes/changes.xml" )
+ @Parameter(property = "changes.xmlPath", defaultValue = "src/changes/changes.xml")
private File xmlPath;
/**
* @see org.apache.maven.plugin.Mojo#execute()
*/
- public void execute()
- throws MojoExecutionException
- {
+ public void execute() throws MojoExecutionException {
// Run only at the execution root
- if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
- {
- getLog().info( "Skipping the changes validate in this project because it's not the Execution Root" );
- }
- else
- {
- if ( !xmlPath.exists() )
- {
- getLog().warn( "changes.xml file " + xmlPath.getAbsolutePath() + " does not exist." );
+ if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
+ getLog().info("Skipping the changes validate in this project because it's not the Execution Root");
+ } else {
+ if (!xmlPath.exists()) {
+ getLog().warn("changes.xml file " + xmlPath.getAbsolutePath() + " does not exist.");
return;
}
- try
- {
+ try {
XmlValidationHandler xmlValidationHandler =
- changesSchemaValidator.validateXmlWithSchema( xmlPath, changesXsdVersion, failOnError );
+ changesSchemaValidator.validateXmlWithSchema(xmlPath, changesXsdVersion, failOnError);
boolean hasErrors = !xmlValidationHandler.getErrors().isEmpty();
- if ( hasErrors )
- {
- logSchemaValidation( xmlValidationHandler.getErrors() );
- if ( failOnError )
- {
- throw new MojoExecutionException( "changes.xml file " + xmlPath.getAbsolutePath()
- + " is not valid, see previous errors." );
- }
- else
- {
- getLog().info( " skip previous validation errors due to failOnError=false." );
+ if (hasErrors) {
+ logSchemaValidation(xmlValidationHandler.getErrors());
+ if (failOnError) {
+ throw new MojoExecutionException("changes.xml file " + xmlPath.getAbsolutePath()
+ + " is not valid, see previous errors.");
+ } else {
+ getLog().info(" skip previous validation errors due to failOnError=false.");
}
}
- }
- catch ( SchemaValidatorException e )
- {
- if ( failOnError )
- {
- throw new MojoExecutionException( "failed to validate changes.xml file " + xmlPath.getAbsolutePath()
- + ": " + e.getMessage(), e );
+ } catch (SchemaValidatorException e) {
+ if (failOnError) {
+ throw new MojoExecutionException(
+ "failed to validate changes.xml file " + xmlPath.getAbsolutePath() + ": " + e.getMessage(),
+ e);
}
}
}
}
- private void logSchemaValidation( List errors )
- {
- getLog().warn( "failed to validate changes.xml file " + xmlPath.getAbsolutePath() );
- getLog().warn( "validation errors: " );
- for ( SAXParseException error : errors )
- {
- getLog().warn( error.getMessage() );
+ private void logSchemaValidation(List errors) {
+ getLog().warn("failed to validate changes.xml file " + xmlPath.getAbsolutePath());
+ getLog().warn("validation errors: ");
+ for (SAXParseException error : errors) {
+ getLog().warn(error.getMessage());
}
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesXML.java b/src/main/java/org/apache/maven/plugins/changes/ChangesXML.java
index 5fe79597..323fa16b 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ChangesXML.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ChangesXML.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,31 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import java.io.File;
import java.io.FileInputStream;
import java.util.Collections;
import java.util.List;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.changes.model.Body;
import org.apache.maven.plugins.changes.model.ChangesDocument;
@@ -55,8 +35,7 @@
*
* @version $Id$
*/
-public class ChangesXML
-{
+public class ChangesXML {
/** The list of releases in the changes.xml file. */
private List releaseList;
@@ -75,43 +54,35 @@ public class ChangesXML
/**
* Constructor that sets the changes.xml file and the logger.
- *
+ *
* @param xmlPath the changes.xml file
* @param log the logger
* @throws ChangesXMLRuntimeException if there was a fatal error while parsing the changes.xml file
*/
- public ChangesXML( File xmlPath, Log log )
- throws ChangesXMLRuntimeException
- {
+ public ChangesXML(File xmlPath, Log log) throws ChangesXMLRuntimeException {
- if ( xmlPath == null || !xmlPath.exists() )
- {
- log.error( "changes xml file is null or not exists " );
+ if (xmlPath == null || !xmlPath.exists()) {
+ log.error("changes xml file is null or not exists ");
return;
}
- try
- {
+ try {
ChangesXpp3Reader reader = new ChangesXpp3Reader();
- try ( FileInputStream fileInputStream = new FileInputStream( xmlPath ) )
- {
- changesDocument = reader.read( fileInputStream, false );
+ try (FileInputStream fileInputStream = new FileInputStream(xmlPath)) {
+ changesDocument = reader.read(fileInputStream, false);
}
- if ( changesDocument == null )
- {
- log.error( "Cannot build Changes Report from file: " + xmlPath.getPath() );
+ if (changesDocument == null) {
+ log.error("Cannot build Changes Report from file: " + xmlPath.getPath());
return;
}
Properties properties = changesDocument.getProperties();
- if ( properties != null )
- {
- if ( properties.getAuthor() != null )
- {
+ if (properties != null) {
+ if (properties.getAuthor() != null) {
this.author = properties.getAuthor().getName();
this.authorEmail = properties.getAuthor().getName();
}
@@ -120,107 +91,94 @@ public ChangesXML( File xmlPath, Log log )
Body body = changesDocument.getBody();
- if ( body != null )
- {
+ if (body != null) {
this.releaseList = body.getReleases();
}
- }
- catch ( Throwable e )
- {
- log.error( "An error occurred when parsing the changes.xml file: ", e );
- throw new ChangesXMLRuntimeException( "An error occurred when parsing the changes.xml file", e );
+ } catch (Throwable e) {
+ log.error("An error occurred when parsing the changes.xml file: ", e);
+ throw new ChangesXMLRuntimeException("An error occurred when parsing the changes.xml file", e);
}
}
/**
* Sets the {@link ChangesXML#author} attribute.
- *
+ *
* @param author the new value of the {@link ChangesXML#author} attribute
*/
- public void setAuthor( String author )
- {
+ public void setAuthor(String author) {
this.author = author;
}
/**
* Returns the current value of the author attribute.
- *
+ *
* @return the current value of the author attribute
*/
- public String getAuthor()
- {
+ public String getAuthor() {
return author;
}
/**
* Sets the {@link ChangesXML#releaseList} attribute.
- *
+ *
* @param releaseList the new value of the {@link ChangesXML#releaseList} attribute
*/
- public void setReleaseList( List releaseList )
- {
+ public void setReleaseList(List releaseList) {
this.releaseList = releaseList;
}
/**
* Returns the current value of the {@link ChangesXML#releaseList} attribute.
- *
+ *
* @return the current value of the {@link ChangesXML#releaseList} attribute
*/
- public List getReleaseList()
- {
+ public List getReleaseList() {
return releaseList == null ? Collections.emptyList() : releaseList;
}
/**
* Sets the {@link ChangesXML#title} attribute.
- *
+ *
* @param title the new value of the {@link ChangesXML#title} attribute
*/
- public void setTitle( String title )
- {
+ public void setTitle(String title) {
this.title = title;
}
/**
* Returns the current value of the {@link ChangesXML#title} attribute.
- *
+ *
* @return the current value of the {@link ChangesXML#title} attribute
*/
- public String getTitle()
- {
+ public String getTitle() {
return title;
}
/**
* Returns the current value of the {@link ChangesXML#changesDocument} attribute.
- *
+ *
* @return the current value of the {@link ChangesXML#changesDocument} attribute
*/
- public ChangesDocument getChangesDocument()
- {
+ public ChangesDocument getChangesDocument() {
return changesDocument;
}
/**
* Returns the current value of the {@link ChangesXML#authorEmail} attribute.
- *
+ *
* @return the current value of the {@link ChangesXML#authorEmail} attribute
*/
- public String getAuthorEmail()
- {
+ public String getAuthorEmail() {
return authorEmail;
}
/**
* Sets the {@link ChangesXML#authorEmail} attribute.
- *
+ *
* @param authorEmail the new value of the {@link ChangesXML#authorEmail} attribute
*/
- public void setAuthorEmail( String authorEmail )
- {
+ public void setAuthorEmail(String authorEmail) {
this.authorEmail = authorEmail;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesXMLRuntimeException.java b/src/main/java/org/apache/maven/plugins/changes/ChangesXMLRuntimeException.java
index 61620980..62639336 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ChangesXMLRuntimeException.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ChangesXMLRuntimeException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
/**
* This is a runtime exception class that is thrown by the
@@ -26,9 +25,7 @@
*
* @author Gabor Szabo
*/
-public class ChangesXMLRuntimeException
- extends RuntimeException
-{
+public class ChangesXMLRuntimeException extends RuntimeException {
/** The serialVersionUID **/
private static final long serialVersionUID = -8059557047280992301L;
@@ -37,9 +34,8 @@ public class ChangesXMLRuntimeException
*
* @param msg the exception message.
*/
- public ChangesXMLRuntimeException( String msg )
- {
- super( msg );
+ public ChangesXMLRuntimeException(String msg) {
+ super(msg);
}
/**
@@ -48,8 +44,7 @@ public ChangesXMLRuntimeException( String msg )
* @param msg the exception message.
* @param cause the cause.
*/
- public ChangesXMLRuntimeException( String msg, Throwable cause )
- {
- super( msg, cause );
+ public ChangesXMLRuntimeException(String msg, Throwable cause) {
+ super(msg, cause);
}
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/FeedGenerator.java b/src/main/java/org/apache/maven/plugins/changes/FeedGenerator.java
index af0030ed..23cba0ba 100644
--- a/src/main/java/org/apache/maven/plugins/changes/FeedGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/changes/FeedGenerator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,37 +16,33 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import com.sun.syndication.feed.synd.SyndContent;
-import com.sun.syndication.feed.synd.SyndContentImpl;
-import com.sun.syndication.feed.synd.SyndEntry;
-import com.sun.syndication.feed.synd.SyndEntryImpl;
-import com.sun.syndication.feed.synd.SyndFeed;
-import com.sun.syndication.feed.synd.SyndFeedImpl;
-import com.sun.syndication.io.FeedException;
-import com.sun.syndication.io.SyndFeedOutput;
+package org.apache.maven.plugins.changes;
import java.io.IOException;
import java.io.Writer;
-
import java.text.DateFormat;
import java.text.ParseException;
-
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedOutput;
import org.apache.maven.doxia.util.HtmlTools;
-
import org.apache.maven.plugins.changes.model.Release;
/**
* @author ltheussl
*/
-public class FeedGenerator
-{
+public class FeedGenerator {
private final ResourceBundle rbundle;
private final SyndFeed feed;
@@ -66,10 +60,10 @@ public class FeedGenerator
*
* @param locale a locale for i18n.
*/
- public FeedGenerator( final Locale locale )
- {
+ public FeedGenerator(final Locale locale) {
this.feed = new SyndFeedImpl();
- this.rbundle = ResourceBundle.getBundle( "changes-report", locale, this.getClass().getClassLoader() );
+ this.rbundle = ResourceBundle.getBundle(
+ "changes-report", locale, this.getClass().getClassLoader());
}
/**
@@ -77,8 +71,7 @@ public FeedGenerator( final Locale locale )
*
* @return the author.
*/
- public String getAuthor()
- {
+ public String getAuthor() {
return author;
}
@@ -87,8 +80,7 @@ public String getAuthor()
*
* @param author not null.
*/
- public void setAuthor( final String author )
- {
+ public void setAuthor(final String author) {
this.author = author.trim(); // this also assures that author is not null.
}
@@ -97,8 +89,7 @@ public void setAuthor( final String author )
*
* @return the title.
*/
- public String getTitle()
- {
+ public String getTitle() {
return title;
}
@@ -107,8 +98,7 @@ public String getTitle()
*
* @param title not null.
*/
- public void setTitle( final String title )
- {
+ public void setTitle(final String title) {
this.title = title.trim(); // this also assures that title is not null.
}
@@ -117,8 +107,7 @@ public void setTitle( final String title )
*
* @return may be null.
*/
- public DateFormat getDateFormat()
- {
+ public DateFormat getDateFormat() {
return dateFormat;
}
@@ -127,8 +116,7 @@ public DateFormat getDateFormat()
*
* @param dateFormat may be null.
*/
- public void setDateFormat( final DateFormat dateFormat )
- {
+ public void setDateFormat(final DateFormat dateFormat) {
this.dateFormat = dateFormat;
}
@@ -137,8 +125,7 @@ public void setDateFormat( final DateFormat dateFormat )
*
* @return the link.
*/
- public String getLink()
- {
+ public String getLink() {
return link;
}
@@ -147,8 +134,7 @@ public String getLink()
*
* @param link not null.
*/
- public void setLink( final String link )
- {
+ public void setLink(final String link) {
this.link = link.trim(); // this also assures that link is not null.
}
@@ -160,9 +146,8 @@ public void setLink( final String link )
* @param type the feed type to check. May be null.
* @return true if if the given type is supported by the rome library, false otherwise.
*/
- public boolean isSupportedFeedType( final String type )
- {
- return getSupportedFeedTypes().contains( type );
+ public boolean isSupportedFeedType(final String type) {
+ return getSupportedFeedTypes().contains(type);
}
/**
@@ -171,9 +156,8 @@ public boolean isSupportedFeedType( final String type )
* @return a List of supported feed types.
* @see #isSupportedFeedType(java.lang.String)
*/
- @SuppressWarnings( "unchecked" )
- public List getSupportedFeedTypes()
- {
+ @SuppressWarnings("unchecked")
+ public List getSupportedFeedTypes() {
return feed.getSupportedFeedTypes();
}
@@ -186,87 +170,73 @@ public List getSupportedFeedTypes()
* @param writer a Writer. Note that this is not flushed nor closed upon exit.
* @throws IOException if an error occurs during export.
*/
- public void export( final List releases, final String feedType, final Writer writer )
- throws IOException
- {
- feed.setFeedType( feedType );
- feed.setTitle( title );
- feed.setAuthor( author );
- feed.setPublishedDate( new Date() );
- feed.setLink( link );
- feed.setDescription( rbundle.getString( "report.changes.text.rssfeed.description" ) );
- feed.setLanguage( rbundle.getLocale().getLanguage() );
+ public void export(final List releases, final String feedType, final Writer writer) throws IOException {
+ feed.setFeedType(feedType);
+ feed.setTitle(title);
+ feed.setAuthor(author);
+ feed.setPublishedDate(new Date());
+ feed.setLink(link);
+ feed.setDescription(rbundle.getString("report.changes.text.rssfeed.description"));
+ feed.setLanguage(rbundle.getLocale().getLanguage());
// feed.setCopyright( );
// feed.setEncoding();
- feed.setEntries( getEntries( releases ) );
+ feed.setEntries(getEntries(releases));
- try
- {
- new SyndFeedOutput().output( feed, writer );
- }
- catch ( FeedException ex )
- {
- throw new IOException( ex.getMessage(), ex );
+ try {
+ new SyndFeedOutput().output(feed, writer);
+ } catch (FeedException ex) {
+ throw new IOException(ex.getMessage(), ex);
}
}
- private List getEntries( final List releases )
- {
- final List entries = new ArrayList<>( 1 );
+ private List getEntries(final List releases) {
+ final List entries = new ArrayList<>(1);
- if ( releases.size() > 0 )
- {
- final Release release = releases.get( 0 ); // TODO: is this guaranteed to be the latest?
+ if (releases.size() > 0) {
+ final Release release = releases.get(0); // TODO: is this guaranteed to be the latest?
final SyndEntry entry = new SyndEntryImpl();
- entry.setTitle( release.getVersion() );
- entry.setLink( link + "#" + HtmlTools.encodeId( release.getVersion() ) );
- entry.setDescription( getSyndContent( release ) );
- entry.setPublishedDate( getDate( release.getDateRelease(), dateFormat ) );
+ entry.setTitle(release.getVersion());
+ entry.setLink(link + "#" + HtmlTools.encodeId(release.getVersion()));
+ entry.setDescription(getSyndContent(release));
+ entry.setPublishedDate(getDate(release.getDateRelease(), dateFormat));
- entries.add( entry );
+ entries.add(entry);
}
return entries;
}
- private static SyndContent getSyndContent( final Release release )
- {
+ private static SyndContent getSyndContent(final Release release) {
final SyndContent syndContent = new SyndContentImpl();
- syndContent.setType( "text/html" );
+ syndContent.setType("text/html");
- final StringBuilder sb = new StringBuilder( 512 );
+ final StringBuilder sb = new StringBuilder(512);
final String description = release.getDescription();
- if ( description != null && description.trim().length() > 0 )
- {
- sb.append( "" ).append( description ).append( "
" );
+ if (description != null && description.trim().length() > 0) {
+ sb.append("").append(description).append("
");
}
// TODO: localize?
- sb.append( "Version " ).append( release.getVersion() ).append( " is available with " );
- sb.append( release.getActions().size() ).append( " fixed issues.
" );
+ sb.append("Version ").append(release.getVersion()).append(" is available with ");
+ sb.append(release.getActions().size()).append(" fixed issues.
");
- syndContent.setValue( sb.toString() );
+ syndContent.setValue(sb.toString());
return syndContent;
}
- private static Date getDate( final String dateRelease, final DateFormat dateFormat )
- {
- if ( dateFormat == null )
- {
+ private static Date getDate(final String dateRelease, final DateFormat dateFormat) {
+ if (dateFormat == null) {
return new Date();
}
- try
- {
- return dateFormat.parse( dateRelease );
- }
- catch ( ParseException ex )
- {
+ try {
+ return dateFormat.parse(dateRelease);
+ } catch (ParseException ex) {
return new Date();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java b/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java
index ef090a33..5443e217 100644
--- a/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java
+++ b/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,17 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.plugins.changes.model.Action;
-import org.apache.maven.plugins.changes.model.Release;
-import org.apache.maven.plugins.issues.Issue;
-import org.apache.maven.plugins.issues.IssueManagementSystem;
+package org.apache.maven.plugins.changes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.maven.plugins.changes.model.Action;
+import org.apache.maven.plugins.changes.model.Release;
+import org.apache.maven.plugins.issues.Issue;
+import org.apache.maven.plugins.issues.IssueManagementSystem;
+
/**
* An adapter that can adapt data models from other issue management system to the data models used in the changes.xml
* file.
@@ -37,8 +36,7 @@
* @version $Id$
* @since 2.4
*/
-public class IssueAdapter
-{
+public class IssueAdapter {
private static final String UNKNOWN_ISSUE_TYPE = "";
private IssueManagementSystem ims;
@@ -48,13 +46,11 @@ public class IssueAdapter
*
* @param ims The issue management system that has the data that should be adapted
*/
- public IssueAdapter( IssueManagementSystem ims )
- {
+ public IssueAdapter(IssueManagementSystem ims) {
this.ims = ims;
}
- private Map getIssueTypeMap()
- {
+ private Map getIssueTypeMap() {
return ims.getIssueTypeMap();
}
@@ -64,38 +60,33 @@ private Map getIssueTypeMap()
* @param issues The issues
* @return A list of releases
*/
- public List getReleases( List issues )
- {
+ public List getReleases(List issues) {
// A Map of releases keyed by fixVersion
Map releasesMap = new HashMap<>();
// Loop through all issues looking for fixVersions
- for ( Issue issue : issues )
- {
+ for (Issue issue : issues) {
// Do NOT create a release for issues that lack a fixVersion
- if ( issue.getFixVersions() != null )
- {
- for ( String fixVersion : issue.getFixVersions() )
- {
+ if (issue.getFixVersions() != null) {
+ for (String fixVersion : issue.getFixVersions()) {
// Try to get a matching Release from the map
- Release release = releasesMap.get( fixVersion );
- if ( release == null )
- {
+ Release release = releasesMap.get(fixVersion);
+ if (release == null) {
// Add a new Release to the Map if it wasn't there
release = new Release();
- release.setVersion( fixVersion );
- releasesMap.put( fixVersion, release );
+ release.setVersion(fixVersion);
+ releasesMap.put(fixVersion, release);
}
// Add this issue as an Action to this release
- Action action = createAction( issue );
- release.addAction( action );
+ Action action = createAction(issue);
+ release.addAction(action);
}
}
}
// Extract the releases from the Map to a List
- return new ArrayList<>( releasesMap.values() );
+ return new ArrayList<>(releasesMap.values());
}
/**
@@ -104,31 +95,27 @@ public List getReleases( List issues )
* @param issue The issue to extract the information from
* @return An Action
*/
- public Action createAction( Issue issue )
- {
+ public Action createAction(Issue issue) {
Action action = new Action();
// @todo We need to add something like issue.getPresentationIdentifier() to be able to support other IMSes
// beside JIRA
- action.setIssue( issue.getKey() );
+ action.setIssue(issue.getKey());
// Try to map the IMS-specific issue type to one that is used in a changes.xml file
IssueType type;
- if ( getIssueTypeMap().containsKey( issue.getType() ) )
- {
- type = getIssueTypeMap().get( issue.getType() );
- action.setType( type.modelRepresentation() );
- }
- else
- {
- action.setType( UNKNOWN_ISSUE_TYPE );
+ if (getIssueTypeMap().containsKey(issue.getType())) {
+ type = getIssueTypeMap().get(issue.getType());
+ action.setType(type.modelRepresentation());
+ } else {
+ action.setType(UNKNOWN_ISSUE_TYPE);
}
- action.setDev( issue.getAssignee() );
+ action.setDev(issue.getAssignee());
- action.setDueTo( issue.getReporter() == null ? "" : issue.getReporter() );
+ action.setDueTo(issue.getReporter() == null ? "" : issue.getReporter());
- action.setAction( issue.getSummary() );
+ action.setAction(issue.getSummary());
return action;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/IssueType.java b/src/main/java/org/apache/maven/plugins/changes/IssueType.java
index ed112d27..800f86ee 100644
--- a/src/main/java/org/apache/maven/plugins/changes/IssueType.java
+++ b/src/main/java/org/apache/maven/plugins/changes/IssueType.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,42 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
/**
* The types of issues that can be used in a changes.xml
file.
*
* @version $Id$
*/
-public enum IssueType
-{
- ADD( "add" ), FIX( "fix" ), UPDATE( "update" ), REMOVE( "remove" );
+public enum IssueType {
+ ADD("add"),
+ FIX("fix"),
+ UPDATE("update"),
+ REMOVE("remove");
private String configurationKey;
- IssueType( String configurationKey )
- {
+ IssueType(String configurationKey) {
this.configurationKey = configurationKey;
}
- public String configurationKey()
- {
+ public String configurationKey() {
return configurationKey;
}
- public String modelRepresentation()
- {
+ public String modelRepresentation() {
return name().toLowerCase();
}
- public static IssueType lookupByKey( String key )
- {
+ public static IssueType lookupByKey(String key) {
IssueType type;
- try
- {
- type = IssueType.valueOf( key.toUpperCase() );
- }
- catch ( IllegalArgumentException e )
- {
+ try {
+ type = IssueType.valueOf(key.toUpperCase());
+ } catch (IllegalArgumentException e) {
type = null;
}
return type;
diff --git a/src/main/java/org/apache/maven/plugins/changes/ProjectUtils.java b/src/main/java/org/apache/maven/plugins/changes/ProjectUtils.java
index e5f00c01..1b383d1a 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ProjectUtils.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ProjectUtils.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import org.apache.maven.project.MavenProject;
@@ -28,12 +27,9 @@
* @version $Id$
* @since 2.4
*/
-public final class ProjectUtils
-{
+public final class ProjectUtils {
- private ProjectUtils()
- {
- }
+ private ProjectUtils() {}
/**
* Check if the issue management system has been properly configured in the Maven project.
@@ -44,23 +40,17 @@ private ProjectUtils()
* @return null
if the <issueManagement> element of the POM is complete, otherwise a String
* containing the reason of the failed validation.
*/
- public static String validateIssueManagement( MavenProject project, String issueManagementSystem,
- String mojoResult )
- {
- if ( project.getIssueManagement() == null )
- {
+ public static String validateIssueManagement(
+ MavenProject project, String issueManagementSystem, String mojoResult) {
+ if (project.getIssueManagement() == null) {
return "No Issue Management set. No " + mojoResult + " will be generated.";
- }
- else if ( ( project.getIssueManagement().getUrl() == null )
- || ( project.getIssueManagement().getUrl().trim().equals( "" ) ) )
- {
+ } else if ((project.getIssueManagement().getUrl() == null)
+ || (project.getIssueManagement().getUrl().trim().equals(""))) {
return "No URL set in Issue Management. No " + mojoResult + " will be generated.";
- }
- else if ( ( project.getIssueManagement().getSystem() != null )
- && !( project.getIssueManagement().getSystem().equalsIgnoreCase( issueManagementSystem ) ) )
- {
+ } else if ((project.getIssueManagement().getSystem() != null)
+ && !(project.getIssueManagement().getSystem().equalsIgnoreCase(issueManagementSystem))) {
return "The " + mojoResult + " only supports " + issueManagementSystem + ". No " + mojoResult
- + " will be generated.";
+ + " will be generated.";
}
return null;
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/ReleaseUtils.java b/src/main/java/org/apache/maven/plugins/changes/ReleaseUtils.java
index fbf29f2b..482f8a8c 100644
--- a/src/main/java/org/apache/maven/plugins/changes/ReleaseUtils.java
+++ b/src/main/java/org/apache/maven/plugins/changes/ReleaseUtils.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes;
import java.util.ArrayList;
import java.util.Collections;
@@ -35,14 +34,12 @@
* @version $Id$
* @since 2.4
*/
-public class ReleaseUtils
-{
+public class ReleaseUtils {
private static final String SNAPSHOT_SUFFIX = "-SNAPSHOT";
private Log log;
- public ReleaseUtils( Log log )
- {
+ public ReleaseUtils(Log log) {
this.log = log;
}
@@ -54,29 +51,24 @@ public ReleaseUtils( Log log )
* @return A Release
that matches the next release of the current project
* @throws org.apache.maven.plugin.MojoExecutionException If a release can't be found
*/
- public Release getLatestRelease( List releases, String pomVersion )
- throws MojoExecutionException
- {
+ public Release getLatestRelease(List releases, String pomVersion) throws MojoExecutionException {
// Remove "-SNAPSHOT" from the end, if it's there
- if ( pomVersion != null && pomVersion.endsWith( SNAPSHOT_SUFFIX ) )
- {
- pomVersion = pomVersion.substring( 0, pomVersion.length() - SNAPSHOT_SUFFIX.length() );
+ if (pomVersion != null && pomVersion.endsWith(SNAPSHOT_SUFFIX)) {
+ pomVersion = pomVersion.substring(0, pomVersion.length() - SNAPSHOT_SUFFIX.length());
}
- getLog().debug( "Found " + releases.size() + " releases." );
+ getLog().debug("Found " + releases.size() + " releases.");
- Release release = getRelease( releases, pomVersion );
+ Release release = getRelease(releases, pomVersion);
- if ( release == null )
- {
- throw new MojoExecutionException( "Couldn't find the release '" + pomVersion
- + "' among the supplied releases: " + toString( releases ) );
+ if (release == null) {
+ throw new MojoExecutionException("Couldn't find the release '" + pomVersion
+ + "' among the supplied releases: " + toString(releases));
}
return release;
}
- private Log getLog()
- {
+ private Log getLog() {
return log;
}
@@ -87,22 +79,17 @@ private Log getLog()
* @param version The version we want
* @return A Release, or null if no release with the specified version can be found
*/
- protected Release getRelease( List releases, String version )
- {
- for ( Release release : releases )
- {
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "The release: " + release.getVersion() + " has " + release.getActions().size()
- + " actions." );
+ protected Release getRelease(List releases, String version) {
+ for (Release release : releases) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("The release: " + release.getVersion() + " has "
+ + release.getActions().size() + " actions.");
}
- if ( release.getVersion() != null && release.getVersion().equals( version ) )
- {
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "Found the correct release: " + release.getVersion() );
- logRelease( release );
+ if (release.getVersion() != null && release.getVersion().equals(version)) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Found the correct release: " + release.getVersion());
+ logRelease(release);
}
return release;
}
@@ -110,16 +97,14 @@ protected Release getRelease( List releases, String version )
return null;
}
- protected void logRelease( Release release )
- {
+ protected void logRelease(Release release) {
Action action;
- for ( Action action1 : release.getActions() )
- {
+ for (Action action1 : release.getActions()) {
action = action1;
- getLog().debug( "o " + action.getType() );
- getLog().debug( "issue : " + action.getIssue() );
- getLog().debug( "action : " + action.getAction() );
- getLog().debug( "dueTo : " + action.getDueTo() );
+ getLog().debug("o " + action.getType());
+ getLog().debug("issue : " + action.getIssue());
+ getLog().debug("action : " + action.getAction());
+ getLog().debug("dueTo : " + action.getDueTo());
}
}
@@ -131,18 +116,14 @@ protected void logRelease( Release release )
* @param secondReleases Releases from the second issue tracker
* @return A list containing the merged releases
*/
- public List mergeReleases( final List firstReleases, final List secondReleases )
- {
- if ( firstReleases == null && secondReleases == null )
- {
+ public List mergeReleases(final List firstReleases, final List secondReleases) {
+ if (firstReleases == null && secondReleases == null) {
return Collections.emptyList();
}
- if ( firstReleases == null )
- {
+ if (firstReleases == null) {
return secondReleases;
}
- if ( secondReleases == null )
- {
+ if (secondReleases == null) {
return firstReleases;
}
@@ -151,26 +132,21 @@ public List mergeReleases( final List firstReleases, final Lis
// Loop through the releases from the first issue tracker, merging in
// actions from releases with the same version from the second issue
// tracker
- for ( Release firstRelease : firstReleases )
- {
- Release secondRelease = getRelease( secondReleases, firstRelease.getVersion() );
- if ( secondRelease != null )
- {
- if ( secondRelease.getActions() != null )
- {
- firstRelease.getActions().addAll( secondRelease.getActions() );
+ for (Release firstRelease : firstReleases) {
+ Release secondRelease = getRelease(secondReleases, firstRelease.getVersion());
+ if (secondRelease != null) {
+ if (secondRelease.getActions() != null) {
+ firstRelease.getActions().addAll(secondRelease.getActions());
}
}
- mergedReleases.add( firstRelease );
+ mergedReleases.add(firstRelease);
}
// Handle releases that are only in the second issue tracker
- for ( Release secondRelease : secondReleases )
- {
- Release mergedRelease = getRelease( mergedReleases, secondRelease.getVersion() );
- if ( mergedRelease == null )
- {
- mergedReleases.add( secondRelease );
+ for (Release secondRelease : secondReleases) {
+ Release mergedRelease = getRelease(mergedReleases, secondRelease.getVersion());
+ if (mergedRelease == null) {
+ mergedReleases.add(secondRelease);
}
}
return mergedReleases;
@@ -186,64 +162,53 @@ public List mergeReleases( final List firstReleases, final Lis
* @param componentReleases Releases from the child component
* @return A list containing the merged releases
*/
- public List mergeReleases( final List releases, final String componentName,
- final List componentReleases )
- {
- if ( releases == null && componentReleases == null )
- {
+ public List mergeReleases(
+ final List releases, final String componentName, final List componentReleases) {
+ if (releases == null && componentReleases == null) {
return Collections.emptyList();
}
- if ( componentReleases == null )
- {
+ if (componentReleases == null) {
return releases;
}
final List mergedReleases = new ArrayList<>();
- if ( releases != null )
- {
- for ( Object release1 : releases )
- {
+ if (releases != null) {
+ for (Object release1 : releases) {
final Release release = (Release) release1;
- final Release componentRelease = getRelease( componentReleases, release.getVersion() );
- if ( componentRelease != null )
- {
- release.addComponent( componentName, componentRelease );
+ final Release componentRelease = getRelease(componentReleases, release.getVersion());
+ if (componentRelease != null) {
+ release.addComponent(componentName, componentRelease);
}
- mergedReleases.add( release );
+ mergedReleases.add(release);
}
}
- for ( Object componentRelease1 : componentReleases )
- {
+ for (Object componentRelease1 : componentReleases) {
final Release release = (Release) componentRelease1;
- final Release mergedRelease = getRelease( mergedReleases, release.getVersion() );
- if ( mergedRelease == null )
- {
+ final Release mergedRelease = getRelease(mergedReleases, release.getVersion());
+ if (mergedRelease == null) {
final Release componentRelease = new Release();
- componentRelease.setVersion( release.getVersion() );
- componentRelease.setDateRelease( release.getDateRelease() );
- componentRelease.addComponent( componentName, release );
- mergedReleases.add( componentRelease );
+ componentRelease.setVersion(release.getVersion());
+ componentRelease.setDateRelease(release.getDateRelease());
+ componentRelease.addComponent(componentName, release);
+ mergedReleases.add(componentRelease);
}
}
return mergedReleases;
}
- private static String toString( Release release )
- {
+ private static String toString(Release release) {
return release.getClass().getSimpleName() + "[version='" + release.getVersion() + "'" + ", date='"
- + release.getDateRelease() + "'" + ", description='" + release.getDescription() + "'" + ", actionsSize="
- + release.getActions().size() + "]";
+ + release.getDateRelease() + "'" + ", description='" + release.getDescription() + "'" + ", actionsSize="
+ + release.getActions().size() + "]";
}
- public static String toString( List releases )
- {
- List releaseStrings = new ArrayList<>( releases.size() );
- for ( Release release : releases )
- {
- releaseStrings.add( toString( release ) );
+ public static String toString(List releases) {
+ List releaseStrings = new ArrayList<>(releases.size());
+ for (Release release : releases) {
+ releaseStrings.add(toString(release));
}
return releaseStrings.toString();
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/schema/ChangesSchemaValidator.java b/src/main/java/org/apache/maven/plugins/changes/schema/ChangesSchemaValidator.java
index 4fc564d6..e3e4d0b1 100644
--- a/src/main/java/org/apache/maven/plugins/changes/schema/ChangesSchemaValidator.java
+++ b/src/main/java/org/apache/maven/plugins/changes/schema/ChangesSchemaValidator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes.schema;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes.schema;
import java.io.File;
@@ -26,8 +25,7 @@
* @since 28 juil. 2008
* @version $Id$
*/
-public interface ChangesSchemaValidator
-{
+public interface ChangesSchemaValidator {
/**
* @param file File to validate.
* @param schemaVersion Schema version.
@@ -35,7 +33,6 @@ public interface ChangesSchemaValidator
* @return {@link XmlValidationHandler}
* @throws SchemaValidatorException if validation failed.
*/
- XmlValidationHandler validateXmlWithSchema( File file, String schemaVersion, boolean failOnValidationError )
- throws SchemaValidatorException;
-
+ XmlValidationHandler validateXmlWithSchema(File file, String schemaVersion, boolean failOnValidationError)
+ throws SchemaValidatorException;
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/schema/DefaultChangesSchemaValidator.java b/src/main/java/org/apache/maven/plugins/changes/schema/DefaultChangesSchemaValidator.java
index 068f34a6..ead9eb29 100644
--- a/src/main/java/org/apache/maven/plugins/changes/schema/DefaultChangesSchemaValidator.java
+++ b/src/main/java/org/apache/maven/plugins/changes/schema/DefaultChangesSchemaValidator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes.schema;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -18,6 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes.schema;
+
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
import java.io.File;
import java.io.IOException;
@@ -26,11 +30,6 @@
import java.util.HashMap;
import java.util.Map;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
import org.apache.commons.io.input.XmlStreamReader;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
@@ -41,10 +40,8 @@
* @since 28 juil. 2008
* @version $Id$
*/
-@Component( role = ChangesSchemaValidator.class, hint = "default" )
-public class DefaultChangesSchemaValidator
- implements ChangesSchemaValidator
-{
+@Component(role = ChangesSchemaValidator.class, hint = "default")
+public class DefaultChangesSchemaValidator implements ChangesSchemaValidator {
/** property schema */
public static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
@@ -53,52 +50,40 @@ public class DefaultChangesSchemaValidator
private Map compiledSchemas = new HashMap<>();
- public XmlValidationHandler validateXmlWithSchema( File file, String schemaVersion, boolean failOnValidationError )
- throws SchemaValidatorException
- {
- try
- {
+ public XmlValidationHandler validateXmlWithSchema(File file, String schemaVersion, boolean failOnValidationError)
+ throws SchemaValidatorException {
+ try {
String schemaPath = CHANGES_SCHEMA_PATH + "changes-" + schemaVersion + ".xsd";
- Schema schema = getSchema( schemaPath );
+ Schema schema = getSchema(schemaPath);
Validator validator = schema.newValidator();
- XmlValidationHandler baseHandler = new XmlValidationHandler( failOnValidationError );
+ XmlValidationHandler baseHandler = new XmlValidationHandler(failOnValidationError);
- validator.setErrorHandler( baseHandler );
+ validator.setErrorHandler(baseHandler);
- try ( Reader reader = new XmlStreamReader( file ) )
- {
- validator.validate( new StreamSource( reader ) );
+ try (Reader reader = new XmlStreamReader(file)) {
+ validator.validate(new StreamSource(reader));
}
return baseHandler;
- }
- catch ( IOException e )
- {
- throw new SchemaValidatorException( "IOException : " + e.getMessage(), e );
- }
- catch ( SAXException e )
- {
- throw new SchemaValidatorException( "SAXException : " + e.getMessage(), e );
- }
- catch ( Exception e )
- {
- throw new SchemaValidatorException( "Exception : " + e.getMessage(), e );
+ } catch (IOException e) {
+ throw new SchemaValidatorException("IOException : " + e.getMessage(), e);
+ } catch (SAXException e) {
+ throw new SchemaValidatorException("SAXException : " + e.getMessage(), e);
+ } catch (Exception e) {
+ throw new SchemaValidatorException("Exception : " + e.getMessage(), e);
}
}
- public Schema getSchema( String schemaPath )
- throws SAXException, IOException
- {
- if ( this.compiledSchemas.containsKey( schemaPath ) )
- {
- return this.compiledSchemas.get( schemaPath );
+ public Schema getSchema(String schemaPath) throws SAXException, IOException {
+ if (this.compiledSchemas.containsKey(schemaPath)) {
+ return this.compiledSchemas.get(schemaPath);
}
- Schema schema = this.compileJAXPSchema( schemaPath );
+ Schema schema = this.compileJAXPSchema(schemaPath);
- this.compiledSchemas.put( schemaPath, schema );
+ this.compiledSchemas.put(schemaPath, schema);
return schema;
}
@@ -108,45 +93,31 @@ public Schema getSchema( String schemaPath )
* @return Schema
* @throws Exception
*/
- private Schema compileJAXPSchema( String uriSchema )
- throws IOException, SAXException, NullPointerException
- {
+ private Schema compileJAXPSchema(String uriSchema) throws IOException, SAXException, NullPointerException {
InputStream in = null;
- try
- {
- in = Thread.currentThread().getContextClassLoader().getResourceAsStream( uriSchema );
- if ( in == null )
- {
- throw new NullPointerException( " impossible to load schema with path " + uriSchema );
+ try {
+ in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uriSchema);
+ if (in == null) {
+ throw new NullPointerException(" impossible to load schema with path " + uriSchema);
}
- //newInstance de SchemaFactory not ThreadSafe
- final Schema schema = SchemaFactory.newInstance( W3C_XML_SCHEMA ).newSchema( new StreamSource( in ) );
+ // newInstance de SchemaFactory not ThreadSafe
+ final Schema schema = SchemaFactory.newInstance(W3C_XML_SCHEMA).newSchema(new StreamSource(in));
in.close();
in = null;
return schema;
- }
- finally
- {
- IOUtil.close( in );
+ } finally {
+ IOUtil.close(in);
}
}
- public void loadSchema( String uriSchema )
- throws SchemaValidatorException
- {
- try
- {
- this.getSchema( uriSchema );
- }
- catch ( SAXException e )
- {
- throw new SchemaValidatorException( "SAXException : " + e.getMessage(), e );
+ public void loadSchema(String uriSchema) throws SchemaValidatorException {
+ try {
+ this.getSchema(uriSchema);
+ } catch (SAXException e) {
+ throw new SchemaValidatorException("SAXException : " + e.getMessage(), e);
+ } catch (IOException e) {
+ throw new SchemaValidatorException("IOException : " + e.getMessage(), e);
}
- catch ( IOException e )
- {
- throw new SchemaValidatorException( "IOException : " + e.getMessage(), e );
- }
-
}
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/schema/SchemaValidatorException.java b/src/main/java/org/apache/maven/plugins/changes/schema/SchemaValidatorException.java
index e96ece84..be238442 100644
--- a/src/main/java/org/apache/maven/plugins/changes/schema/SchemaValidatorException.java
+++ b/src/main/java/org/apache/maven/plugins/changes/schema/SchemaValidatorException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes.schema;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -18,15 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes.schema;
/**
* @author Olivier Lamy
* @since 28 juil. 2008
* @version $Id$
*/
-public class SchemaValidatorException
- extends Exception
-{
+public class SchemaValidatorException extends Exception {
/**
* Generated serial UID.
@@ -37,9 +34,7 @@ public class SchemaValidatorException
* @param message Message.
* @param cause Cause.
*/
- public SchemaValidatorException( String message, Throwable cause )
- {
- super( message, cause );
+ public SchemaValidatorException(String message, Throwable cause) {
+ super(message, cause);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/changes/schema/XmlValidationHandler.java b/src/main/java/org/apache/maven/plugins/changes/schema/XmlValidationHandler.java
index b7ae15ff..40bb18d1 100644
--- a/src/main/java/org/apache/maven/plugins/changes/schema/XmlValidationHandler.java
+++ b/src/main/java/org/apache/maven/plugins/changes/schema/XmlValidationHandler.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.changes.schema;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.changes.schema;
import java.util.ArrayList;
import java.util.List;
@@ -32,10 +31,8 @@
* @since 28 juil. 2008
* @version $Id$
*/
-public class XmlValidationHandler
- extends DefaultHandler
-{
-
+public class XmlValidationHandler extends DefaultHandler {
+
private boolean parsingError = false;
private List errors = new ArrayList<>();
@@ -49,97 +46,80 @@ public class XmlValidationHandler
/**
* @param failOnValidationError If fail on validation error.
*/
- public XmlValidationHandler( boolean failOnValidationError )
- {
+ public XmlValidationHandler(boolean failOnValidationError) {
this.failOnValidationError = failOnValidationError;
}
/**
* @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
*/
- public void error( SAXParseException excp )
- throws SAXException
- {
- this.setErrorParsing( true );
- this.errors.add( excp );
- if ( this.failOnValidationError )
- {
- throw new SAXException( excp.getMessage(), excp );
+ public void error(SAXParseException excp) throws SAXException {
+ this.setErrorParsing(true);
+ this.errors.add(excp);
+ if (this.failOnValidationError) {
+ throw new SAXException(excp.getMessage(), excp);
}
}
/**
* @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
*/
- public void fatalError( SAXParseException excp )
- throws SAXException
- {
- this.fatalErrors.add( excp );
- if ( this.failOnValidationError )
- {
- throw new SAXException( excp.getMessage(), excp );
+ public void fatalError(SAXParseException excp) throws SAXException {
+ this.fatalErrors.add(excp);
+ if (this.failOnValidationError) {
+ throw new SAXException(excp.getMessage(), excp);
}
}
/**
* @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
*/
- public void warning( SAXParseException excp )
- {
- this.warnings.add( excp );
+ public void warning(SAXParseException excp) {
+ this.warnings.add(excp);
}
/**
* @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
*/
- public void startElement( String uri, String localName, String qName, Attributes attributes )
- {
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
// nothing
}
/**
* @return Returns the errorParsing.
*/
- public boolean isErrorParsing()
- {
+ public boolean isErrorParsing() {
return this.parsingError;
}
/**
* @param error The errorParsing to set.
*/
- public void setErrorParsing( boolean error )
- {
+ public void setErrorParsing(boolean error) {
this.parsingError = error;
}
- public List getErrors()
- {
+ public List getErrors() {
return errors;
}
- public void setErrors( List errors )
- {
+ public void setErrors(List errors) {
this.errors = errors;
}
- public List getFatalErrors()
- {
+ public List getFatalErrors() {
return fatalErrors;
}
- public void setFatalErrors( List fatalErrors )
- {
+ public void setFatalErrors(List fatalErrors) {
this.fatalErrors = fatalErrors;
}
- public List getWarnings()
- {
+ public List getWarnings() {
return warnings;
}
- public void setWarnings( List warnings )
- {
+ public void setWarnings(List warnings) {
this.warnings = warnings;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/github/GitHubDownloader.java b/src/main/java/org/apache/maven/plugins/github/GitHubDownloader.java
index cdd3a782..410deab0 100644
--- a/src/main/java/org/apache/maven/plugins/github/GitHubDownloader.java
+++ b/src/main/java/org/apache/maven/plugins/github/GitHubDownloader.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.github;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.github;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.issues.Issue;
@@ -32,19 +39,10 @@
import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.service.IssueService;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* @since 2.8
*/
-public class GitHubDownloader
-{
+public class GitHubDownloader {
/**
* The github client.
@@ -76,175 +74,148 @@ public class GitHubDownloader
*/
private String githubIssueURL;
- public GitHubDownloader( MavenProject project, String githubScheme, int githubPort, boolean includeOpenIssues,
- boolean onlyMilestoneIssues )
- throws MalformedURLException
- {
+ public GitHubDownloader(
+ MavenProject project,
+ String githubScheme,
+ int githubPort,
+ boolean includeOpenIssues,
+ boolean onlyMilestoneIssues)
+ throws MalformedURLException {
this.includeOpenIssues = includeOpenIssues;
this.onlyMilestoneIssues = onlyMilestoneIssues;
- URL githubURL = new URL( project.getIssueManagement().getUrl() );
+ URL githubURL = new URL(project.getIssueManagement().getUrl());
// The githubclient prefers to connect to 'github.com' using the api domain, unlike github enterprise
// which can connect fine using its domain, so for github.com use empty constructor
- if ( githubURL.getHost().equalsIgnoreCase( "github.com" ) )
- {
+ if (githubURL.getHost().equalsIgnoreCase("github.com")) {
this.client = new GitHubClient();
- }
- else
- {
- this.client = new GitHubClient( githubURL.getHost(), githubPort, githubScheme );
+ } else {
+ this.client = new GitHubClient(githubURL.getHost(), githubPort, githubScheme);
}
this.githubIssueURL = project.getIssueManagement().getUrl();
- if ( !this.githubIssueURL.endsWith( "/" ) )
- {
+ if (!this.githubIssueURL.endsWith("/")) {
this.githubIssueURL = this.githubIssueURL + "/";
}
String urlPath = githubURL.getPath();
- if ( urlPath.startsWith( "/" ) )
- {
- urlPath = urlPath.substring( 1 );
+ if (urlPath.startsWith("/")) {
+ urlPath = urlPath.substring(1);
}
- if ( urlPath.endsWith( "/" ) )
- {
- urlPath = urlPath.substring( 0, urlPath.length() - 2 );
+ if (urlPath.endsWith("/")) {
+ urlPath = urlPath.substring(0, urlPath.length() - 2);
}
- String[] urlPathParts = urlPath.split( "/" );
+ String[] urlPathParts = urlPath.split("/");
- if ( urlPathParts.length != 3 )
- {
- throw new MalformedURLException( "GitHub issue management URL must look like, "
- + "[GITHUB_DOMAIN]/[OWNER]/[REPO]/issues" );
+ if (urlPathParts.length != 3) {
+ throw new MalformedURLException(
+ "GitHub issue management URL must look like, " + "[GITHUB_DOMAIN]/[OWNER]/[REPO]/issues");
}
this.githubOwner = urlPathParts[0];
this.githubRepo = urlPathParts[1];
}
- protected Issue createIssue( org.eclipse.egit.github.core.Issue githubIssue )
- {
+ protected Issue createIssue(org.eclipse.egit.github.core.Issue githubIssue) {
Issue issue = new Issue();
- issue.setKey( String.valueOf( githubIssue.getNumber() ) );
- issue.setId( String.valueOf( githubIssue.getNumber() ) );
+ issue.setKey(String.valueOf(githubIssue.getNumber()));
+ issue.setId(String.valueOf(githubIssue.getNumber()));
- issue.setLink( this.githubIssueURL + githubIssue.getNumber() );
+ issue.setLink(this.githubIssueURL + githubIssue.getNumber());
- issue.setCreated( githubIssue.getCreatedAt() );
+ issue.setCreated(githubIssue.getCreatedAt());
- issue.setUpdated( githubIssue.getUpdatedAt() );
+ issue.setUpdated(githubIssue.getUpdatedAt());
- if ( githubIssue.getAssignee() != null )
- {
- if ( githubIssue.getAssignee().getName() != null )
- {
- issue.setAssignee( githubIssue.getAssignee().getName() );
- }
- else
- {
- issue.setAssignee( githubIssue.getAssignee().getLogin() );
+ if (githubIssue.getAssignee() != null) {
+ if (githubIssue.getAssignee().getName() != null) {
+ issue.setAssignee(githubIssue.getAssignee().getName());
+ } else {
+ issue.setAssignee(githubIssue.getAssignee().getLogin());
}
}
- issue.setTitle( githubIssue.getTitle() );
+ issue.setTitle(githubIssue.getTitle());
- issue.setSummary( githubIssue.getTitle() );
+ issue.setSummary(githubIssue.getTitle());
- if ( githubIssue.getMilestone() != null )
- {
- issue.addFixVersion( githubIssue.getMilestone().getTitle() );
+ if (githubIssue.getMilestone() != null) {
+ issue.addFixVersion(githubIssue.getMilestone().getTitle());
}
- issue.setReporter( githubIssue.getUser().getLogin() );
+ issue.setReporter(githubIssue.getUser().getLogin());
- if ( githubIssue.getClosedAt() != null )
- {
- issue.setStatus( "closed" );
- }
- else
- {
- issue.setStatus( "open" );
+ if (githubIssue.getClosedAt() != null) {
+ issue.setStatus("closed");
+ } else {
+ issue.setStatus("open");
}
List labels = githubIssue.getLabels();
- if ( labels != null && !labels.isEmpty() )
- {
- issue.setType( labels.get( 0 ).getName() );
+ if (labels != null && !labels.isEmpty()) {
+ issue.setType(labels.get(0).getName());
}
return issue;
}
- public List getIssueList()
- throws IOException
- {
+ public List getIssueList() throws IOException {
List issueList = new ArrayList<>();
- IssueService service = new IssueService( client );
+ IssueService service = new IssueService(client);
Map issueFilter = new HashMap<>();
- if ( includeOpenIssues )
- {
+ if (includeOpenIssues) {
// Adding open issues
- for ( org.eclipse.egit.github.core.Issue issue : service.getIssues( githubOwner, githubRepo, issueFilter ) )
- {
- if ( !onlyMilestoneIssues || issue.getMilestone() != null )
- {
- issueList.add( createIssue( issue ) );
+ for (org.eclipse.egit.github.core.Issue issue : service.getIssues(githubOwner, githubRepo, issueFilter)) {
+ if (!onlyMilestoneIssues || issue.getMilestone() != null) {
+ issueList.add(createIssue(issue));
}
}
}
// Adding closed issues
- issueFilter.put( "state", "closed" );
+ issueFilter.put("state", "closed");
- for ( org.eclipse.egit.github.core.Issue issue : service.getIssues( githubOwner, githubRepo, issueFilter ) )
- {
- if ( !onlyMilestoneIssues || issue.getMilestone() != null )
- {
- issueList.add( createIssue( issue ) );
+ for (org.eclipse.egit.github.core.Issue issue : service.getIssues(githubOwner, githubRepo, issueFilter)) {
+ if (!onlyMilestoneIssues || issue.getMilestone() != null) {
+ issueList.add(createIssue(issue));
}
}
return issueList;
}
- public void configureAuthentication( SettingsDecrypter decrypter, String githubAPIServerId, Settings settings,
- Log log )
- {
+ public void configureAuthentication(
+ SettingsDecrypter decrypter, String githubAPIServerId, Settings settings, Log log) {
boolean configured = false;
List servers = settings.getServers();
- for ( Server server : servers )
- {
- if ( server.getId().equals( githubAPIServerId ) )
- {
- SettingsDecryptionResult result = decrypter.decrypt( new DefaultSettingsDecryptionRequest( server ) );
- for ( SettingsProblem problem : result.getProblems() )
- {
- log.error( problem.getMessage(), problem.getException() );
+ for (Server server : servers) {
+ if (server.getId().equals(githubAPIServerId)) {
+ SettingsDecryptionResult result = decrypter.decrypt(new DefaultSettingsDecryptionRequest(server));
+ for (SettingsProblem problem : result.getProblems()) {
+ log.error(problem.getMessage(), problem.getException());
}
server = result.getServer();
String user = server.getUsername();
String password = server.getPassword();
- this.client.setCredentials( user, password );
+ this.client.setCredentials(user, password);
configured = true;
break;
}
}
- if ( !configured )
- {
- log.warn( "Can't find server id [" + githubAPIServerId + "] configured in githubAPIServerId." );
+ if (!configured) {
+ log.warn("Can't find server id [" + githubAPIServerId + "] configured in githubAPIServerId.");
}
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/github/GitHubIssueManagementSystem.java b/src/main/java/org/apache/maven/plugins/github/GitHubIssueManagementSystem.java
index 5c7e7cd1..9ae6b7aa 100644
--- a/src/main/java/org/apache/maven/plugins/github/GitHubIssueManagementSystem.java
+++ b/src/main/java/org/apache/maven/plugins/github/GitHubIssueManagementSystem.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.github;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.github;
import org.apache.maven.plugins.changes.IssueType;
import org.apache.maven.plugins.issues.AbstractIssueManagementSystem;
@@ -25,26 +24,21 @@
/**
* @since 2.8
*/
-public class GitHubIssueManagementSystem
- extends AbstractIssueManagementSystem
-{
+public class GitHubIssueManagementSystem extends AbstractIssueManagementSystem {
private static final String DEFAULT_ADD_TYPE = "enhancement";
private static final String DEFAULT_FIX_TYPE = "bug";
- public GitHubIssueManagementSystem()
- {
+ public GitHubIssueManagementSystem() {
super();
// The standard issue types for GitHub
- issueTypeMap.put( DEFAULT_ADD_TYPE, IssueType.ADD );
- issueTypeMap.put( DEFAULT_FIX_TYPE, IssueType.FIX );
+ issueTypeMap.put(DEFAULT_ADD_TYPE, IssueType.ADD);
+ issueTypeMap.put(DEFAULT_FIX_TYPE, IssueType.FIX);
}
@Override
- public String getName()
- {
+ public String getName() {
return "Github";
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/github/GitHubMojo.java b/src/main/java/org/apache/maven/plugins/github/GitHubMojo.java
index cdd11fed..60937665 100644
--- a/src/main/java/org/apache/maven/plugins/github/GitHubMojo.java
+++ b/src/main/java/org/apache/maven/plugins/github/GitHubMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.github;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.github;
import java.net.MalformedURLException;
import java.util.HashMap;
@@ -45,27 +44,24 @@
* @author Bryan Baugher
* @since 2.8
*/
-@Mojo( name = "github-report", threadSafe = true )
-public class GitHubMojo
- extends AbstractChangesReport
-{
+@Mojo(name = "github-report", threadSafe = true)
+public class GitHubMojo extends AbstractChangesReport {
/**
* Valid Github columns.
*/
private static Map githubColumns = new HashMap<>();
- static
- {
- githubColumns.put( "Assignee", IssuesReportHelper.COLUMN_ASSIGNEE );
- githubColumns.put( "Created", IssuesReportHelper.COLUMN_CREATED );
- githubColumns.put( "Fix Version", IssuesReportHelper.COLUMN_FIX_VERSION );
- githubColumns.put( "Id", IssuesReportHelper.COLUMN_ID );
- githubColumns.put( "Reporter", IssuesReportHelper.COLUMN_REPORTER );
- githubColumns.put( "Status", IssuesReportHelper.COLUMN_STATUS );
- githubColumns.put( "Summary", IssuesReportHelper.COLUMN_SUMMARY );
- githubColumns.put( "Type", IssuesReportHelper.COLUMN_TYPE );
- githubColumns.put( "Updated", IssuesReportHelper.COLUMN_UPDATED );
+ static {
+ githubColumns.put("Assignee", IssuesReportHelper.COLUMN_ASSIGNEE);
+ githubColumns.put("Created", IssuesReportHelper.COLUMN_CREATED);
+ githubColumns.put("Fix Version", IssuesReportHelper.COLUMN_FIX_VERSION);
+ githubColumns.put("Id", IssuesReportHelper.COLUMN_ID);
+ githubColumns.put("Reporter", IssuesReportHelper.COLUMN_REPORTER);
+ githubColumns.put("Status", IssuesReportHelper.COLUMN_STATUS);
+ githubColumns.put("Summary", IssuesReportHelper.COLUMN_SUMMARY);
+ githubColumns.put("Type", IssuesReportHelper.COLUMN_TYPE);
+ githubColumns.put("Updated", IssuesReportHelper.COLUMN_UPDATED);
}
/**
@@ -82,66 +78,63 @@ public class GitHubMojo
* Reporter
, Status
, Summary
, Type
and Updated
.
*
*/
- @Parameter( defaultValue = "Id,Type,Summary,Assignee,Reporter,Status,Created,Updated,Fix Version" )
+ @Parameter(defaultValue = "Id,Type,Summary,Assignee,Reporter,Status,Created,Updated,Fix Version")
private String columnNames;
/**
* The scheme of your github api domain. Only use if using github enterprise.
*/
- @Parameter( defaultValue = "http" )
+ @Parameter(defaultValue = "http")
private String githubAPIScheme;
/**
* The port of your github api domain. Only use if using github enterprise.
*/
- @Parameter( defaultValue = "80" )
+ @Parameter(defaultValue = "80")
private int githubAPIPort;
/**
* The settings.xml server id to be used to authenticate into github api domain. Only use if using github
* enterprise.
*/
- @Parameter( defaultValue = "github" )
+ @Parameter(defaultValue = "github")
private String githubAPIServerId;
/**
* Settings XML configuration.
*/
- @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+ @Parameter(defaultValue = "${settings}", readonly = true, required = true)
private Settings settings;
/**
* Boolean which says if we should include open issues in the report.
*/
- @Parameter( defaultValue = "true" )
+ @Parameter(defaultValue = "true")
private boolean includeOpenIssues;
/**
* Boolean which says if we should include only issues with milestones.
*/
- @Parameter( defaultValue = "true" )
+ @Parameter(defaultValue = "true")
private boolean onlyMilestoneIssues;
/**
* If you only want to show issues for the current version in the report. The current version being used is
* ${project.version}
minus any "-SNAPSHOT" suffix.
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean onlyCurrentVersion;
- public String getOutputName()
- {
+ public String getOutputName() {
return "github-report";
}
- public String getName( Locale locale )
- {
- return getBundle( locale ).getString( "report.issues.name" );
+ public String getName(Locale locale) {
+ return getBundle(locale).getString("report.issues.name");
}
- public String getDescription( Locale locale )
- {
- return getBundle( locale ).getString( "report.issues.description" );
+ public String getDescription(Locale locale) {
+ return getBundle(locale).getString("report.issues.description");
}
/* --------------------------------------------------------------------- */
@@ -151,73 +144,58 @@ public String getDescription( Locale locale )
/**
* @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
*/
- public boolean canGenerateReport()
- {
+ public boolean canGenerateReport() {
// Run only at the execution root
- if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
- {
- getLog().info( "Skipping the GitHub Report in this project because it's not the Execution Root" );
+ if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
+ getLog().info("Skipping the GitHub Report in this project because it's not the Execution Root");
return false;
}
- String message = ProjectUtils.validateIssueManagement( project, "GitHub", "GitHub Report" );
- if ( message != null )
- {
- getLog().warn( message );
+ String message = ProjectUtils.validateIssueManagement(project, "GitHub", "GitHub Report");
+ if (message != null) {
+ getLog().warn(message);
}
return message == null;
}
@Override
- protected void executeReport( Locale locale )
- throws MavenReportException
- {
+ protected void executeReport(Locale locale) throws MavenReportException {
// Validate parameters
- List columnIds = IssuesReportHelper.getColumnIds( columnNames, githubColumns );
- if ( columnIds.size() == 0 )
- {
+ List columnIds = IssuesReportHelper.getColumnIds(columnNames, githubColumns);
+ if (columnIds.size() == 0) {
// This can happen if the user has configured column names and they are all invalid
- throw new MavenReportException( "maven-changes-plugin: None of the configured columnNames '" + columnNames
- + "' are valid." );
+ throw new MavenReportException(
+ "maven-changes-plugin: None of the configured columnNames '" + columnNames + "' are valid.");
}
- try
- {
+ try {
// Download issues
- GitHubDownloader issueDownloader =
- new GitHubDownloader( project, githubAPIScheme, githubAPIPort, includeOpenIssues, onlyMilestoneIssues );
+ GitHubDownloader issueDownloader = new GitHubDownloader(
+ project, githubAPIScheme, githubAPIPort, includeOpenIssues, onlyMilestoneIssues);
- issueDownloader.configureAuthentication( settingsDecrypter, githubAPIServerId, settings, getLog() );
+ issueDownloader.configureAuthentication(settingsDecrypter, githubAPIServerId, settings, getLog());
List issueList = issueDownloader.getIssueList();
- if ( onlyCurrentVersion )
- {
- issueList = IssueUtils.getIssuesForVersion( issueList, project.getVersion() );
- getLog().info( "The GitHub Report will contain issues only for the current version." );
+ if (onlyCurrentVersion) {
+ issueList = IssueUtils.getIssuesForVersion(issueList, project.getVersion());
+ getLog().info("The GitHub Report will contain issues only for the current version.");
}
// Generate the report
- IssuesReportGenerator report = new IssuesReportGenerator( IssuesReportHelper.toIntArray( columnIds ) );
+ IssuesReportGenerator report = new IssuesReportGenerator(IssuesReportHelper.toIntArray(columnIds));
- if ( issueList.isEmpty() )
- {
- report.doGenerateEmptyReport( getBundle( locale ), getSink() );
- getLog().warn( "No issue was matched." );
- }
- else
- {
- report.doGenerateReport( getBundle( locale ), getSink(), issueList );
+ if (issueList.isEmpty()) {
+ report.doGenerateEmptyReport(getBundle(locale), getSink());
+ getLog().warn("No issue was matched.");
+ } else {
+ report.doGenerateReport(getBundle(locale), getSink(), issueList);
}
- }
- catch ( MalformedURLException e )
- {
+ } catch (MalformedURLException e) {
// Rethrow this error so that the build fails
- throw new MavenReportException( "The Github URL is incorrect." );
- }
- catch ( Exception e )
- {
- throw new MavenReportException( e.getMessage(), e );
+ throw new MavenReportException("The Github URL is incorrect.");
+ } catch (Exception e) {
+ throw new MavenReportException(e.getMessage(), e);
}
}
@@ -225,9 +203,7 @@ protected void executeReport( Locale locale )
/* Private methods */
/* --------------------------------------------------------------------- */
- private ResourceBundle getBundle( Locale locale )
- {
- return ResourceBundle.getBundle( "github-report", locale, this.getClass().getClassLoader() );
+ private ResourceBundle getBundle(Locale locale) {
+ return ResourceBundle.getBundle("github-report", locale, this.getClass().getClassLoader());
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/issues/AbstractIssueManagementSystem.java b/src/main/java/org/apache/maven/plugins/issues/AbstractIssueManagementSystem.java
index 5e63c7c4..631388be 100644
--- a/src/main/java/org/apache/maven/plugins/issues/AbstractIssueManagementSystem.java
+++ b/src/main/java/org/apache/maven/plugins/issues/AbstractIssueManagementSystem.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.issues;
import java.util.HashMap;
import java.util.Map;
@@ -36,13 +35,10 @@
*
* @version $Id$
*/
-public abstract class AbstractIssueManagementSystem
- implements IssueManagementSystem
-{
+public abstract class AbstractIssueManagementSystem implements IssueManagementSystem {
protected Map issueTypeMap;
- protected AbstractIssueManagementSystem()
- {
+ protected AbstractIssueManagementSystem() {
issueTypeMap = new HashMap<>();
}
@@ -50,8 +46,7 @@ protected AbstractIssueManagementSystem()
* (non-Javadoc)
* @see org.apache.maven.plugins.issues.IssueManagementSystem#getIssueTypeMap()
*/
- public Map getIssueTypeMap()
- {
+ public Map getIssueTypeMap() {
return issueTypeMap;
}
@@ -65,21 +60,16 @@ public Map getIssueTypeMap()
* (non-Javadoc)
* @see org.apache.maven.plugins.issues.IssueManagementSystem#applyConfiguration(java.util.Map)
*/
- public void applyConfiguration( Map issueTypes )
- throws MojoExecutionException
- {
- for ( Map.Entry me : issueTypes.entrySet() )
- {
- IssueType type = IssueType.lookupByKey( me.getKey() );
- if ( type == null )
- {
- throw new MojoExecutionException( "Invalid issue action " + me.getKey() );
+ public void applyConfiguration(Map issueTypes) throws MojoExecutionException {
+ for (Map.Entry me : issueTypes.entrySet()) {
+ IssueType type = IssueType.lookupByKey(me.getKey());
+ if (type == null) {
+ throw new MojoExecutionException("Invalid issue action " + me.getKey());
}
String imsTypes = me.getValue();
- String[] imsTypeArray = imsTypes.split( "," );
- for ( String imsType : imsTypeArray )
- {
- issueTypeMap.put( imsType, type );
+ String[] imsTypeArray = imsTypes.split(",");
+ for (String imsType : imsTypeArray) {
+ issueTypeMap.put(imsType, type);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugins/issues/AbstractIssuesReportGenerator.java b/src/main/java/org/apache/maven/plugins/issues/AbstractIssuesReportGenerator.java
index a506940c..abd1e0ae 100644
--- a/src/main/java/org/apache/maven/plugins/issues/AbstractIssuesReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/issues/AbstractIssuesReportGenerator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.issues;
+
+import java.util.ResourceBundle;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import java.util.ResourceBundle;
-
/**
* An abstract super class that helps when generating a report on issues.
*
@@ -32,57 +31,45 @@
* @version $Id$
* @since 2.4
*/
-public abstract class AbstractIssuesReportGenerator
-{
+public abstract class AbstractIssuesReportGenerator {
protected String author;
protected String title;
- public AbstractIssuesReportGenerator()
- {
- }
+ public AbstractIssuesReportGenerator() {}
- public String getAuthor()
- {
+ public String getAuthor() {
return author;
}
- public void setAuthor( String author )
- {
+ public void setAuthor(String author) {
this.author = author;
}
- public String getTitle()
- {
+ public String getTitle() {
return title;
}
- public void setTitle( String title )
- {
+ public void setTitle(String title) {
this.title = title;
}
- protected void sinkBeginReport( Sink sink, ResourceBundle bundle )
- {
+ protected void sinkBeginReport(Sink sink, ResourceBundle bundle) {
sink.head();
String title;
- if ( this.title != null )
- {
+ if (this.title != null) {
title = this.title;
- }
- else
- {
- title = bundle.getString( "report.issues.header" );
+ } else {
+ title = bundle.getString("report.issues.header");
}
sink.title();
- sink.text( title );
+ sink.text(title);
sink.title_();
- if ( author != null && !author.isEmpty() )
- {
+ if (author != null && !author.isEmpty()) {
sink.author();
- sink.text( author );
+ sink.text(author);
sink.author_();
}
@@ -94,38 +81,32 @@ protected void sinkBeginReport( Sink sink, ResourceBundle bundle )
sink.sectionTitle1();
- sink.text( title );
+ sink.text(title);
sink.sectionTitle1_();
}
- protected void sinkCell( Sink sink, String text )
- {
+ protected void sinkCell(Sink sink, String text) {
sink.tableCell();
- if ( text != null )
- {
- sink.text( text );
- }
- else
- {
+ if (text != null) {
+ sink.text(text);
+ } else {
sink.nonBreakingSpace();
}
sink.tableCell_();
}
- protected void sinkCellLink( Sink sink, String text, String link )
- {
+ protected void sinkCellLink(Sink sink, String text, String link) {
sink.tableCell();
- sinkLink( sink, text, link );
+ sinkLink(sink, text, link);
sink.tableCell_();
}
- protected void sinkEndReport( Sink sink )
- {
+ protected void sinkEndReport(Sink sink) {
sink.section1_();
sink.body_();
@@ -135,68 +116,55 @@ protected void sinkEndReport( Sink sink )
sink.close();
}
- protected void sinkFigure( Sink sink, String image, String altText )
- {
+ protected void sinkFigure(Sink sink, String image, String altText) {
SinkEventAttributes attributes = new SinkEventAttributeSet();
- attributes.addAttribute( "alt", altText );
- attributes.addAttribute( "title", altText );
+ attributes.addAttribute("alt", altText);
+ attributes.addAttribute("title", altText);
- sink.figureGraphics( image, attributes );
+ sink.figureGraphics(image, attributes);
}
- protected void sinkHeader( Sink sink, String header )
- {
+ protected void sinkHeader(Sink sink, String header) {
sink.tableHeaderCell();
- sink.text( header );
+ sink.text(header);
sink.tableHeaderCell_();
}
- protected void sinkLink( Sink sink, String text, String link )
- {
- sink.link( link );
+ protected void sinkLink(Sink sink, String text, String link) {
+ sink.link(link);
- sink.text( text );
+ sink.text(text);
sink.link_();
}
- protected void sinkShowTypeIcon( Sink sink, String type )
- {
+ protected void sinkShowTypeIcon(Sink sink, String type) {
String image = "";
String altText = "";
- if ( type == null )
- {
+ if (type == null) {
image = "images/icon_help_sml.gif";
altText = "Unknown";
- }
- else if ( type.equals( "fix" ) )
- {
+ } else if (type.equals("fix")) {
image = "images/fix.gif";
altText = "Fix";
- }
- else if ( type.equals( "update" ) )
- {
+ } else if (type.equals("update")) {
image = "images/update.gif";
altText = "Update";
- }
- else if ( type.equals( "add" ) )
- {
+ } else if (type.equals("add")) {
image = "images/add.gif";
altText = "Add";
- }
- else if ( type.equals( "remove" ) )
- {
+ } else if (type.equals("remove")) {
image = "images/remove.gif";
altText = "Remove";
}
sink.tableCell();
- sinkFigure( sink, image, altText );
+ sinkFigure(sink, image, altText);
sink.tableCell_();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/maven/plugins/issues/Issue.java b/src/main/java/org/apache/maven/plugins/issues/Issue.java
index 09c24d6f..8947e0cb 100644
--- a/src/main/java/org/apache/maven/plugins/issues/Issue.java
+++ b/src/main/java/org/apache/maven/plugins/issues/Issue.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.issues;
import java.util.ArrayList;
import java.util.Date;
@@ -30,8 +29,7 @@
* @version $Id$
* @since 2.4
*/
-public class Issue
-{
+public class Issue {
private String assignee;
private List comments;
@@ -66,195 +64,155 @@ public class Issue
private String version;
- public Issue()
- {
- }
+ public Issue() {}
- public String getAssignee()
- {
+ public String getAssignee() {
return assignee;
}
- public void setAssignee( String assignee )
- {
+ public void setAssignee(String assignee) {
this.assignee = assignee;
}
- public List getComments()
- {
+ public List getComments() {
return comments;
}
- public void addComment( String comment )
- {
- if ( comments == null )
- {
+ public void addComment(String comment) {
+ if (comments == null) {
comments = new ArrayList<>();
}
- comments.add( comment );
+ comments.add(comment);
}
- public List getComponents()
- {
+ public List getComponents() {
return components;
}
- public void addComponent( String component )
- {
- if ( components == null )
- {
+ public void addComponent(String component) {
+ if (components == null) {
components = new ArrayList<>();
}
- components.add( component );
+ components.add(component);
}
- public Date getCreated()
- {
+ public Date getCreated() {
return created;
}
- public void setCreated( Date created )
- {
+ public void setCreated(Date created) {
this.created = created;
}
- public List getFixVersions()
- {
+ public List getFixVersions() {
return fixVersions;
}
- public void addFixVersion( String fixVersion )
- {
- if ( fixVersions == null )
- {
+ public void addFixVersion(String fixVersion) {
+ if (fixVersions == null) {
fixVersions = new ArrayList<>();
}
- fixVersions.add( fixVersion );
+ fixVersions.add(fixVersion);
}
- public String getId()
- {
+ public String getId() {
return id;
}
- public void setId( String id )
- {
+ public void setId(String id) {
this.id = id;
}
- public String getKey()
- {
+ public String getKey() {
return key;
}
- public void setKey( String key )
- {
+ public void setKey(String key) {
this.key = key;
}
- public String getLink()
- {
+ public String getLink() {
return link;
}
- public void setLink( String link )
- {
+ public void setLink(String link) {
this.link = link;
}
- public String getPriority()
- {
+ public String getPriority() {
return priority;
}
- public void setPriority( String priority )
- {
+ public void setPriority(String priority) {
this.priority = priority;
}
- public String getReporter()
- {
+ public String getReporter() {
return reporter;
}
- public void setReporter( String reporter )
- {
+ public void setReporter(String reporter) {
this.reporter = reporter;
}
- public String getResolution()
- {
+ public String getResolution() {
return resolution;
}
- public void setResolution( String resolution )
- {
+ public void setResolution(String resolution) {
this.resolution = resolution;
}
- public String getStatus()
- {
+ public String getStatus() {
return status;
}
- public void setStatus( String status )
- {
+ public void setStatus(String status) {
this.status = status;
}
- public String getSummary()
- {
+ public String getSummary() {
return summary;
}
- public void setSummary( String summary )
- {
+ public void setSummary(String summary) {
this.summary = summary;
}
- public String getTitle()
- {
+ public String getTitle() {
return title;
}
- public void setTitle( String title )
- {
+ public void setTitle(String title) {
this.title = title;
}
- public String getType()
- {
+ public String getType() {
return type;
}
- public void setType( String type )
- {
+ public void setType(String type) {
this.type = type;
}
- public Date getUpdated()
- {
+ public Date getUpdated() {
return updated;
}
- public void setUpdated( Date updated )
- {
+ public void setUpdated(Date updated) {
this.updated = updated;
}
- public String getVersion()
- {
+ public String getVersion() {
return version;
}
- public void setVersion( String version )
- {
+ public void setVersion(String version) {
this.version = version;
}
- public String toString()
- {
+ public String toString() {
return this.getClass().getSimpleName() + "[id='" + this.getId() + "'" + ", title='" + this.getTitle() + "'"
- + ", fixVersions='" + this.getFixVersions() + "'" + "]";
+ + ", fixVersions='" + this.getFixVersions() + "'" + "]";
}
}
diff --git a/src/main/java/org/apache/maven/plugins/issues/IssueManagementSystem.java b/src/main/java/org/apache/maven/plugins/issues/IssueManagementSystem.java
index 46a10a6a..58c282c5 100644
--- a/src/main/java/org/apache/maven/plugins/issues/IssueManagementSystem.java
+++ b/src/main/java/org/apache/maven/plugins/issues/IssueManagementSystem.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.issues;
import java.util.Map;
@@ -32,8 +31,7 @@
*
* @version $Id$
*/
-public interface IssueManagementSystem
-{
+public interface IssueManagementSystem {
/**
* Get a mapping of issue types used in this issue management system to the ones used in a changes.xml file.
@@ -56,7 +54,5 @@ public interface IssueManagementSystem
* changes.xml file
* @throws MojoExecutionException If the configuration fails
*/
- void applyConfiguration( Map issueTypes )
- throws MojoExecutionException;
-
-}
\ No newline at end of file
+ void applyConfiguration(Map issueTypes) throws MojoExecutionException;
+}
diff --git a/src/main/java/org/apache/maven/plugins/issues/IssueUtils.java b/src/main/java/org/apache/maven/plugins/issues/IssueUtils.java
index 23a7a5b6..4c103664 100644
--- a/src/main/java/org/apache/maven/plugins/issues/IssueUtils.java
+++ b/src/main/java/org/apache/maven/plugins/issues/IssueUtils.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -18,12 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.plugin.MojoExecutionException;
+package org.apache.maven.plugins.issues;
import java.util.ArrayList;
import java.util.List;
+import org.apache.maven.plugin.MojoExecutionException;
+
/**
* A utility class for working with issue objects.
*
@@ -31,8 +30,7 @@
* @version $Id$
* @since 2.4
*/
-public class IssueUtils
-{
+public class IssueUtils {
public static final String SNAPSHOT_SUFFIX = "-SNAPSHOT";
/**
@@ -43,35 +41,29 @@ public class IssueUtils
* @return A List
of issues fixed in versions that match the supplied prefix
* @throws org.apache.maven.plugin.MojoExecutionException If no issues could be found for the supplied prefix
*/
- public static List filterIssuesWithVersionPrefix( List issues, String prefix )
- throws MojoExecutionException
- {
+ public static List filterIssuesWithVersionPrefix(List issues, String prefix)
+ throws MojoExecutionException {
List filteredIssues = new ArrayList<>();
boolean isFound = false;
Issue issue;
- for ( Issue issue1 : issues )
- {
+ for (Issue issue1 : issues) {
issue = issue1;
- if ( issue.getFixVersions() != null )
- {
- for ( String fixVersion : issue.getFixVersions() )
- {
- if ( prefix == null || fixVersion.startsWith( prefix ) )
- {
+ if (issue.getFixVersions() != null) {
+ for (String fixVersion : issue.getFixVersions()) {
+ if (prefix == null || fixVersion.startsWith(prefix)) {
isFound = true;
- filteredIssues.add( issue );
+ filteredIssues.add(issue);
break;
}
}
}
}
- if ( !isFound )
- {
- throw new MojoExecutionException( "Couldn't find any issues with a Fix Version prefix of '" + prefix
- + "' among the supplied issues: " + toString( issues ) );
+ if (!isFound) {
+ throw new MojoExecutionException("Couldn't find any issues with a Fix Version prefix of '" + prefix
+ + "' among the supplied issues: " + toString(issues));
}
return filteredIssues;
}
@@ -86,45 +78,37 @@ public static List filterIssuesWithVersionPrefix( List issues, Str
* @return A List
of issues for the supplied version
* @throws org.apache.maven.plugin.MojoExecutionException If no issues could be found for the supplied version
*/
- public static List getIssuesForVersion( List issues, String version )
- throws MojoExecutionException
- {
+ public static List getIssuesForVersion(List issues, String version) throws MojoExecutionException {
List issuesForVersion = new ArrayList<>();
boolean isFound = false;
Issue issue;
String releaseVersion = version;
// Remove "-SNAPSHOT" from the end of the version, if it's there
- if ( version != null && version.endsWith( SNAPSHOT_SUFFIX ) )
- {
- releaseVersion = version.substring( 0, version.length() - SNAPSHOT_SUFFIX.length() );
+ if (version != null && version.endsWith(SNAPSHOT_SUFFIX)) {
+ releaseVersion = version.substring(0, version.length() - SNAPSHOT_SUFFIX.length());
}
- for ( Issue issue1 : issues )
- {
+ for (Issue issue1 : issues) {
issue = issue1;
- if ( issue.getFixVersions() != null && issue.getFixVersions().contains( releaseVersion ) )
- {
+ if (issue.getFixVersions() != null && issue.getFixVersions().contains(releaseVersion)) {
isFound = true;
- issuesForVersion.add( issue );
+ issuesForVersion.add(issue);
}
}
- if ( !isFound )
- {
- throw new MojoExecutionException( "Couldn't find any issues for the version '" + releaseVersion
- + "' among the supplied issues: " + toString( issues ) );
+ if (!isFound) {
+ throw new MojoExecutionException("Couldn't find any issues for the version '" + releaseVersion
+ + "' among the supplied issues: " + toString(issues));
}
return issuesForVersion;
}
- public static String toString( List issues )
- {
- List issueStrings = new ArrayList<>( issues.size() );
- for ( Issue issue : issues )
- {
- issueStrings.add( issue.toString() );
+ public static String toString(List issues) {
+ List issueStrings = new ArrayList<>(issues.size());
+ for (Issue issue : issues) {
+ issueStrings.add(issue.toString());
}
return issueStrings.toString();
}
diff --git a/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java b/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java
index 579cead5..ed1ea320 100644
--- a/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,14 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.doxia.sink.Sink;
+package org.apache.maven.plugins.issues;
import java.text.DateFormat;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
+import org.apache.maven.doxia.sink.Sink;
+
/**
* Generates a report on issues.
*
@@ -34,9 +33,7 @@
* @version $Id$
* @since 2.4
*/
-public class IssuesReportGenerator
- extends AbstractIssuesReportGenerator
-{
+public class IssuesReportGenerator extends AbstractIssuesReportGenerator {
/**
* Fallback value that is used if date field are not available.
*/
@@ -50,42 +47,37 @@ public class IssuesReportGenerator
/**
* @param includedColumns The id:s of the columns to include in the report
*/
- public IssuesReportGenerator( int[] includedColumns )
- {
+ public IssuesReportGenerator(int[] includedColumns) {
this.columns = includedColumns;
}
- public void doGenerateEmptyReport( ResourceBundle bundle, Sink sink )
- {
- sinkBeginReport( sink, bundle );
+ public void doGenerateEmptyReport(ResourceBundle bundle, Sink sink) {
+ sinkBeginReport(sink, bundle);
sink.paragraph();
- sink.text( bundle.getString( "report.issues.error" ) );
+ sink.text(bundle.getString("report.issues.error"));
sink.paragraph_();
- sinkEndReport( sink );
+ sinkEndReport(sink);
}
- public void doGenerateReport( ResourceBundle bundle, Sink sink, List issueList )
- {
- sinkBeginReport( sink, bundle );
+ public void doGenerateReport(ResourceBundle bundle, Sink sink, List issueList) {
+ sinkBeginReport(sink, bundle);
- constructHeaderRow( sink, issueList, bundle );
+ constructHeaderRow(sink, issueList, bundle);
// Always use the international date format as recommended by the W3C:
// http://www.w3.org/QA/Tips/iso-date
// This date format is used in the Swedish locale.
- constructDetailRows( sink, issueList, bundle, new Locale( "sv" ) );
+ constructDetailRows(sink, issueList, bundle, new Locale("sv"));
- sinkEndReport( sink );
+ sinkEndReport(sink);
}
- private void constructHeaderRow( Sink sink, List issueList, ResourceBundle bundle )
- {
- if ( issueList == null )
- {
+ private void constructHeaderRow(Sink sink, List issueList, ResourceBundle bundle) {
+ if (issueList == null) {
return;
}
@@ -93,64 +85,62 @@ private void constructHeaderRow( Sink sink, List issueList, ResourceBundl
sink.tableRow();
- for ( int column : columns )
- {
- switch ( column )
- {
+ for (int column : columns) {
+ switch (column) {
case IssuesReportHelper.COLUMN_ASSIGNEE:
- sinkHeader( sink, bundle.getString( "report.issues.label.assignee" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.assignee"));
break;
case IssuesReportHelper.COLUMN_COMPONENT:
- sinkHeader( sink, bundle.getString( "report.issues.label.component" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.component"));
break;
case IssuesReportHelper.COLUMN_CREATED:
- sinkHeader( sink, bundle.getString( "report.issues.label.created" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.created"));
break;
case IssuesReportHelper.COLUMN_FIX_VERSION:
- sinkHeader( sink, bundle.getString( "report.issues.label.fixVersion" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.fixVersion"));
break;
case IssuesReportHelper.COLUMN_ID:
- sinkHeader( sink, bundle.getString( "report.issues.label.id" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.id"));
break;
case IssuesReportHelper.COLUMN_KEY:
- sinkHeader( sink, bundle.getString( "report.issues.label.key" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.key"));
break;
case IssuesReportHelper.COLUMN_PRIORITY:
- sinkHeader( sink, bundle.getString( "report.issues.label.priority" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.priority"));
break;
case IssuesReportHelper.COLUMN_REPORTER:
- sinkHeader( sink, bundle.getString( "report.issues.label.reporter" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.reporter"));
break;
case IssuesReportHelper.COLUMN_RESOLUTION:
- sinkHeader( sink, bundle.getString( "report.issues.label.resolution" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.resolution"));
break;
case IssuesReportHelper.COLUMN_STATUS:
- sinkHeader( sink, bundle.getString( "report.issues.label.status" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.status"));
break;
case IssuesReportHelper.COLUMN_SUMMARY:
- sinkHeader( sink, bundle.getString( "report.issues.label.summary" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.summary"));
break;
case IssuesReportHelper.COLUMN_TYPE:
- sinkHeader( sink, bundle.getString( "report.issues.label.type" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.type"));
break;
case IssuesReportHelper.COLUMN_UPDATED:
- sinkHeader( sink, bundle.getString( "report.issues.label.updated" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.updated"));
break;
case IssuesReportHelper.COLUMN_VERSION:
- sinkHeader( sink, bundle.getString( "report.issues.label.version" ) );
+ sinkHeader(sink, bundle.getString("report.issues.label.version"));
break;
default:
@@ -162,96 +152,89 @@ private void constructHeaderRow( Sink sink, List issueList, ResourceBundl
sink.tableRow_();
}
- private void constructDetailRows( Sink sink, List issueList, ResourceBundle bundle, Locale locale )
- {
- if ( issueList == null )
- {
+ private void constructDetailRows(Sink sink, List issueList, ResourceBundle bundle, Locale locale) {
+ if (issueList == null) {
return;
}
- for ( Issue issue : issueList )
- {
+ for (Issue issue : issueList) {
// Use a DateFormat based on the Locale
- DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT, locale );
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
sink.tableRow();
- for ( int column : columns )
- {
- switch ( column )
- {
+ for (int column : columns) {
+ switch (column) {
case IssuesReportHelper.COLUMN_ASSIGNEE:
- sinkCell( sink, issue.getAssignee() );
+ sinkCell(sink, issue.getAssignee());
break;
case IssuesReportHelper.COLUMN_COMPONENT:
- sinkCell( sink, IssuesReportHelper.printValues( issue.getComponents() ) );
+ sinkCell(sink, IssuesReportHelper.printValues(issue.getComponents()));
break;
case IssuesReportHelper.COLUMN_CREATED:
String created = NOT_AVAILABLE;
- if ( issue.getCreated() != null )
- {
- created = df.format( issue.getCreated() );
+ if (issue.getCreated() != null) {
+ created = df.format(issue.getCreated());
}
- sinkCell( sink, created );
+ sinkCell(sink, created);
break;
case IssuesReportHelper.COLUMN_FIX_VERSION:
- sinkCell( sink, IssuesReportHelper.printValues( issue.getFixVersions() ) );
+ sinkCell(sink, IssuesReportHelper.printValues(issue.getFixVersions()));
break;
case IssuesReportHelper.COLUMN_ID:
sink.tableCell();
- sink.link( issue.getLink() );
- sink.text( issue.getId() );
+ sink.link(issue.getLink());
+ sink.text(issue.getId());
sink.link_();
sink.tableCell_();
break;
case IssuesReportHelper.COLUMN_KEY:
sink.tableCell();
- sink.link( issue.getLink() );
- sink.text( issue.getKey() );
+ sink.link(issue.getLink());
+ sink.text(issue.getKey());
sink.link_();
sink.tableCell_();
break;
case IssuesReportHelper.COLUMN_PRIORITY:
- sinkCell( sink, issue.getPriority() );
+ sinkCell(sink, issue.getPriority());
break;
case IssuesReportHelper.COLUMN_REPORTER:
- sinkCell( sink, issue.getReporter() );
+ sinkCell(sink, issue.getReporter());
break;
case IssuesReportHelper.COLUMN_RESOLUTION:
- sinkCell( sink, issue.getResolution() );
+ sinkCell(sink, issue.getResolution());
break;
case IssuesReportHelper.COLUMN_STATUS:
- sinkCell( sink, issue.getStatus() );
+ sinkCell(sink, issue.getStatus());
break;
case IssuesReportHelper.COLUMN_SUMMARY:
- sinkCell( sink, issue.getSummary() );
+ sinkCell(sink, issue.getSummary());
break;
case IssuesReportHelper.COLUMN_TYPE:
- sinkCell( sink, issue.getType() );
+ sinkCell(sink, issue.getType());
break;
case IssuesReportHelper.COLUMN_UPDATED:
String updated = NOT_AVAILABLE;
- if ( issue.getUpdated() != null )
- {
- updated = df.format( issue.getUpdated() );
+ if (issue.getUpdated() != null) {
+ updated = df.format(issue.getUpdated());
}
- sinkCell( sink, updated );
+ sinkCell(sink, updated);
break;
case IssuesReportHelper.COLUMN_VERSION:
- sinkCell( sink, issue.getVersion() );
+ sinkCell(sink, issue.getVersion());
break;
default:
diff --git a/src/main/java/org/apache/maven/plugins/issues/IssuesReportHelper.java b/src/main/java/org/apache/maven/plugins/issues/IssuesReportHelper.java
index 9ca1d2ac..904448d0 100644
--- a/src/main/java/org/apache/maven/plugins/issues/IssuesReportHelper.java
+++ b/src/main/java/org/apache/maven/plugins/issues/IssuesReportHelper.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.issues;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,15 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.commons.collections.bidimap.DualHashBidiMap;
-import org.apache.maven.plugin.logging.Log;
+package org.apache.maven.plugins.issues;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.apache.commons.collections.bidimap.DualHashBidiMap;
+import org.apache.maven.plugin.logging.Log;
+
/**
* A helper class for generation of reports based on issues.
*
@@ -34,8 +33,7 @@
* @version $Id$
* @since 2.4
*/
-public class IssuesReportHelper
-{
+public class IssuesReportHelper {
public static final int COLUMN_ASSIGNEE = 0;
public static final int COLUMN_COMPONENT = 1;
@@ -71,9 +69,8 @@ public class IssuesReportHelper
* @param allColumns A mapping from column name to column id
* @return A List of column id:s
*/
- public static List getColumnIds( String columnNames, Map allColumns )
- {
- return getColumnIds( columnNames, allColumns, null, null );
+ public static List getColumnIds(String columnNames, Map allColumns) {
+ return getColumnIds(columnNames, allColumns, null, null);
}
/**
@@ -87,34 +84,27 @@ public static List getColumnIds( String columnNames, Map getColumnIds( String columnNames, Map allColumns,
- Map deprecatedColumns, Log log )
- {
+ public static List getColumnIds(
+ String columnNames, Map allColumns, Map deprecatedColumns, Log log) {
DualHashBidiMap bidiColumns = null;
List columnIds = new ArrayList<>();
- String[] columnNamesArray = columnNames.split( "," );
+ String[] columnNamesArray = columnNames.split(",");
- if ( deprecatedColumns != null )
- {
- bidiColumns = new DualHashBidiMap( allColumns );
+ if (deprecatedColumns != null) {
+ bidiColumns = new DualHashBidiMap(allColumns);
}
// Loop through the names of the columns, to validate each of them and add their id to the list
- for ( String aColumnNamesArray : columnNamesArray )
- {
+ for (String aColumnNamesArray : columnNamesArray) {
String columnName = aColumnNamesArray.trim();
- if ( allColumns.containsKey( columnName ) )
- {
- columnIds.add( allColumns.get( columnName ) );
- }
- else if ( deprecatedColumns != null && deprecatedColumns.containsKey( columnName ) )
- {
- Integer columnId = deprecatedColumns.get( columnName );
- columnIds.add( columnId );
- if ( log != null )
- {
- log.warn( "The columnName '" + columnName + "' has been deprecated." + " Please use "
- + "the columnName '" + bidiColumns.getKey( columnId ) + "' instead." );
+ if (allColumns.containsKey(columnName)) {
+ columnIds.add(allColumns.get(columnName));
+ } else if (deprecatedColumns != null && deprecatedColumns.containsKey(columnName)) {
+ Integer columnId = deprecatedColumns.get(columnName);
+ columnIds.add(columnId);
+ if (log != null) {
+ log.warn("The columnName '" + columnName + "' has been deprecated." + " Please use "
+ + "the columnName '" + bidiColumns.getKey(columnId) + "' instead.");
}
}
}
@@ -127,19 +117,15 @@ else if ( deprecatedColumns != null && deprecatedColumns.containsKey( columnName
* @param values The values to print
* @return A nicely formatted string of values.
*/
- public static String printValues( List values )
- {
+ public static String printValues(List values) {
StringBuilder sb = new StringBuilder();
- if ( values != null )
- {
+ if (values != null) {
Iterator iterator = values.iterator();
- while ( iterator.hasNext() )
- {
+ while (iterator.hasNext()) {
String value = iterator.next();
- sb.append( value );
- if ( iterator.hasNext() )
- {
- sb.append( ", " );
+ sb.append(value);
+ if (iterator.hasNext()) {
+ sb.append(", ");
}
}
}
@@ -152,12 +138,10 @@ public static String printValues( List values )
* @param list The List to convert
* @return An in array
*/
- public static int[] toIntArray( List list )
- {
+ public static int[] toIntArray(List list) {
int[] intArray = new int[list.size()];
- for ( int j = 0; j < intArray.length; j++ )
- {
- intArray[j] = list.get( j );
+ for (int j = 0; j < intArray.length; j++) {
+ intArray[j] = list.get(j);
}
return intArray;
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java b/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java
index 00250519..020b0c18 100644
--- a/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java
+++ b/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jira;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
@@ -29,11 +33,6 @@
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.proxy.ProxyUtils;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-
/**
* Abstract API, more or less, to retrieving issue information from JIRA. Intended to have subclasses for the old (RSS)
* and new (REST) ways of doing things.
@@ -42,8 +41,7 @@
* @author jruiz@exist.com
* @version $Id$
*/
-public abstract class AbstractJiraDownloader
-{
+public abstract class AbstractJiraDownloader {
protected static final String UTF_8 = "UTF-8";
/** Log for debug output. */
@@ -129,60 +127,49 @@ public abstract class AbstractJiraDownloader
*
* @throws Exception on error
*/
- public abstract void doExecute()
- throws Exception;
+ public abstract void doExecute() throws Exception;
/**
* Check to see if we think that JIRA authentication is needed.
*
* @return true
if jiraUser and jiraPassword are set, otherwise false
*/
- protected boolean isJiraAuthenticationConfigured()
- {
- return ( jiraUser != null ) && ( jiraUser.length() > 0 ) && ( jiraPassword != null );
+ protected boolean isJiraAuthenticationConfigured() {
+ return (jiraUser != null) && (jiraUser.length() > 0) && (jiraPassword != null);
}
- protected void getProxyInfo( String jiraUrl )
- {
+ protected void getProxyInfo(String jiraUrl) {
// see whether there is any proxy defined in maven
Proxy proxy = null;
- if ( project == null )
- {
- getLog().error( "No project set. No proxy info available." );
+ if (project == null) {
+ getLog().error("No project set. No proxy info available.");
return;
}
- if ( settings != null )
- {
+ if (settings != null) {
proxy = settings.getActiveProxy();
}
- if ( proxy != null )
- {
+ if (proxy != null) {
ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() );
+ proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
// Get the host out of the JIRA URL
URL url = null;
- try
- {
- url = new URL( jiraUrl );
- }
- catch ( MalformedURLException e )
- {
- getLog().error( "Invalid JIRA URL: " + jiraUrl + ". " + e.getMessage() );
+ try {
+ url = new URL(jiraUrl);
+ } catch (MalformedURLException e) {
+ getLog().error("Invalid JIRA URL: " + jiraUrl + ". " + e.getMessage());
}
String jiraHost = null;
- if ( url != null )
- {
+ if (url != null) {
jiraHost = url.getHost();
}
- if ( ProxyUtils.validateNonProxyHosts( proxyInfo, jiraHost ) )
- {
+ if (ProxyUtils.validateNonProxyHosts(proxyInfo, jiraHost)) {
return;
}
@@ -198,36 +185,27 @@ protected void getProxyInfo( String jiraUrl )
*
* @return A Fix For id or null
if you don't have that need
*/
- protected String getFixFor()
- {
- if ( onlyCurrentVersion && useJql )
- {
+ protected String getFixFor() {
+ if (onlyCurrentVersion && useJql) {
// Let JIRA do the filtering of the current version instead of the JIRA mojo.
// This way JIRA returns less issues and we do not run into the "nbEntriesMax" limit that easily.
- String version = ( versionPrefix == null ? "" : versionPrefix ) + project.getVersion();
+ String version = (versionPrefix == null ? "" : versionPrefix) + project.getVersion();
// Remove "-SNAPSHOT" from the end of the version, if it's there
- if ( version.endsWith( IssueUtils.SNAPSHOT_SUFFIX ) )
- {
- return version.substring( 0, version.length() - IssueUtils.SNAPSHOT_SUFFIX.length() );
- }
- else
- {
+ if (version.endsWith(IssueUtils.SNAPSHOT_SUFFIX)) {
+ return version.substring(0, version.length() - IssueUtils.SNAPSHOT_SUFFIX.length());
+ } else {
return version;
}
- }
- else
- {
+ } else {
return null;
}
}
- public abstract List getIssueList()
- throws MojoExecutionException;
+ public abstract List getIssueList() throws MojoExecutionException;
- public void setJiraDatePattern( String jiraDatePattern )
- {
+ public void setJiraDatePattern(String jiraDatePattern) {
this.jiraDatePattern = jiraDatePattern;
}
@@ -236,13 +214,11 @@ public void setJiraDatePattern( String jiraDatePattern )
*
* @param thisOutput the output file
*/
- public void setOutput( File thisOutput )
- {
+ public void setOutput(File thisOutput) {
this.output = thisOutput;
}
- public File getOutput()
- {
+ public File getOutput() {
return this.output;
}
@@ -251,8 +227,7 @@ public File getOutput()
*
* @param thisProject The project to set
*/
- public void setMavenProject( Object thisProject )
- {
+ public void setMavenProject(Object thisProject) {
this.project = (MavenProject) thisProject;
}
@@ -261,8 +236,7 @@ public void setMavenProject( Object thisProject )
*
* @param nbEntries The maximum number of Issues
*/
- public void setNbEntries( final int nbEntries )
- {
+ public void setNbEntries(final int nbEntries) {
nbEntriesMax = nbEntries;
}
@@ -271,8 +245,7 @@ public void setNbEntries( final int nbEntries )
*
* @param thisStatusIds The id(s) of the status to show, as comma separated string
*/
- public void setStatusIds( String thisStatusIds )
- {
+ public void setStatusIds(String thisStatusIds) {
statusIds = thisStatusIds;
}
@@ -281,8 +254,7 @@ public void setStatusIds( String thisStatusIds )
*
* @param thisPriorityIds The id(s) of the priority to show, as comma separated string
*/
- public void setPriorityIds( String thisPriorityIds )
- {
+ public void setPriorityIds(String thisPriorityIds) {
priorityIds = thisPriorityIds;
}
@@ -291,8 +263,7 @@ public void setPriorityIds( String thisPriorityIds )
*
* @param thisResolutionIds The id(s) of the resolution to show, as comma separated string
*/
- public void setResolutionIds( String thisResolutionIds )
- {
+ public void setResolutionIds(String thisResolutionIds) {
resolutionIds = thisResolutionIds;
}
@@ -301,8 +272,7 @@ public void setResolutionIds( String thisResolutionIds )
*
* @param thisSortColumnNames The column names to sort by
*/
- public void setSortColumnNames( String thisSortColumnNames )
- {
+ public void setSortColumnNames(String thisSortColumnNames) {
sortColumnNames = thisSortColumnNames;
}
@@ -311,8 +281,7 @@ public void setSortColumnNames( String thisSortColumnNames )
*
* @param thisWebPassword The password of the webserver
*/
- public void setWebPassword( String thisWebPassword )
- {
+ public void setWebPassword(String thisWebPassword) {
this.webPassword = thisWebPassword;
}
@@ -321,8 +290,7 @@ public void setWebPassword( String thisWebPassword )
*
* @param thisWebUser The username of the webserver
*/
- public void setWebUser( String thisWebUser )
- {
+ public void setWebUser(String thisWebUser) {
this.webUser = thisWebUser;
}
@@ -331,8 +299,7 @@ public void setWebUser( String thisWebUser )
*
* @param thisJiraPassword The password for JIRA
*/
- public void setJiraPassword( final String thisJiraPassword )
- {
+ public void setJiraPassword(final String thisJiraPassword) {
this.jiraPassword = thisJiraPassword;
}
@@ -341,8 +308,7 @@ public void setJiraPassword( final String thisJiraPassword )
*
* @param thisJiraUser The username for JIRA
*/
- public void setJiraUser( String thisJiraUser )
- {
+ public void setJiraUser(String thisJiraUser) {
this.jiraUser = thisJiraUser;
}
@@ -351,8 +317,7 @@ public void setJiraUser( String thisJiraUser )
*
* @param thisFilter The filter to query JIRA
*/
- public void setFilter( String thisFilter )
- {
+ public void setFilter(String thisFilter) {
this.filter = thisFilter;
}
@@ -361,8 +326,7 @@ public void setFilter( String thisFilter )
*
* @param theseComponents The id(s) of components to show, as comma separated string
*/
- public void setComponent( String theseComponents )
- {
+ public void setComponent(String theseComponents) {
this.component = theseComponents;
}
@@ -371,8 +335,7 @@ public void setComponent( String theseComponents )
*
* @param theseFixVersionIds The id(s) of fix versions to show, as comma separated string
*/
- public void setFixVersionIds( String theseFixVersionIds )
- {
+ public void setFixVersionIds(String theseFixVersionIds) {
this.fixVersionIds = theseFixVersionIds;
}
@@ -381,63 +344,51 @@ public void setFixVersionIds( String theseFixVersionIds )
*
* @param theseTypeIds The id(s) of the types to show, as comma separated string
*/
- public void setTypeIds( String theseTypeIds )
- {
+ public void setTypeIds(String theseTypeIds) {
typeIds = theseTypeIds;
}
- public void setLog( Log log )
- {
+ public void setLog(Log log) {
this.log = log;
}
- protected Log getLog()
- {
+ protected Log getLog() {
return log;
}
- public void setSettings( Settings settings )
- {
+ public void setSettings(Settings settings) {
this.settings = settings;
}
- public boolean isUseJql()
- {
+ public boolean isUseJql() {
return useJql;
}
- public void setUseJql( boolean useJql )
- {
+ public void setUseJql(boolean useJql) {
this.useJql = useJql;
}
- public boolean isOnlyCurrentVersion()
- {
+ public boolean isOnlyCurrentVersion() {
return onlyCurrentVersion;
}
- public void setOnlyCurrentVersion( boolean onlyCurrentVersion )
- {
+ public void setOnlyCurrentVersion(boolean onlyCurrentVersion) {
this.onlyCurrentVersion = onlyCurrentVersion;
}
- public String getVersionPrefix()
- {
+ public String getVersionPrefix() {
return versionPrefix;
}
- public void setVersionPrefix( String versionPrefix )
- {
+ public void setVersionPrefix(String versionPrefix) {
this.versionPrefix = versionPrefix;
}
- public void setConnectionTimeout( int connectionTimeout )
- {
+ public void setConnectionTimeout(int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
- public void setReceiveTimout( int receiveTimout )
- {
+ public void setReceiveTimout(int receiveTimout) {
this.receiveTimout = receiveTimout;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/AdaptiveJiraDownloader.java b/src/main/java/org/apache/maven/plugins/jira/AdaptiveJiraDownloader.java
index 64b099d3..19ad02f8 100644
--- a/src/main/java/org/apache/maven/plugins/jira/AdaptiveJiraDownloader.java
+++ b/src/main/java/org/apache/maven/plugins/jira/AdaptiveJiraDownloader.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,81 +16,70 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jira;
+
+import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.issues.Issue;
-import java.util.List;
-
/**
* Jira downloader that uses REST or RSS, depending. This code is not very attractive. However, JIRA has supported REST
* for a very long time, and so the fallback is only relevant for people with very old copies of JIRA.
*/
-public class AdaptiveJiraDownloader
- extends AbstractJiraDownloader
-{
+public class AdaptiveJiraDownloader extends AbstractJiraDownloader {
private AbstractJiraDownloader effectiveDownloader;
private boolean forceClassic;
- public void doExecute()
- throws Exception
- {
+ public void doExecute() throws Exception {
effectiveDownloader = new RestJiraDownloader();
- copySettings( effectiveDownloader );
- try
- {
+ copySettings(effectiveDownloader);
+ try {
effectiveDownloader.doExecute();
- }
- catch ( RestJiraDownloader.NoRest nre )
- {
- getLog().info( "Falling back to RSS for issue download: " + nre.getMessage() );
+ } catch (RestJiraDownloader.NoRest nre) {
+ getLog().info("Falling back to RSS for issue download: " + nre.getMessage());
effectiveDownloader = new ClassicJiraDownloader();
- copySettings( effectiveDownloader );
+ copySettings(effectiveDownloader);
effectiveDownloader.doExecute();
}
}
- private void copySettings( AbstractJiraDownloader target )
- {
- target.setLog( getLog() );
- target.setMavenProject( project );
- target.setOutput( output );
- target.setNbEntries( nbEntriesMax );
- target.setComponent( component );
- target.setFixVersionIds( fixVersionIds );
- target.setStatusIds( statusIds );
- target.setResolutionIds( resolutionIds );
- target.setPriorityIds( priorityIds );
- target.setSortColumnNames( sortColumnNames );
- target.setFilter( filter );
- target.setJiraDatePattern( jiraDatePattern );
- target.setJiraUser( jiraUser );
- target.setJiraPassword( jiraPassword );
- target.setTypeIds( typeIds );
- target.setWebUser( webUser );
- target.setWebPassword( webPassword );
- target.setSettings( settings );
- target.setUseJql( useJql );
- target.setOnlyCurrentVersion( onlyCurrentVersion );
- target.setVersionPrefix( versionPrefix );
- target.setConnectionTimeout( connectionTimeout );
- target.setReceiveTimout( receiveTimout );
+ private void copySettings(AbstractJiraDownloader target) {
+ target.setLog(getLog());
+ target.setMavenProject(project);
+ target.setOutput(output);
+ target.setNbEntries(nbEntriesMax);
+ target.setComponent(component);
+ target.setFixVersionIds(fixVersionIds);
+ target.setStatusIds(statusIds);
+ target.setResolutionIds(resolutionIds);
+ target.setPriorityIds(priorityIds);
+ target.setSortColumnNames(sortColumnNames);
+ target.setFilter(filter);
+ target.setJiraDatePattern(jiraDatePattern);
+ target.setJiraUser(jiraUser);
+ target.setJiraPassword(jiraPassword);
+ target.setTypeIds(typeIds);
+ target.setWebUser(webUser);
+ target.setWebPassword(webPassword);
+ target.setSettings(settings);
+ target.setUseJql(useJql);
+ target.setOnlyCurrentVersion(onlyCurrentVersion);
+ target.setVersionPrefix(versionPrefix);
+ target.setConnectionTimeout(connectionTimeout);
+ target.setReceiveTimout(receiveTimout);
}
- public List getIssueList()
- throws MojoExecutionException
- {
+ public List getIssueList() throws MojoExecutionException {
return effectiveDownloader.getIssueList();
}
- public boolean isForceClassic()
- {
+ public boolean isForceClassic() {
return forceClassic;
}
- public void setForceClassic( boolean forceClassic )
- {
+ public void setForceClassic(boolean forceClassic) {
this.forceClassic = forceClassic;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/ClassicJiraDownloader.java b/src/main/java/org/apache/maven/plugins/jira/ClassicJiraDownloader.java
index ee0e33cc..a291ae3e 100644
--- a/src/main/java/org/apache/maven/plugins/jira/ClassicJiraDownloader.java
+++ b/src/main/java/org/apache/maven/plugins/jira/ClassicJiraDownloader.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jira;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
@@ -37,15 +45,6 @@
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URLEncoder;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
/**
* Gets relevant issues for a JIRA report via HTTP/RSS.
*
@@ -53,153 +52,140 @@
* @author jruiz@exist.com
* @version $Id$
*/
-public final class ClassicJiraDownloader
- extends AbstractJiraDownloader
-{
- public ClassicJiraDownloader()
- {
- }
+public final class ClassicJiraDownloader extends AbstractJiraDownloader {
+ public ClassicJiraDownloader() {}
/**
* Execute the query on the JIRA server.
*
*/
- public void doExecute()
- {
- try
- {
+ public void doExecute() {
+ try {
HttpClient client = new HttpClient();
// MCHANGES-89 Allow circular redirects
HttpClientParams clientParams = client.getParams();
- clientParams.setBooleanParameter( HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true );
- clientParams.setCookiePolicy( CookiePolicy.BROWSER_COMPATIBILITY ); // MCHANGES-237
+ clientParams.setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
+ clientParams.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); // MCHANGES-237
HttpState state = new HttpState();
HostConfiguration hc = new HostConfiguration();
- client.setHostConfiguration( hc );
+ client.setHostConfiguration(hc);
- client.setState( state );
+ client.setState(state);
- String baseUrl = JiraHelper.getBaseUrl( project.getIssueManagement().getUrl() );
+ String baseUrl = JiraHelper.getBaseUrl(project.getIssueManagement().getUrl());
- getLog().debug( "JIRA lives at: " + baseUrl );
+ getLog().debug("JIRA lives at: " + baseUrl);
// Here we only need the host part of the URL
- determineProxy( baseUrl, client );
+ determineProxy(baseUrl, client);
- prepareBasicAuthentication( client );
+ prepareBasicAuthentication(client);
boolean jiraAuthenticationSuccessful = false;
- if ( isJiraAuthenticationConfigured() )
- {
+ if (isJiraAuthenticationConfigured()) {
// Here we only need the parts up to and including the host part of the URL
- jiraAuthenticationSuccessful = doJiraAuthentication( client, baseUrl );
+ jiraAuthenticationSuccessful = doJiraAuthentication(client, baseUrl);
}
- if ( ( isJiraAuthenticationConfigured() && jiraAuthenticationSuccessful )
- || !isJiraAuthenticationConfigured() )
- {
+ if ((isJiraAuthenticationConfigured() && jiraAuthenticationSuccessful)
+ || !isJiraAuthenticationConfigured()) {
String fullUrl;
- if ( useJql )
- {
+ if (useJql) {
fullUrl = getJqlQueryURL();
+ } else {
+ fullUrl = getParameterBasedQueryURL(client);
}
- else
- {
- fullUrl = getParameterBasedQueryURL( client );
- }
- if ( log.isDebugEnabled() )
- {
- log.debug( "download jira issues from url " + fullUrl );
+ if (log.isDebugEnabled()) {
+ log.debug("download jira issues from url " + fullUrl);
}
// execute the GET
- download( client, fullUrl );
+ download(client, fullUrl);
}
- }
- catch ( Exception e )
- {
- if ( project.getIssueManagement() != null )
- {
- getLog().error( "Error accessing " + project.getIssueManagement().getUrl(), e );
- }
- else
- {
- getLog().error( "Error accessing mock project issues", e );
+ } catch (Exception e) {
+ if (project.getIssueManagement() != null) {
+ getLog().error("Error accessing " + project.getIssueManagement().getUrl(), e);
+ } else {
+ getLog().error("Error accessing mock project issues", e);
}
}
}
- private String getJqlQueryURL()
- {
+ private String getJqlQueryURL() {
// JQL is based on project names instead of project ID's
- Map urlMap = JiraHelper.getJiraUrlAndProjectName( project.getIssueManagement().getUrl() );
- String jiraUrl = urlMap.get( "url" );
- String jiraProject = urlMap.get( "project" );
-
- if ( jiraProject == null )
- {
- throw new RuntimeException( "The issue management URL in the POM does not include a JIRA project name" );
- }
- else
- {
+ Map urlMap =
+ JiraHelper.getJiraUrlAndProjectName(project.getIssueManagement().getUrl());
+ String jiraUrl = urlMap.get("url");
+ String jiraProject = urlMap.get("project");
+
+ if (jiraProject == null) {
+ throw new RuntimeException("The issue management URL in the POM does not include a JIRA project name");
+ } else {
// create the URL for getting the proper issues from JIRA
- String jqlQuery = new JqlQueryBuilder( log ).project( jiraProject ).fixVersion( getFixFor() )
- .fixVersionIds( fixVersionIds ).statusIds( statusIds ).priorityIds( priorityIds )
- .resolutionIds( resolutionIds ).components( component ).typeIds( typeIds )
- .sortColumnNames( sortColumnNames )
- .build();
-
- return new UrlBuilder( jiraUrl, "sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml" )
- .addParameter( "tempMax", nbEntriesMax ).addParameter( "reset", "true" )
- .addParameter( "jqlQuery", jqlQuery )
- .build();
+ String jqlQuery = new JqlQueryBuilder(log)
+ .project(jiraProject)
+ .fixVersion(getFixFor())
+ .fixVersionIds(fixVersionIds)
+ .statusIds(statusIds)
+ .priorityIds(priorityIds)
+ .resolutionIds(resolutionIds)
+ .components(component)
+ .typeIds(typeIds)
+ .sortColumnNames(sortColumnNames)
+ .build();
+
+ return new UrlBuilder(jiraUrl, "sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml")
+ .addParameter("tempMax", nbEntriesMax)
+ .addParameter("reset", "true")
+ .addParameter("jqlQuery", jqlQuery)
+ .build();
}
}
- private String getParameterBasedQueryURL( HttpClient client )
- {
- Map urlMap = JiraHelper.getJiraUrlAndProjectId( project.getIssueManagement().getUrl() );
- String jiraUrl = urlMap.get( "url" );
- String jiraId = urlMap.get( "id" );
-
- if ( jiraId == null || jiraId.length() == 0 )
- {
- log.debug( "The JIRA URL " + project.getIssueManagement().getUrl()
- + " doesn't include a pid, trying to extract it from JIRA." );
- jiraId = JiraHelper.getPidFromJira( log, project.getIssueManagement().getUrl(), client );
- }
+ private String getParameterBasedQueryURL(HttpClient client) {
+ Map urlMap =
+ JiraHelper.getJiraUrlAndProjectId(project.getIssueManagement().getUrl());
+ String jiraUrl = urlMap.get("url");
+ String jiraId = urlMap.get("id");
- if ( jiraId == null )
- {
- throw new RuntimeException( "The issue management URL in the POM does not include a pid,"
- + " and it was not possible to extract it from the page at that URL." );
+ if (jiraId == null || jiraId.length() == 0) {
+ log.debug("The JIRA URL " + project.getIssueManagement().getUrl()
+ + " doesn't include a pid, trying to extract it from JIRA.");
+ jiraId = JiraHelper.getPidFromJira(log, project.getIssueManagement().getUrl(), client);
}
- else
- {
+
+ if (jiraId == null) {
+ throw new RuntimeException("The issue management URL in the POM does not include a pid,"
+ + " and it was not possible to extract it from the page at that URL.");
+ } else {
// create the URL for getting the proper issues from JIRA
String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" + jiraId;
- if ( getFixFor() != null )
- {
+ if (getFixFor() != null) {
fullURL += "&fixfor=" + getFixFor();
}
- String createdFilter = new ParameterQueryBuilder( log ).fixVersionIds( fixVersionIds )
- .statusIds( statusIds ).priorityIds( priorityIds ).resolutionIds( resolutionIds )
- .components( component ).typeIds( typeIds ).sortColumnNames( sortColumnNames ).filter( filter )
+ String createdFilter = new ParameterQueryBuilder(log)
+ .fixVersionIds(fixVersionIds)
+ .statusIds(statusIds)
+ .priorityIds(priorityIds)
+ .resolutionIds(resolutionIds)
+ .components(component)
+ .typeIds(typeIds)
+ .sortColumnNames(sortColumnNames)
+ .filter(filter)
.build();
- if ( createdFilter.charAt( 0 ) != '&' )
- {
+ if (createdFilter.charAt(0) != '&') {
fullURL += "&";
}
fullURL += createdFilter;
- fullURL += ( "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none" );
+ fullURL += ("&tempMax=" + nbEntriesMax + "&reset=true&decorator=none");
return fullURL;
}
@@ -210,18 +196,16 @@ private String getParameterBasedQueryURL( HttpClient client )
*
* @param client The client to prepare
*/
- private void prepareBasicAuthentication( HttpClient client )
- {
- if ( ( webUser != null ) && ( webUser.length() > 0 ) )
- {
- client.getParams().setAuthenticationPreemptive( true );
+ private void prepareBasicAuthentication(HttpClient client) {
+ if ((webUser != null) && (webUser.length() > 0)) {
+ client.getParams().setAuthenticationPreemptive(true);
- Credentials defaultcreds = new UsernamePasswordCredentials( webUser, webPassword );
+ Credentials defaultcreds = new UsernamePasswordCredentials(webUser, webPassword);
- getLog().debug( "Using username: " + webUser + " for Basic Authentication." );
+ getLog().debug("Using username: " + webUser + " for Basic Authentication.");
- client.getState().setCredentials( new AuthScope( null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME ),
- defaultcreds );
+ client.getState()
+ .setCredentials(new AuthScope(null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME), defaultcreds);
}
}
@@ -233,54 +217,43 @@ private void prepareBasicAuthentication( HttpClient client )
* @param jiraUrl the JIRA installation
* @return true
if the authentication was successful, otherwise false
*/
- private boolean doJiraAuthentication( HttpClient client, final String jiraUrl )
- {
+ private boolean doJiraAuthentication(HttpClient client, final String jiraUrl) {
// log into JIRA if we have to
String loginUrl;
- StringBuilder loginLink = new StringBuilder( jiraUrl );
+ StringBuilder loginLink = new StringBuilder(jiraUrl);
- loginLink.append( "/login.jsp?os_destination=/secure/" );
+ loginLink.append("/login.jsp?os_destination=/secure/");
- try
- {
- loginLink.append( "&os_username=" ).append( URLEncoder.encode( jiraUser, UTF_8 ) );
+ try {
+ loginLink.append("&os_username=").append(URLEncoder.encode(jiraUser, UTF_8));
String password = null;
- if ( jiraPassword != null )
- {
- password = StringUtils.repeat( "*", jiraPassword.length() );
+ if (jiraPassword != null) {
+ password = StringUtils.repeat("*", jiraPassword.length());
}
- getLog().debug( "Login URL: " + loginLink + "&os_password=" + password );
+ getLog().debug("Login URL: " + loginLink + "&os_password=" + password);
- loginLink.append( "&os_password=" ).append( URLEncoder.encode( jiraPassword, UTF_8 ) );
+ loginLink.append("&os_password=").append(URLEncoder.encode(jiraPassword, UTF_8));
loginUrl = loginLink.toString();
// execute the login
- GetMethod loginGet = new GetMethod( loginUrl );
+ GetMethod loginGet = new GetMethod(loginUrl);
- client.executeMethod( loginGet );
+ client.executeMethod(loginGet);
- if ( loginSucceeded( loginGet ) )
- {
- getLog().debug( "Successfully logged in into JIRA." );
+ if (loginSucceeded(loginGet)) {
+ getLog().debug("Successfully logged in into JIRA.");
return true;
+ } else {
+ getLog().warn("Was unable to login into JIRA: wrong username and/or password.");
}
- else
- {
- getLog().warn( "Was unable to login into JIRA: wrong username and/or password." );
- }
- }
- catch ( Exception e )
- {
- if ( getLog().isDebugEnabled() )
- {
- getLog().error( "Error trying to login into JIRA.", e );
- }
- else
- {
- getLog().error( "Error trying to login into JIRA. Cause is: " + e.getLocalizedMessage() );
+ } catch (Exception e) {
+ if (getLog().isDebugEnabled()) {
+ getLog().error("Error trying to login into JIRA.", e);
+ } else {
+ getLog().error("Error trying to login into JIRA. Cause is: " + e.getLocalizedMessage());
}
}
return false;
@@ -294,12 +267,10 @@ private boolean doJiraAuthentication( HttpClient client, final String jiraUrl )
* @return false
if we find an error message in the response body, otherwise true
* @todo There must be a nicer way to know whether we were able to login or not
*/
- private boolean loginSucceeded( GetMethod loginGet )
- throws IOException
- {
+ private boolean loginSucceeded(GetMethod loginGet) throws IOException {
final String loginFailureResponse = "your username and password are incorrect";
- return !loginGet.getResponseBodyAsString().contains( loginFailureResponse );
+ return !loginGet.getResponseBodyAsString().contains(loginFailureResponse);
}
/**
@@ -307,25 +278,23 @@ private boolean loginSucceeded( GetMethod loginGet )
*
* @param client the HttpClient
*/
- private void determineProxy( String jiraUrl, HttpClient client )
- {
+ private void determineProxy(String jiraUrl, HttpClient client) {
// see whether there is any proxy defined in maven
- getProxyInfo( jiraUrl );
+ getProxyInfo(jiraUrl);
- if ( proxyHost != null )
- {
- client.getHostConfiguration().setProxy( proxyHost, proxyPort );
+ if (proxyHost != null) {
+ client.getHostConfiguration().setProxy(proxyHost, proxyPort);
- getLog().debug( "Using proxy: " + proxyHost + " at port " + proxyPort );
+ getLog().debug("Using proxy: " + proxyHost + " at port " + proxyPort);
- if ( proxyUser != null )
- {
- getLog().debug( "Using proxy user: " + proxyUser );
+ if (proxyUser != null) {
+ getLog().debug("Using proxy user: " + proxyUser);
- client.getState().setProxyCredentials( new AuthScope( null, AuthScope.ANY_PORT, null,
- AuthScope.ANY_SCHEME ),
- new UsernamePasswordCredentials( proxyUser, proxyPass ) );
+ client.getState()
+ .setProxyCredentials(
+ new AuthScope(null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME),
+ new UsernamePasswordCredentials(proxyUser, proxyPass));
}
}
}
@@ -336,117 +305,87 @@ private void determineProxy( String jiraUrl, HttpClient client )
* @param cl the HttpClient
* @param link the URL to JIRA
*/
- private void download( final HttpClient cl, final String link )
- {
+ private void download(final HttpClient cl, final String link) {
InputStream in = null;
OutputStream out = null;
- try
- {
- GetMethod gm = new GetMethod( link );
+ try {
+ GetMethod gm = new GetMethod(link);
- getLog().info( "Downloading from JIRA at: " + link );
+ getLog().info("Downloading from JIRA at: " + link);
- gm.setFollowRedirects( true );
+ gm.setFollowRedirects(true);
- cl.executeMethod( gm );
+ cl.executeMethod(gm);
StatusLine sl = gm.getStatusLine();
- if ( sl == null )
- {
- getLog().error( "Unknown error validating link: " + link );
+ if (sl == null) {
+ getLog().error("Unknown error validating link: " + link);
return;
}
// if we get a redirect, do so
- if ( gm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY )
- {
- Header locationHeader = gm.getResponseHeader( "Location" );
+ if (gm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
+ Header locationHeader = gm.getResponseHeader("Location");
- if ( locationHeader == null )
- {
- getLog().warn( "Site sent redirect, but did not set Location header" );
- }
- else
- {
+ if (locationHeader == null) {
+ getLog().warn("Site sent redirect, but did not set Location header");
+ } else {
String newLink = locationHeader.getValue();
- getLog().debug( "Following redirect to " + newLink );
+ getLog().debug("Following redirect to " + newLink);
- download( cl, newLink );
+ download(cl, newLink);
}
}
- if ( gm.getStatusCode() == HttpStatus.SC_OK )
- {
+ if (gm.getStatusCode() == HttpStatus.SC_OK) {
in = gm.getResponseBodyAsStream();
- if ( !output.getParentFile().exists() )
- {
+ if (!output.getParentFile().exists()) {
output.getParentFile().mkdirs();
}
// write the response to file
- out = new FileOutputStream( output );
- IOUtil.copy( in, out );
+ out = new FileOutputStream(output);
+ IOUtil.copy(in, out);
out.close();
out = null;
in.close();
in = null;
- getLog().debug( "Downloading from JIRA was successful" );
- }
- else
- {
- getLog().warn( "Downloading from JIRA failed. Received: [" + gm.getStatusCode() + "]" );
+ getLog().debug("Downloading from JIRA was successful");
+ } else {
+ getLog().warn("Downloading from JIRA failed. Received: [" + gm.getStatusCode() + "]");
}
- }
- catch ( HttpException e )
- {
- if ( getLog().isDebugEnabled() )
- {
- getLog().error( "Error downloading issues from JIRA:", e );
+ } catch (HttpException e) {
+ if (getLog().isDebugEnabled()) {
+ getLog().error("Error downloading issues from JIRA:", e);
+ } else {
+ getLog().error("Error downloading issues from JIRA url: " + e.getLocalizedMessage());
}
- else
- {
- getLog().error( "Error downloading issues from JIRA url: " + e.getLocalizedMessage() );
-
+ } catch (IOException e) {
+ if (getLog().isDebugEnabled()) {
+ getLog().error("Error downloading issues from JIRA:", e);
+ } else {
+ getLog().error("Error downloading issues from JIRA. Cause is " + e.getLocalizedMessage());
}
- }
- catch ( IOException e )
- {
- if ( getLog().isDebugEnabled() )
- {
- getLog().error( "Error downloading issues from JIRA:", e );
- }
- else
- {
- getLog().error( "Error downloading issues from JIRA. Cause is " + e.getLocalizedMessage() );
- }
- }
- finally
- {
- IOUtil.close( out );
- IOUtil.close( in );
+ } finally {
+ IOUtil.close(out);
+ IOUtil.close(in);
}
}
- public List getIssueList()
- throws MojoExecutionException
- {
- if ( output.isFile() )
- {
- JiraXML jira = new JiraXML( log, jiraDatePattern );
- jira.parseXML( output );
- getLog().info( "The JIRA version is '" + jira.getJiraVersion() + "'" );
+ public List getIssueList() throws MojoExecutionException {
+ if (output.isFile()) {
+ JiraXML jira = new JiraXML(log, jiraDatePattern);
+ jira.parseXML(output);
+ getLog().info("The JIRA version is '" + jira.getJiraVersion() + "'");
return jira.getIssueList();
- }
- else
- {
- getLog().warn( "JIRA file " + output.getPath() + " doesn't exist." );
+ } else {
+ getLog().warn("JIRA file " + output.getPath() + " doesn't exist.");
return Collections.emptyList();
}
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/JIRAIssueManagmentSystem.java b/src/main/java/org/apache/maven/plugins/jira/JIRAIssueManagmentSystem.java
index b4ef21d2..2fe841bd 100644
--- a/src/main/java/org/apache/maven/plugins/jira/JIRAIssueManagmentSystem.java
+++ b/src/main/java/org/apache/maven/plugins/jira/JIRAIssueManagmentSystem.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jira;
import org.apache.maven.plugins.changes.IssueType;
import org.apache.maven.plugins.issues.AbstractIssueManagementSystem;
@@ -27,28 +26,23 @@
*
* @version $Id$
*/
-public class JIRAIssueManagmentSystem
- extends AbstractIssueManagementSystem
-{
+public class JIRAIssueManagmentSystem extends AbstractIssueManagementSystem {
private static final String DEFAULT_ADD_TYPE = "New Feature";
private static final String DEFAULT_FIX_TYPE = "Bug";
private static final String DEFAULT_UPDATE_TYPE = "Improvement";
- public JIRAIssueManagmentSystem()
- {
+ public JIRAIssueManagmentSystem() {
super();
// Add the standard issue types for JIRA
- issueTypeMap.put( DEFAULT_ADD_TYPE, IssueType.ADD );
- issueTypeMap.put( DEFAULT_FIX_TYPE, IssueType.FIX );
- issueTypeMap.put( DEFAULT_UPDATE_TYPE, IssueType.UPDATE );
+ issueTypeMap.put(DEFAULT_ADD_TYPE, IssueType.ADD);
+ issueTypeMap.put(DEFAULT_FIX_TYPE, IssueType.FIX);
+ issueTypeMap.put(DEFAULT_UPDATE_TYPE, IssueType.UPDATE);
}
@Override
- public String getName()
- {
+ public String getName() {
return "JIRA";
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/JiraHelper.java b/src/main/java/org/apache/maven/plugins/jira/JiraHelper.java
index d50bc856..1df2c972 100644
--- a/src/main/java/org/apache/maven/plugins/jira/JiraHelper.java
+++ b/src/main/java/org/apache/maven/plugins/jira/JiraHelper.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jira;
import java.text.NumberFormat;
import java.text.ParsePosition;
@@ -34,8 +33,7 @@
* @author Dennis Lundberg
* @version $Id$
*/
-public class JiraHelper
-{
+public class JiraHelper {
private static final String PID = "?pid="; // MCHANGES-281 addd ?
/**
@@ -44,51 +42,44 @@ public class JiraHelper
* @param issueManagementUrl The URL to the issue management system
* @return A Map
containing the URL and project id
*/
- static Map getJiraUrlAndProjectId( String issueManagementUrl )
- {
+ static Map getJiraUrlAndProjectId(String issueManagementUrl) {
String url = issueManagementUrl;
- if ( url.endsWith( "/" ) )
- {
+ if (url.endsWith("/")) {
// MCHANGES-218
- url = url.substring( 0, url.lastIndexOf( '/' ) );
+ url = url.substring(0, url.lastIndexOf('/'));
}
// chop off the parameter part
- int pos = url.indexOf( '?' );
+ int pos = url.indexOf('?');
// and get the id while we're at it
String id = "";
- if ( pos >= 0 )
- {
+ if (pos >= 0) {
// project id
- 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 = jiraUrl.substring( 0, jiraUrl.lastIndexOf( '/' ) );
- }
- else
- {
+ if (jiraUrl.endsWith("secure")) {
+ jiraUrl = jiraUrl.substring(0, jiraUrl.lastIndexOf('/'));
+ } else {
// If the issueManagement.url points to a component, then "browse"
// will not be at the end - it might be in the middle somewhere.
// Try to find it.
- final int index = jiraUrl.indexOf( "/browse" );
- if ( index != -1 )
- {
- jiraUrl = jiraUrl.substring( 0, index );
+ final int index = jiraUrl.indexOf("/browse");
+ if (index != -1) {
+ jiraUrl = jiraUrl.substring(0, index);
}
}
- HashMap urlMap = new HashMap<>( 4 );
+ HashMap urlMap = new HashMap<>(4);
- urlMap.put( "url", jiraUrl );
+ urlMap.put("url", jiraUrl);
- urlMap.put( "id", id );
+ urlMap.put("id", id);
return urlMap;
}
@@ -101,49 +92,38 @@ static Map getJiraUrlAndProjectId( String issueManagementUrl )
* @param client The client used to connect to JIRA
* @return The JIRA id for the project, or null if it can't be found
*/
- public static String getPidFromJira( Log log, String issueManagementUrl, HttpClient client )
- {
+ public static String getPidFromJira(Log log, String issueManagementUrl, HttpClient client) {
String jiraId = null;
- GetMethod gm = new GetMethod( issueManagementUrl );
+ GetMethod gm = new GetMethod(issueManagementUrl);
String projectPage;
- try
- {
- client.executeMethod( gm );
- log.debug( "Successfully reached JIRA." );
+ try {
+ client.executeMethod(gm);
+ log.debug("Successfully reached JIRA.");
projectPage = gm.getResponseBodyAsString();
- }
- catch ( Exception e )
- {
- if ( log.isDebugEnabled() )
- {
- log.error( "Unable to reach the JIRA project page:", e );
- }
- else
- {
- log.error( "Unable to reach the JIRA project page. Cause is: " + e.getLocalizedMessage() );
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.error("Unable to reach the JIRA project page:", e);
+ } else {
+ log.error("Unable to reach the JIRA project page. Cause is: " + e.getLocalizedMessage());
}
return null;
}
- int pidIndex = projectPage.indexOf( PID );
+ int pidIndex = projectPage.indexOf(PID);
- if ( pidIndex == -1 )
- {
- log.error( "Unable to extract a JIRA pid from the page at the url " + issueManagementUrl );
- }
- else
- {
+ if (pidIndex == -1) {
+ log.error("Unable to extract a JIRA pid from the page at the url " + issueManagementUrl);
+ } else {
NumberFormat nf = NumberFormat.getInstance();
- Number pidNumber = nf.parse( projectPage, new ParsePosition( pidIndex + PID.length() ) );
- jiraId = Integer.toString( pidNumber.intValue() );
- log.debug( "Found the pid " + jiraId + " at " + issueManagementUrl );
+ Number pidNumber = nf.parse(projectPage, new ParsePosition(pidIndex + PID.length()));
+ jiraId = Integer.toString(pidNumber.intValue());
+ log.debug("Found the pid " + jiraId + " at " + issueManagementUrl);
}
return jiraId;
}
- private JiraHelper()
- {
+ private JiraHelper() {
// utility class
}
@@ -155,40 +135,33 @@ private JiraHelper()
* @return A Map
containing the URL and project name
* @since 2.8
*/
- public static Map getJiraUrlAndProjectName( String issueManagementUrl )
- {
- final int indexBrowse = issueManagementUrl.indexOf( "/browse/" );
+ public static Map getJiraUrlAndProjectName(String issueManagementUrl) {
+ final int indexBrowse = issueManagementUrl.indexOf("/browse/");
String jiraUrl;
String project;
- if ( indexBrowse != -1 )
- {
- jiraUrl = issueManagementUrl.substring( 0, indexBrowse );
+ if (indexBrowse != -1) {
+ jiraUrl = issueManagementUrl.substring(0, indexBrowse);
final int indexBrowseEnd = indexBrowse + "/browse/".length();
- final int indexProject = issueManagementUrl.indexOf( "/", indexBrowseEnd );
+ final int indexProject = issueManagementUrl.indexOf("/", indexBrowseEnd);
- if ( indexProject != -1 )
- {
+ if (indexProject != -1) {
// Project name has trailing '/'
- project = issueManagementUrl.substring( indexBrowseEnd, indexProject );
- }
- else
- {
+ project = issueManagementUrl.substring(indexBrowseEnd, indexProject);
+ } else {
// Project name without trailing '/'
- project = issueManagementUrl.substring( indexBrowseEnd );
+ project = issueManagementUrl.substring(indexBrowseEnd);
}
- }
- else
- {
- throw new IllegalArgumentException( "Invalid browse URL" );
+ } else {
+ throw new IllegalArgumentException("Invalid browse URL");
}
- HashMap urlMap = new HashMap<>( 4 );
- urlMap.put( "url", jiraUrl );
- urlMap.put( "project", project );
+ HashMap urlMap = new HashMap<>(4);
+ urlMap.put("url", jiraUrl);
+ urlMap.put("project", project);
return urlMap;
}
@@ -198,9 +171,8 @@ public static Map getJiraUrlAndProjectName( String issueManageme
* @return the base URL.
* @since 2.8
*/
- public static String getBaseUrl( String url )
- {
- int index = url.indexOf( "/", 8 ); // Ignore http:// or https://
- return url.substring( 0, index );
+ public static String getBaseUrl(String url) {
+ int index = url.indexOf("/", 8); // Ignore http:// or https://
+ return url.substring(0, index);
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/JiraMojo.java b/src/main/java/org/apache/maven/plugins/jira/JiraMojo.java
index a06053ba..03ea4c0c 100644
--- a/src/main/java/org/apache/maven/plugins/jira/JiraMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jira/JiraMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jira;
import java.io.File;
import java.util.HashMap;
@@ -45,31 +44,28 @@
* @author Johnny R. Ruiz III
* @version $Id$
*/
-@Mojo( name = "jira-report", threadSafe = true )
-public class JiraMojo
- extends AbstractChangesReport
-{
+@Mojo(name = "jira-report", threadSafe = true)
+public class JiraMojo extends AbstractChangesReport {
/**
* Valid JIRA columns.
*/
- private static final Map JIRA_COLUMNS = new HashMap<>( 16 );
-
- static
- {
- JIRA_COLUMNS.put( "Assignee", IssuesReportHelper.COLUMN_ASSIGNEE );
- JIRA_COLUMNS.put( "Component", IssuesReportHelper.COLUMN_COMPONENT );
- JIRA_COLUMNS.put( "Created", IssuesReportHelper.COLUMN_CREATED );
- JIRA_COLUMNS.put( "Fix Version", IssuesReportHelper.COLUMN_FIX_VERSION );
- JIRA_COLUMNS.put( "Id", IssuesReportHelper.COLUMN_ID );
- JIRA_COLUMNS.put( "Key", IssuesReportHelper.COLUMN_KEY );
- JIRA_COLUMNS.put( "Priority", IssuesReportHelper.COLUMN_PRIORITY );
- JIRA_COLUMNS.put( "Reporter", IssuesReportHelper.COLUMN_REPORTER );
- JIRA_COLUMNS.put( "Resolution", IssuesReportHelper.COLUMN_RESOLUTION );
- JIRA_COLUMNS.put( "Status", IssuesReportHelper.COLUMN_STATUS );
- JIRA_COLUMNS.put( "Summary", IssuesReportHelper.COLUMN_SUMMARY );
- JIRA_COLUMNS.put( "Type", IssuesReportHelper.COLUMN_TYPE );
- JIRA_COLUMNS.put( "Updated", IssuesReportHelper.COLUMN_UPDATED );
- JIRA_COLUMNS.put( "Version", IssuesReportHelper.COLUMN_VERSION );
+ private static final Map JIRA_COLUMNS = new HashMap<>(16);
+
+ static {
+ JIRA_COLUMNS.put("Assignee", IssuesReportHelper.COLUMN_ASSIGNEE);
+ JIRA_COLUMNS.put("Component", IssuesReportHelper.COLUMN_COMPONENT);
+ JIRA_COLUMNS.put("Created", IssuesReportHelper.COLUMN_CREATED);
+ JIRA_COLUMNS.put("Fix Version", IssuesReportHelper.COLUMN_FIX_VERSION);
+ JIRA_COLUMNS.put("Id", IssuesReportHelper.COLUMN_ID);
+ JIRA_COLUMNS.put("Key", IssuesReportHelper.COLUMN_KEY);
+ JIRA_COLUMNS.put("Priority", IssuesReportHelper.COLUMN_PRIORITY);
+ JIRA_COLUMNS.put("Reporter", IssuesReportHelper.COLUMN_REPORTER);
+ JIRA_COLUMNS.put("Resolution", IssuesReportHelper.COLUMN_RESOLUTION);
+ JIRA_COLUMNS.put("Status", IssuesReportHelper.COLUMN_STATUS);
+ JIRA_COLUMNS.put("Summary", IssuesReportHelper.COLUMN_SUMMARY);
+ JIRA_COLUMNS.put("Type", IssuesReportHelper.COLUMN_TYPE);
+ JIRA_COLUMNS.put("Updated", IssuesReportHelper.COLUMN_UPDATED);
+ JIRA_COLUMNS.put("Version", IssuesReportHelper.COLUMN_VERSION);
}
/**
@@ -83,7 +79,7 @@ public class JiraMojo
*
* @since 2.0
*/
- @Parameter( defaultValue = "Key,Summary,Status,Resolution,Assignee" )
+ @Parameter(defaultValue = "Key,Summary,Status,Resolution,Assignee")
private String columnNames;
/**
@@ -93,7 +89,7 @@ public class JiraMojo
*
* @since 2.8
*/
- @Parameter( property = "changes.useJql", defaultValue = "false" )
+ @Parameter(property = "changes.useJql", defaultValue = "false")
private boolean useJql;
/**
@@ -103,7 +99,7 @@ public class JiraMojo
*
* @since 2.9
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean forceRss;
/**
@@ -135,7 +131,7 @@ public class JiraMojo
*
* @since 2.4
*/
- @Parameter( defaultValue = "EEE, d MMM yyyy HH:mm:ss Z" )
+ @Parameter(defaultValue = "EEE, d MMM yyyy HH:mm:ss Z")
private String jiraDatePattern;
/**
@@ -155,19 +151,19 @@ public class JiraMojo
*
* @since 3.0.0
*/
- @Parameter( property = "changes.jiraServerId" )
+ @Parameter(property = "changes.jiraServerId")
private String jiraServerId;
/**
* Path to the JIRA XML file, which will be parsed.
*/
- @Parameter( defaultValue = "${project.build.directory}/jira-results.xml", required = true, readonly = true )
+ @Parameter(defaultValue = "${project.build.directory}/jira-results.xml", required = true, readonly = true)
private File jiraXmlPath;
/**
* Maximum number of entries to be fetched from JIRA.
*/
- @Parameter( defaultValue = "100" )
+ @Parameter(defaultValue = "100")
private int maxEntries;
/**
@@ -176,7 +172,7 @@ public class JiraMojo
*
* @since 2.0
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean onlyCurrentVersion;
/**
@@ -195,21 +191,21 @@ public class JiraMojo
* Note: In versions 2.0-beta-3 and earlier this parameter had no default value.
*
*/
- @Parameter( defaultValue = "Fixed" )
+ @Parameter(defaultValue = "Fixed")
private String resolutionIds;
/**
* Settings XML configuration.
*/
- @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+ @Parameter(defaultValue = "${settings}", readonly = true, required = true)
private Settings settings;
/**
* If set to true
, then the JIRA report will not be generated.
- *
+ *
* @since 2.8
*/
- @Parameter( property = "changes.jira.skip", defaultValue = "false" )
+ @Parameter(property = "changes.jira.skip", defaultValue = "false")
private boolean skip;
/**
@@ -233,7 +229,7 @@ public class JiraMojo
*
* @since 2.0
*/
- @Parameter( defaultValue = "Priority DESC, Created DESC" )
+ @Parameter(defaultValue = "Priority DESC, Created DESC")
private String sortColumnNames;
/**
@@ -250,7 +246,7 @@ public class JiraMojo
* Note: In versions 2.0-beta-3 and earlier this parameter had no default value.
*
*/
- @Parameter( defaultValue = "Closed" )
+ @Parameter(defaultValue = "Closed")
private String statusIds;
/**
@@ -301,106 +297,84 @@ public class JiraMojo
/**
* @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
*/
- public boolean canGenerateReport()
- {
+ public boolean canGenerateReport() {
// Run only at the execution root
- if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
- {
- getLog().info( "Skipping the JIRA Report in this project because it's not the Execution Root" );
+ if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
+ getLog().info("Skipping the JIRA Report in this project because it's not the Execution Root");
return false;
}
- if ( skip )
- {
+ if (skip) {
return false;
}
- if ( mockDownloader != null )
- {
+ if (mockDownloader != null) {
return true;
}
- String message = ProjectUtils.validateIssueManagement( project, "JIRA", "JIRA Report" );
- if ( message != null )
- {
- getLog().warn( message );
+ String message = ProjectUtils.validateIssueManagement(project, "JIRA", "JIRA Report");
+ if (message != null) {
+ getLog().warn(message);
}
return message == null;
}
- public void executeReport( Locale locale )
- throws MavenReportException
- {
+ public void executeReport(Locale locale) throws MavenReportException {
// Validate parameters
- List columnIds = IssuesReportHelper.getColumnIds( columnNames, JIRA_COLUMNS );
- if ( columnIds.isEmpty() )
- {
+ List columnIds = IssuesReportHelper.getColumnIds(columnNames, JIRA_COLUMNS);
+ if (columnIds.isEmpty()) {
// This can happen if the user has configured column names and they are all invalid
- throw new MavenReportException( "maven-changes-plugin: None of the configured columnNames '" + columnNames
- + "' are valid." );
+ throw new MavenReportException(
+ "maven-changes-plugin: None of the configured columnNames '" + columnNames + "' are valid.");
}
- try
- {
+ try {
// Download issues
AbstractJiraDownloader issueDownloader;
- if ( mockDownloader != null )
- {
+ if (mockDownloader != null) {
issueDownloader = mockDownloader;
- }
- else
- {
+ } else {
AdaptiveJiraDownloader downloader = new AdaptiveJiraDownloader();
- downloader.setForceClassic( forceRss );
+ downloader.setForceClassic(forceRss);
issueDownloader = downloader;
}
- configureIssueDownloader( issueDownloader );
+ configureIssueDownloader(issueDownloader);
issueDownloader.doExecute();
List issueList = issueDownloader.getIssueList();
- if ( StringUtils.isNotEmpty( versionPrefix ) )
- {
+ if (StringUtils.isNotEmpty(versionPrefix)) {
int originalNumberOfIssues = issueList.size();
- issueList = IssueUtils.filterIssuesWithVersionPrefix( issueList, versionPrefix );
- getLog().debug( "Filtered out " + issueList.size() + " issues of " + originalNumberOfIssues
- + " that matched the versionPrefix '" + versionPrefix + "'." );
+ issueList = IssueUtils.filterIssuesWithVersionPrefix(issueList, versionPrefix);
+ getLog().debug("Filtered out " + issueList.size() + " issues of " + originalNumberOfIssues
+ + " that matched the versionPrefix '" + versionPrefix + "'.");
}
- if ( onlyCurrentVersion )
- {
- String version = ( versionPrefix == null ? "" : versionPrefix ) + project.getVersion();
- issueList = IssueUtils.getIssuesForVersion( issueList, version );
- getLog().info( "The JIRA Report will contain issues only for the current version." );
+ if (onlyCurrentVersion) {
+ String version = (versionPrefix == null ? "" : versionPrefix) + project.getVersion();
+ issueList = IssueUtils.getIssuesForVersion(issueList, version);
+ getLog().info("The JIRA Report will contain issues only for the current version.");
}
// Generate the report
- IssuesReportGenerator report = new IssuesReportGenerator( IssuesReportHelper.toIntArray( columnIds ) );
+ IssuesReportGenerator report = new IssuesReportGenerator(IssuesReportHelper.toIntArray(columnIds));
- if ( issueList.isEmpty() )
- {
- report.doGenerateEmptyReport( getBundle( locale ), getSink() );
- }
- else
- {
- report.doGenerateReport( getBundle( locale ), getSink(), issueList );
+ if (issueList.isEmpty()) {
+ report.doGenerateEmptyReport(getBundle(locale), getSink());
+ } else {
+ report.doGenerateReport(getBundle(locale), getSink(), issueList);
}
- }
- catch ( Exception e )
- {
- getLog().warn( e );
+ } catch (Exception e) {
+ getLog().warn(e);
}
}
- public String getDescription( Locale locale )
- {
- return getBundle( locale ).getString( "report.issues.description" );
+ public String getDescription(Locale locale) {
+ return getBundle(locale).getString("report.issues.description");
}
- public String getName( Locale locale )
- {
- return getBundle( locale ).getString( "report.issues.name" );
+ public String getName(Locale locale) {
+ return getBundle(locale).getString("report.issues.name");
}
- public String getOutputName()
- {
+ public String getOutputName() {
return "jira-report";
}
@@ -408,71 +382,64 @@ public String getOutputName()
/* Private methods */
/* --------------------------------------------------------------------- */
- private ResourceBundle getBundle( Locale locale )
- {
- return ResourceBundle.getBundle( "jira-report", locale, this.getClass().getClassLoader() );
+ private ResourceBundle getBundle(Locale locale) {
+ return ResourceBundle.getBundle("jira-report", locale, this.getClass().getClassLoader());
}
- private void configureIssueDownloader( AbstractJiraDownloader issueDownloader )
- {
- issueDownloader.setLog( getLog() );
+ private void configureIssueDownloader(AbstractJiraDownloader issueDownloader) {
+ issueDownloader.setLog(getLog());
- issueDownloader.setMavenProject( project );
+ issueDownloader.setMavenProject(project);
- issueDownloader.setOutput( jiraXmlPath );
+ issueDownloader.setOutput(jiraXmlPath);
- issueDownloader.setNbEntries( maxEntries );
+ issueDownloader.setNbEntries(maxEntries);
- issueDownloader.setComponent( component );
+ issueDownloader.setComponent(component);
- issueDownloader.setFixVersionIds( fixVersionIds );
+ issueDownloader.setFixVersionIds(fixVersionIds);
- issueDownloader.setStatusIds( statusIds );
+ issueDownloader.setStatusIds(statusIds);
- issueDownloader.setResolutionIds( resolutionIds );
+ issueDownloader.setResolutionIds(resolutionIds);
- issueDownloader.setPriorityIds( priorityIds );
+ issueDownloader.setPriorityIds(priorityIds);
- issueDownloader.setSortColumnNames( sortColumnNames );
+ issueDownloader.setSortColumnNames(sortColumnNames);
- issueDownloader.setFilter( filter );
+ issueDownloader.setFilter(filter);
- issueDownloader.setJiraDatePattern( jiraDatePattern );
+ issueDownloader.setJiraDatePattern(jiraDatePattern);
- if ( jiraServerId != null )
- {
- final Server server = mavenSession.getSettings().getServer( jiraServerId );
- issueDownloader.setJiraUser( server.getUsername() );
- issueDownloader.setJiraPassword( server.getPassword() );
- }
- else
- {
- issueDownloader.setJiraUser( jiraUser );
- issueDownloader.setJiraPassword( jiraPassword );
+ if (jiraServerId != null) {
+ final Server server = mavenSession.getSettings().getServer(jiraServerId);
+ issueDownloader.setJiraUser(server.getUsername());
+ issueDownloader.setJiraPassword(server.getPassword());
+ } else {
+ issueDownloader.setJiraUser(jiraUser);
+ issueDownloader.setJiraPassword(jiraPassword);
}
- issueDownloader.setTypeIds( typeIds );
+ issueDownloader.setTypeIds(typeIds);
- issueDownloader.setWebUser( webUser );
+ issueDownloader.setWebUser(webUser);
- issueDownloader.setWebPassword( webPassword );
+ issueDownloader.setWebPassword(webPassword);
- issueDownloader.setSettings( settings );
+ issueDownloader.setSettings(settings);
- issueDownloader.setUseJql( useJql );
+ issueDownloader.setUseJql(useJql);
- issueDownloader.setOnlyCurrentVersion( onlyCurrentVersion );
+ issueDownloader.setOnlyCurrentVersion(onlyCurrentVersion);
- issueDownloader.setVersionPrefix( versionPrefix );
+ issueDownloader.setVersionPrefix(versionPrefix);
}
- public void setMockDownloader( AbstractJiraDownloader mockDownloader )
- {
+ public void setMockDownloader(AbstractJiraDownloader mockDownloader) {
this.mockDownloader = mockDownloader;
}
- public AbstractJiraDownloader getMockDownloader()
- {
+ public AbstractJiraDownloader getMockDownloader() {
return mockDownloader;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/JiraQueryBuilder.java b/src/main/java/org/apache/maven/plugins/jira/JiraQueryBuilder.java
index dbe1e5d0..d792e0c0 100644
--- a/src/main/java/org/apache/maven/plugins/jira/JiraQueryBuilder.java
+++ b/src/main/java/org/apache/maven/plugins/jira/JiraQueryBuilder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,11 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.plugin.logging.Log;
+package org.apache.maven.plugins.jira;
import java.util.List;
+import org.apache.maven.plugin.logging.Log;
+
/**
* An interface for building a search query for JIRA.
*
@@ -30,41 +29,40 @@
* @version $Id$
* @since 2.8
*/
-public interface JiraQueryBuilder
-{
+public interface JiraQueryBuilder {
String build();
- JiraQueryBuilder components( String components );
+ JiraQueryBuilder components(String components);
- JiraQueryBuilder components( List components );
+ JiraQueryBuilder components(List components);
- JiraQueryBuilder filter( String filter );
+ JiraQueryBuilder filter(String filter);
- JiraQueryBuilder fixVersion( String fixVersion );
+ JiraQueryBuilder fixVersion(String fixVersion);
- JiraQueryBuilder fixVersionIds( String fixVersionIds );
+ JiraQueryBuilder fixVersionIds(String fixVersionIds);
- JiraQueryBuilder fixVersionIds( List fixVersionIds );
+ JiraQueryBuilder fixVersionIds(List fixVersionIds);
Log getLog();
- JiraQueryBuilder priorityIds( String priorityIds );
+ JiraQueryBuilder priorityIds(String priorityIds);
- JiraQueryBuilder priorityIds( List priorityIds );
+ JiraQueryBuilder priorityIds(List priorityIds);
- JiraQueryBuilder project( String project );
+ JiraQueryBuilder project(String project);
- JiraQueryBuilder resolutionIds( String resolutionIds );
+ JiraQueryBuilder resolutionIds(String resolutionIds);
- JiraQueryBuilder resolutionIds( List resolutionIds );
+ JiraQueryBuilder resolutionIds(List resolutionIds);
- JiraQueryBuilder sortColumnNames( String sortColumnNames );
+ JiraQueryBuilder sortColumnNames(String sortColumnNames);
- JiraQueryBuilder statusIds( String statusIds );
+ JiraQueryBuilder statusIds(String statusIds);
- JiraQueryBuilder statusIds( List statusIds );
+ JiraQueryBuilder statusIds(List statusIds);
- JiraQueryBuilder typeIds( String typeIds );
+ JiraQueryBuilder typeIds(String typeIds);
- JiraQueryBuilder typeIds( List typeIds );
+ JiraQueryBuilder typeIds(List typeIds);
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/JiraXML.java b/src/main/java/org/apache/maven/plugins/jira/JiraXML.java
index b3592fe6..cea101f5 100644
--- a/src/main/java/org/apache/maven/plugins/jira/JiraXML.java
+++ b/src/main/java/org/apache/maven/plugins/jira/JiraXML.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.jira;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
import java.io.File;
import java.io.FileInputStream;
@@ -30,9 +32,6 @@
import java.util.List;
import java.util.Locale;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.issues.Issue;
@@ -44,15 +43,13 @@
/**
* XML parser that extracts Issue
s from JIRA. This works on an XML file downloaded from JIRA and creates a
* List
of issues that is exposed to the user of the class.
- *
+ *
* @version $Id$
*/
-public class JiraXML
- extends DefaultHandler
-{
+public class JiraXML extends DefaultHandler {
private final List issueList;
- private final StringBuilder currentElement = new StringBuilder( 1024 );
+ private final StringBuilder currentElement = new StringBuilder(1024);
private String currentParent = "";
@@ -71,81 +68,62 @@ public class JiraXML
* @param datePattern may be null.
* @since 2.4
*/
- public JiraXML( Log log, String datePattern )
- {
+ public JiraXML(Log log, String datePattern) {
this.log = log;
this.datePattern = datePattern;
- if ( datePattern == null )
- {
+ if (datePattern == null) {
sdf = null;
- }
- else
- {
+ } else {
// @todo Do we need to be able to configure the locale of the JIRA server as well?
- sdf = new SimpleDateFormat( datePattern, Locale.ENGLISH );
+ sdf = new SimpleDateFormat(datePattern, Locale.ENGLISH);
}
- this.issueList = new ArrayList<>( 16 );
+ this.issueList = new ArrayList<>(16);
}
/**
* Parse the given xml file. The list of issues can then be retrieved with {@link #getIssueList()}.
- *
+ *
* @param xmlPath the file to pares.
* @throws MojoExecutionException in case of errors.
* @since 2.4
*/
- public void parseXML( File xmlPath )
- throws MojoExecutionException
- {
+ public void parseXML(File xmlPath) throws MojoExecutionException {
InputStream xmlStream = null;
- try
- {
- xmlStream = new FileInputStream( xmlPath );
- InputSource inputSource = new InputSource( xmlStream );
- parse( inputSource );
- }
- catch ( FileNotFoundException e )
- {
- throw new MojoExecutionException( "Failed to open JIRA XML file " + xmlPath, e );
- }
- finally
- {
- IOUtil.close( xmlStream );
+ try {
+ xmlStream = new FileInputStream(xmlPath);
+ InputSource inputSource = new InputSource(xmlStream);
+ parse(inputSource);
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Failed to open JIRA XML file " + xmlPath, e);
+ } finally {
+ IOUtil.close(xmlStream);
}
}
- void parse( InputSource xmlSource )
- throws MojoExecutionException
- {
- try
- {
+ void parse(InputSource xmlSource) throws MojoExecutionException {
+ try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
- saxParser.parse( xmlSource, this );
- }
- catch ( Throwable t )
- {
- throw new MojoExecutionException( "Failed to parse JIRA XML.", t );
+ saxParser.parse(xmlSource, this);
+ } catch (Throwable t) {
+ throw new MojoExecutionException("Failed to parse JIRA XML.", t);
}
}
- public void startElement( String namespaceURI, String sName, String qName, Attributes attrs )
- {
- switch ( qName )
- {
+ public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) {
+ switch (qName) {
case "item":
issue = new Issue();
currentParent = "item";
break;
case "key":
- String id = attrs.getValue( "id" );
- if ( id != null )
- {
- issue.setId( id.trim() );
+ String id = attrs.getValue("id");
+ if (id != null) {
+ issue.setId(id.trim());
}
break;
case "build-info":
@@ -156,112 +134,67 @@ public void startElement( String namespaceURI, String sName, String qName, Attri
}
}
- public void endElement( String namespaceURI, String sName, String qName )
- {
- if ( qName.equals( "item" ) )
- {
- issueList.add( issue );
+ public void endElement(String namespaceURI, String sName, String qName) {
+ if (qName.equals("item")) {
+ issueList.add(issue);
currentParent = "";
- }
- else if ( qName.equals( "key" ) )
- {
- issue.setKey( currentElement.toString().trim() );
- }
- else if ( qName.equals( "summary" ) )
- {
- issue.setSummary( currentElement.toString().trim() );
- }
- else if ( qName.equals( "type" ) )
- {
- issue.setType( currentElement.toString().trim() );
- }
- else if ( qName.equals( "link" ) && currentParent.equals( "item" ) )
- {
- issue.setLink( currentElement.toString().trim() );
- }
- else if ( qName.equals( "priority" ) )
- {
- issue.setPriority( currentElement.toString().trim() );
- }
- else if ( qName.equals( "status" ) )
- {
- issue.setStatus( currentElement.toString().trim() );
- }
- else if ( qName.equals( "resolution" ) )
- {
- issue.setResolution( currentElement.toString().trim() );
- }
- else if ( qName.equals( "assignee" ) )
- {
- issue.setAssignee( currentElement.toString().trim() );
- }
- else if ( qName.equals( "reporter" ) )
- {
- issue.setReporter( currentElement.toString().trim() );
- }
- else if ( qName.equals( "version" ) && currentParent.equals( "item" ) )
- {
- issue.setVersion( currentElement.toString().trim() );
- }
- else if ( qName.equals( "version" ) && currentParent.equals( "build-info" ) )
- {
+ } else if (qName.equals("key")) {
+ issue.setKey(currentElement.toString().trim());
+ } else if (qName.equals("summary")) {
+ issue.setSummary(currentElement.toString().trim());
+ } else if (qName.equals("type")) {
+ issue.setType(currentElement.toString().trim());
+ } else if (qName.equals("link") && currentParent.equals("item")) {
+ issue.setLink(currentElement.toString().trim());
+ } else if (qName.equals("priority")) {
+ issue.setPriority(currentElement.toString().trim());
+ } else if (qName.equals("status")) {
+ issue.setStatus(currentElement.toString().trim());
+ } else if (qName.equals("resolution")) {
+ issue.setResolution(currentElement.toString().trim());
+ } else if (qName.equals("assignee")) {
+ issue.setAssignee(currentElement.toString().trim());
+ } else if (qName.equals("reporter")) {
+ issue.setReporter(currentElement.toString().trim());
+ } else if (qName.equals("version") && currentParent.equals("item")) {
+ issue.setVersion(currentElement.toString().trim());
+ } else if (qName.equals("version") && currentParent.equals("build-info")) {
jiraVersion = currentElement.toString().trim();
- }
- else if ( qName.equals( "fixVersion" ) )
- {
- issue.addFixVersion( currentElement.toString().trim() );
- }
- else if ( qName.equals( "component" ) )
- {
- issue.addComponent( currentElement.toString().trim() );
- }
- else if ( qName.equals( "comment" ) )
- {
- issue.addComment( currentElement.toString().trim() );
- }
- else if ( qName.equals( "title" ) && currentParent.equals( "item" ) )
- {
- issue.setTitle( currentElement.toString().trim() );
- }
- else if ( qName.equals( "created" ) && currentParent.equals( "item" ) && sdf != null )
- {
- try
- {
- issue.setCreated( sdf.parse( currentElement.toString().trim() ) );
- }
- catch ( ParseException e )
- {
- log.warn( "Element \"Created\". " + e.getMessage() + ". Using the pattern \"" + datePattern + "\"" );
- }
- }
- else if ( qName.equals( "updated" ) && currentParent.equals( "item" ) && sdf != null )
- {
- try
- {
- issue.setUpdated( sdf.parse( currentElement.toString().trim() ) );
+ } else if (qName.equals("fixVersion")) {
+ issue.addFixVersion(currentElement.toString().trim());
+ } else if (qName.equals("component")) {
+ issue.addComponent(currentElement.toString().trim());
+ } else if (qName.equals("comment")) {
+ issue.addComment(currentElement.toString().trim());
+ } else if (qName.equals("title") && currentParent.equals("item")) {
+ issue.setTitle(currentElement.toString().trim());
+ } else if (qName.equals("created") && currentParent.equals("item") && sdf != null) {
+ try {
+ issue.setCreated(sdf.parse(currentElement.toString().trim()));
+ } catch (ParseException e) {
+ log.warn("Element \"Created\". " + e.getMessage() + ". Using the pattern \"" + datePattern + "\"");
}
- catch ( ParseException e )
- {
- log.warn( "Element \"Updated\". " + e.getMessage() + ". Using the pattern \"" + datePattern + "\"" );
+ } else if (qName.equals("updated") && currentParent.equals("item") && sdf != null) {
+ try {
+ issue.setUpdated(sdf.parse(currentElement.toString().trim()));
+ } catch (ParseException e) {
+ log.warn("Element \"Updated\". " + e.getMessage() + ". Using the pattern \"" + datePattern + "\"");
}
}
- currentElement.setLength( 0 );
+ currentElement.setLength(0);
}
- public void characters( char[] buf, int offset, int len )
- {
- currentElement.append( buf, offset, len );
+ public void characters(char[] buf, int offset, int len) {
+ currentElement.append(buf, offset, len);
}
- public List getIssueList()
- {
- return Collections.unmodifiableList( this.issueList );
+ public List getIssueList() {
+ return Collections.unmodifiableList(this.issueList);
}
- public String getJiraVersion()
- {
+ public String getJiraVersion() {
return jiraVersion;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/JqlQueryBuilder.java b/src/main/java/org/apache/maven/plugins/jira/JqlQueryBuilder.java
index d607d6c5..f7330e2e 100644
--- a/src/main/java/org/apache/maven/plugins/jira/JqlQueryBuilder.java
+++ b/src/main/java/org/apache/maven/plugins/jira/JqlQueryBuilder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,14 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.plugin.logging.Log;
+package org.apache.maven.plugins.jira;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Locale;
+import org.apache.maven.plugin.logging.Log;
+
/**
* Builder for a JIRA query using the JIRA query language. Only a limited set of JQL is supported.
*
@@ -33,9 +32,7 @@
* @version $Id$
* @since 2.8
*/
-public class JqlQueryBuilder
- implements JiraQueryBuilder
-{
+public class JqlQueryBuilder implements JiraQueryBuilder {
private String filter = "";
private boolean urlEncode = true;
@@ -49,59 +46,45 @@ public class JqlQueryBuilder
private StringBuilder query = new StringBuilder();
- public JqlQueryBuilder( Log log )
- {
+ public JqlQueryBuilder(Log log) {
this.log = log;
}
- public String build()
- {
- try
- {
+ public String build() {
+ try {
String jqlQuery;
// If the user has defined a filter - use that
- if ( ( this.filter != null ) && ( this.filter.length() > 0 ) )
- {
+ if ((this.filter != null) && (this.filter.length() > 0)) {
jqlQuery = filter;
- }
- else
- {
+ } else {
jqlQuery = query.toString() + orderBy.toString();
}
- if ( urlEncode )
- {
- getLog().debug( "Encoding JQL query " + jqlQuery );
- String encodedQuery = URLEncoder.encode( jqlQuery, "UTF-8" );
- getLog().debug( "Encoded JQL query " + encodedQuery );
+ if (urlEncode) {
+ getLog().debug("Encoding JQL query " + jqlQuery);
+ String encodedQuery = URLEncoder.encode(jqlQuery, "UTF-8");
+ getLog().debug("Encoded JQL query " + encodedQuery);
return encodedQuery;
- }
- else
- {
+ } else {
return jqlQuery;
}
- }
- catch ( UnsupportedEncodingException e )
- {
- getLog().error( "Unable to encode JQL query with UTF-8", e );
- throw new RuntimeException( e );
+ } catch (UnsupportedEncodingException e) {
+ getLog().error("Unable to encode JQL query with UTF-8", e);
+ throw new RuntimeException(e);
}
}
- public JiraQueryBuilder components( String components )
- {
- addCommaSeparatedValues( "component", components );
+ public JiraQueryBuilder components(String components) {
+ addCommaSeparatedValues("component", components);
return this;
}
- public JiraQueryBuilder components( List components )
- {
- addValues( "component", components );
+ public JiraQueryBuilder components(List components) {
+ addValues("component", components);
return this;
}
- public JiraQueryBuilder filter( String filter )
- {
+ public JiraQueryBuilder filter(String filter) {
this.filter = filter;
return this;
}
@@ -113,9 +96,8 @@ public JiraQueryBuilder filter( String filter )
* @param fixVersion a single fix version
* @return the builder.
*/
- public JiraQueryBuilder fixVersion( String fixVersion )
- {
- addSingleValue( "fixVersion", fixVersion );
+ public JiraQueryBuilder fixVersion(String fixVersion) {
+ addSingleValue("fixVersion", fixVersion);
return this;
}
@@ -126,109 +108,92 @@ public JiraQueryBuilder fixVersion( String fixVersion )
* @param fixVersionIds a comma-separated list of version ids.
* @return the builder.
*/
- public JiraQueryBuilder fixVersionIds( String fixVersionIds )
- {
- addCommaSeparatedValues( "fixVersion", fixVersionIds );
+ public JiraQueryBuilder fixVersionIds(String fixVersionIds) {
+ addCommaSeparatedValues("fixVersion", fixVersionIds);
return this;
}
/**
* Add a sequence of version IDs already in a list.
- *
+ *
* @param fixVersionIds the version ids.
* @return the builder.
*/
- public JiraQueryBuilder fixVersionIds( List fixVersionIds )
- {
- addValues( "fixVersion", fixVersionIds );
+ public JiraQueryBuilder fixVersionIds(List fixVersionIds) {
+ addValues("fixVersion", fixVersionIds);
return this;
}
- public Log getLog()
- {
+ public Log getLog() {
return log;
}
- public JiraQueryBuilder priorityIds( String priorityIds )
- {
- addCommaSeparatedValues( "priority", priorityIds );
+ public JiraQueryBuilder priorityIds(String priorityIds) {
+ addCommaSeparatedValues("priority", priorityIds);
return this;
}
- public JiraQueryBuilder priorityIds( List priorityIds )
- {
- addValues( "priority", priorityIds );
+ public JiraQueryBuilder priorityIds(List priorityIds) {
+ addValues("priority", priorityIds);
return this;
}
- public JiraQueryBuilder project( String project )
- {
- addSingleValue( "project", project );
+ public JiraQueryBuilder project(String project) {
+ addSingleValue("project", project);
return this;
}
- public JiraQueryBuilder resolutionIds( String resolutionIds )
- {
- addCommaSeparatedValues( "resolution", resolutionIds );
+ public JiraQueryBuilder resolutionIds(String resolutionIds) {
+ addCommaSeparatedValues("resolution", resolutionIds);
return this;
}
- public JiraQueryBuilder resolutionIds( List resolutionIds )
- {
- addValues( "resolution", resolutionIds );
+ public JiraQueryBuilder resolutionIds(List resolutionIds) {
+ addValues("resolution", resolutionIds);
return this;
}
- public JiraQueryBuilder sortColumnNames( String sortColumnNames )
- {
- if ( sortColumnNames != null )
- {
- orderBy.append( " ORDER BY " );
+ public JiraQueryBuilder sortColumnNames(String sortColumnNames) {
+ if (sortColumnNames != null) {
+ orderBy.append(" ORDER BY ");
- String[] sortColumnNamesArray = sortColumnNames.split( "," );
+ String[] sortColumnNamesArray = sortColumnNames.split(",");
- for ( int i = 0; i < sortColumnNamesArray.length - 1; i++ )
- {
- addSingleSortColumn( sortColumnNamesArray[i] );
- orderBy.append( ", " );
+ for (int i = 0; i < sortColumnNamesArray.length - 1; i++) {
+ addSingleSortColumn(sortColumnNamesArray[i]);
+ orderBy.append(", ");
}
- addSingleSortColumn( sortColumnNamesArray[sortColumnNamesArray.length - 1] );
+ addSingleSortColumn(sortColumnNamesArray[sortColumnNamesArray.length - 1]);
}
return this;
}
- public JiraQueryBuilder statusIds( String statusIds )
- {
- addCommaSeparatedValues( "status", statusIds );
+ public JiraQueryBuilder statusIds(String statusIds) {
+ addCommaSeparatedValues("status", statusIds);
return this;
}
- public JiraQueryBuilder statusIds( List statusIds )
- {
- addValues( "status", statusIds );
+ public JiraQueryBuilder statusIds(List statusIds) {
+ addValues("status", statusIds);
return this;
}
- public JiraQueryBuilder typeIds( String typeIds )
- {
- addCommaSeparatedValues( "type", typeIds );
+ public JiraQueryBuilder typeIds(String typeIds) {
+ addCommaSeparatedValues("type", typeIds);
return this;
}
- public JiraQueryBuilder typeIds( List typeIds )
- {
- addValues( "type", typeIds );
+ public JiraQueryBuilder typeIds(List typeIds) {
+ addValues("type", typeIds);
return this;
}
- public JiraQueryBuilder urlEncode( boolean doEncoding )
- {
+ public JiraQueryBuilder urlEncode(boolean doEncoding) {
urlEncode = doEncoding;
return this;
}
- public boolean urlEncode()
- {
+ public boolean urlEncode() {
return urlEncode;
}
@@ -236,93 +201,74 @@ public boolean urlEncode()
/* Private methods */
/* --------------------------------------------------------------------- */
- private void addCommaSeparatedValues( String key, String values )
- {
- if ( values != null )
- {
- if ( query.length() > 0 )
- {
- query.append( " AND " );
+ private void addCommaSeparatedValues(String key, String values) {
+ if (values != null) {
+ if (query.length() > 0) {
+ query.append(" AND ");
}
- query.append( key ).append( " in (" );
+ query.append(key).append(" in (");
- String[] valuesArr = values.split( "," );
+ String[] valuesArr = values.split(",");
- for ( int i = 0; i < ( valuesArr.length - 1 ); i++ )
- {
- trimAndQuoteValue( valuesArr[i] );
- query.append( ", " );
+ for (int i = 0; i < (valuesArr.length - 1); i++) {
+ trimAndQuoteValue(valuesArr[i]);
+ query.append(", ");
}
- trimAndQuoteValue( valuesArr[valuesArr.length - 1] );
- query.append( ")" );
+ trimAndQuoteValue(valuesArr[valuesArr.length - 1]);
+ query.append(")");
}
}
- private void addValues( String key, List values )
- {
- if ( values != null && values.size() > 0 )
- {
- if ( query.length() > 0 )
- {
- query.append( " AND " );
+ private void addValues(String key, List values) {
+ if (values != null && values.size() > 0) {
+ if (query.length() > 0) {
+ query.append(" AND ");
}
- query.append( key ).append( " in (" );
+ query.append(key).append(" in (");
- for ( int i = 0; i < ( values.size() - 1 ); i++ )
- {
- trimAndQuoteValue( values.get( i ) );
- query.append( ", " );
+ for (int i = 0; i < (values.size() - 1); i++) {
+ trimAndQuoteValue(values.get(i));
+ query.append(", ");
}
- trimAndQuoteValue( values.get( values.size() - 1 ) );
- query.append( ")" );
+ trimAndQuoteValue(values.get(values.size() - 1));
+ query.append(")");
}
}
- private void addSingleSortColumn( String name )
- {
+ private void addSingleSortColumn(String name) {
boolean descending = false;
- name = name.trim().toLowerCase( Locale.ENGLISH );
- if ( name.endsWith( "desc" ) )
- {
+ name = name.trim().toLowerCase(Locale.ENGLISH);
+ if (name.endsWith("desc")) {
descending = true;
- name = name.substring( 0, name.length() - 4 ).trim();
- }
- else if ( name.endsWith( "asc" ) )
- {
+ name = name.substring(0, name.length() - 4).trim();
+ } else if (name.endsWith("asc")) {
descending = false;
- name = name.substring( 0, name.length() - 3 ).trim();
+ name = name.substring(0, name.length() - 3).trim();
}
// Strip any spaces from the column name, or it will trip up JIRA's JQL parser
- name = name.replaceAll( " ", "" );
- orderBy.append( name );
- orderBy.append( descending ? " DESC" : " ASC" );
+ name = name.replaceAll(" ", "");
+ orderBy.append(name);
+ orderBy.append(descending ? " DESC" : " ASC");
}
- private void addSingleValue( String key, String value )
- {
- if ( value != null )
- {
- if ( query.length() > 0 )
- {
- query.append( " AND " );
+ private void addSingleValue(String key, String value) {
+ if (value != null) {
+ if (query.length() > 0) {
+ query.append(" AND ");
}
- query.append( key ).append( " = " );
- trimAndQuoteValue( value );
+ query.append(key).append(" = ");
+ trimAndQuoteValue(value);
}
}
- private void trimAndQuoteValue( String value )
- {
+ private void trimAndQuoteValue(String value) {
String trimmedValue = value.trim();
- if ( trimmedValue.contains( " " ) || trimmedValue.contains( "." ) )
- {
- query.append( "\"" ).append( trimmedValue ).append( "\"" );
- }
- else
- {
- query.append( trimmedValue );
+ if (trimmedValue.contains(" ") || trimmedValue.contains(".")) {
+ query.append("\"").append(trimmedValue).append("\"");
+ } else {
+ query.append(trimmedValue);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugins/jira/ParameterQueryBuilder.java b/src/main/java/org/apache/maven/plugins/jira/ParameterQueryBuilder.java
index 22f3a5ac..c5f5e53b 100644
--- a/src/main/java/org/apache/maven/plugins/jira/ParameterQueryBuilder.java
+++ b/src/main/java/org/apache/maven/plugins/jira/ParameterQueryBuilder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.jira;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,24 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.plugin.logging.Log;
+package org.apache.maven.plugins.jira;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.apache.maven.plugin.logging.Log;
+
/**
* JIRA 3.x way of constructing a search query based on URL parameters.
- *
+ *
* @author ton.swieb@finalist.com
* @version $Id$
* @since 2.8
*/
-public class ParameterQueryBuilder
- implements JiraQueryBuilder
-{
+public class ParameterQueryBuilder implements JiraQueryBuilder {
private String filter = "";
/** Log for debug output. */
@@ -44,100 +41,86 @@ public class ParameterQueryBuilder
private StringBuilder query = new StringBuilder();
/** Mapping containing all allowed JIRA priority values. */
- private final Map priorityMap = new HashMap<>( 8 );
+ private final Map priorityMap = new HashMap<>(8);
/** Mapping containing all allowed JIRA resolution values. */
- private final Map resolutionMap = new HashMap<>( 8 );
+ private final Map resolutionMap = new HashMap<>(8);
/** Mapping containing all allowed JIRA status values. */
- private final Map