You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2008/02/06 00:52:08 UTC
svn commit: r618829 - in
/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin:
announcement/ changes/ jira/
Author: dennisl
Date: Tue Feb 5 15:52:00 2008
New Revision: 618829
URL: http://svn.apache.org/viewvc?rev=618829&view=rev
Log:
[MCHECKSTYLE-96] Change type of path parameters to java.io.File
Submitted by: Benjamin Bentmann
Reviewed by: Dennis Lundberg
Modified:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesXML.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java Tue Feb 5 15:52:00 2008
@@ -143,7 +143,7 @@
* @parameter expression="${project.build.directory}/announcement"
* @required
*/
- private String templateOutputDirectory;
+ private File templateOutputDirectory;
/**
* The Velocity template used to format the announcement.
@@ -158,7 +158,7 @@
public void execute()
throws MojoExecutionException
{
- template = templateOutputDirectory + "/" + template;
+ File templateFile = new File( templateOutputDirectory, template );
ConsoleLogger logger = new ConsoleLogger( 0, "base" );
@@ -186,7 +186,7 @@
getLog().debug( "fromDeveloperId: " + getFromDeveloperId() );
}
- if ( isTextFileExisting( template ) )
+ if ( templateFile.isFile() )
{
getLog().info( "Connecting to Host: " + getSmtpHost() + ":" + getSmtpPort() );
@@ -194,23 +194,7 @@
}
else
{
- if ( template != null )
- {
- if ( isTextFileExisting( template ) )
- {
- getLog().info( "Connecting to Host: " + getSmtpHost() + " : " + getSmtpPort() );
-
- sendMessage();
- }
- else
- {
- throw new MojoExecutionException( "Announcement template " + template + " not found..." );
- }
- }
- else
- {
- throw new MojoExecutionException( "Announcement template " + template + " not found..." );
- }
+ throw new MojoExecutionException( "Announcement template " + templateFile + " not found..." );
}
}
@@ -222,6 +206,7 @@
protected void sendMessage()
throws MojoExecutionException
{
+ File templateFile = new File( templateOutputDirectory, template );
String email = "";
final MailSender ms = getActualMailSender();
final String fromName = ms.getName();
@@ -238,7 +223,7 @@
{
email = it.next().toString();
getLog().info( "Sending mail to " + email + "..." );
- mailer.send( getSubject(), IOUtil.toString( readAnnouncement( template ) ), email, "", fromAddress,
+ mailer.send( getSubject(), IOUtil.toString( readAnnouncement( templateFile ) ), email, "", fromAddress,
fromName );
getLog().info( "Sent..." );
}
@@ -253,38 +238,24 @@
}
}
- protected boolean isTextFileExisting( String fileName )
- {
- boolean found = false;
-
- File f = new File( fileName );
-
- if ( f.exists() )
- {
- found = true;
- }
- return found;
- }
-
/**
* Read the announcement generated file.
*
- * @param fileName the filename to be read
+ * @param file the file to be read
* @return fileReader Return the FileReader
* @throws MojoExecutionException if the file could not be found
*/
- protected FileReader readAnnouncement( String fileName )
+ protected FileReader readAnnouncement( File file )
throws MojoExecutionException
{
FileReader fileReader;
try
{
- File file = new File( fileName );
fileReader = new FileReader( file );
}
catch ( FileNotFoundException fnfe )
{
- throw new MojoExecutionException( "File not found. " + fileName );
+ throw new MojoExecutionException( "File not found. " + file );
}
return fileReader;
}
@@ -451,12 +422,12 @@
this.mailSender = mailSender;
}
- public String getTemplateOutputDirectory()
+ public File getTemplateOutputDirectory()
{
return templateOutputDirectory;
}
- public void setTemplateOutputDirectory( String templateOutputDirectory )
+ public void setTemplateOutputDirectory( File templateOutputDirectory )
{
this.templateOutputDirectory = templateOutputDirectory;
}
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java Tue Feb 5 15:52:00 2008
@@ -19,12 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.changes.Action;
@@ -38,6 +32,12 @@
import org.apache.velocity.exception.VelocityException;
import org.codehaus.plexus.velocity.VelocityComponent;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+
/**
* Goal which generate the template for an announcement.
*
@@ -57,7 +57,7 @@
* @parameter expression="${project.build.directory}/announcement"
* @required
*/
- private String outputDirectory;
+ private File outputDirectory;
/**
* @parameter expression="${project.groupId}"
@@ -117,7 +117,7 @@
* @parameter expression="${basedir}/src/changes/changes.xml"
* @required
*/
- private String xmlPath;
+ private File xmlPath;
/**
* Name of the team that develops the artifact.
@@ -223,7 +223,7 @@
* @required
* @readonly
*/
- private String jiraXML;
+ private File jiraXML;
/**
* The maximum number of issues to include.
@@ -388,7 +388,7 @@
* @param template velocity template which will the context be merged
* @throws ResourceNotFoundException, VelocityException, IOException
*/
- public void processTemplate( Context context, String outputDirectory, String template )
+ public void processTemplate( Context context, File outputDirectory, String template )
throws ResourceNotFoundException, VelocityException, MojoExecutionException
{
File f;
@@ -437,7 +437,7 @@
{
JiraDownloader jiraDownloader = new JiraDownloader();
- File jiraXMLFile = new File( jiraXML );
+ File jiraXMLFile = jiraXML;
jiraDownloader.setLog( getLog() );
@@ -480,22 +480,22 @@
* accessors
*/
- public String getXmlPath()
+ public File getXmlPath()
{
return xmlPath;
}
- public void setXmlPath( String xmlPath )
+ public void setXmlPath( File xmlPath )
{
this.xmlPath = xmlPath;
}
- public String getOutputDirectory()
+ public File getOutputDirectory()
{
return outputDirectory;
}
- public void setOutputDirectory( String outputDirectory )
+ public void setOutputDirectory( File outputDirectory )
{
this.outputDirectory = outputDirectory;
}
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java Tue Feb 5 15:52:00 2008
@@ -19,18 +19,18 @@
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.util.FileUtils;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
/**
* Goal which creates a nicely formatted Changes Report in html format from a changes.xml file.
*
@@ -48,7 +48,7 @@
* @required
* @readonly
*/
- private String outputDirectory;
+ private File outputDirectory;
/**
* @parameter expression="${component.org.apache.maven.doxia.siterenderer.Renderer}"
@@ -70,7 +70,7 @@
* @parameter expression="${basedir}/src/changes/changes.xml"
* @required
*/
- private String xmlPath;
+ private File xmlPath;
/**
* Template string that is used to discover the URL to use to display an issue report.
@@ -95,8 +95,7 @@
public boolean canGenerateReport()
{
- File xmlFile = new File( xmlPath );
- return xmlFile.exists();
+ return xmlPath.isFile();
}
private void copyStaticResources()
@@ -171,7 +170,7 @@
protected String getOutputDirectory()
{
- return outputDirectory;
+ return outputDirectory.getAbsolutePath();
}
private ResourceBundle getBundle( Locale locale )
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java Tue Feb 5 15:52:00 2008
@@ -19,14 +19,14 @@
* under the License.
*/
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.apache.maven.doxia.util.HtmlTools;
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.util.HtmlTools;
import org.apache.maven.plugin.logging.Log;
-import org.apache.commons.lang.StringUtils;
+import java.io.File;
+import java.util.List;
+import java.util.ResourceBundle;
/**
* Generates a changes report.
@@ -45,7 +45,7 @@
{
}
- public ChangesReportGenerator( String xmlPath, Log log )
+ public ChangesReportGenerator( File xmlPath, Log log )
{
report = new ChangesXML( xmlPath, log );
}
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesXML.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesXML.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesXML.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesXML.java Tue Feb 5 15:52:00 2008
@@ -19,18 +19,17 @@
* under the License.
*/
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
import org.apache.maven.plugin.logging.Log;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* XML Parser for changes.xml files.
*
@@ -57,7 +56,7 @@
private String title;
- public ChangesXML( String xmlPath, Log log )
+ public ChangesXML( File xmlPath, Log log )
{
SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -65,7 +64,7 @@
{
SAXParser saxParser = factory.newSAXParser();
- saxParser.parse( new File( xmlPath ), this );
+ saxParser.parse( xmlPath, this );
}
catch ( Throwable t )
{
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java Tue Feb 5 15:52:00 2008
@@ -19,16 +19,16 @@
* under the License.
*/
-import java.io.File;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.apache.maven.settings.Settings;
+import java.io.File;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
/**
* Goal which downloads issues from the Issue Tracking System and generates a report.
*
@@ -46,7 +46,7 @@
* @required
* @readonly
*/
- private String outputDirectory;
+ private File outputDirectory;
/**
* Path to the JIRA XML file, which will be parsed.
@@ -55,7 +55,7 @@
* @required
* @readonly
*/
- private String jiraXmlPath;
+ private File jiraXmlPath;
/**
* Doxia Site Renderer.
@@ -261,7 +261,7 @@
{
jiraDownloader.doExecute();
- if ( new File( jiraXmlPath ).exists() )
+ if ( jiraXmlPath.isFile() )
{
report = new JiraReportGenerator( jiraXmlPath, columnNames );
@@ -313,7 +313,7 @@
protected String getOutputDirectory()
{
- return outputDirectory;
+ return outputDirectory.getAbsolutePath();
}
private ResourceBundle getBundle( Locale locale )
@@ -327,7 +327,7 @@
jira.setMavenProject( project );
- jira.setOutput( new File( jiraXmlPath ) );
+ jira.setOutput( jiraXmlPath );
jira.setNbEntries( maxEntries );
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java Tue Feb 5 15:52:00 2008
@@ -19,12 +19,13 @@
* under the License.
*/
-import java.util.List;
-import java.util.ResourceBundle;
-
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.reporting.MavenReportException;
+import java.io.File;
+import java.util.List;
+import java.util.ResourceBundle;
+
/**
* Generates a JIRA report.
*
@@ -67,7 +68,7 @@
}
- public JiraReportGenerator( String xmlPath, String columnNames )
+ public JiraReportGenerator( File xmlPath, String columnNames )
throws MavenReportException
{
jira = new JiraXML( xmlPath );
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java?rev=618829&r1=618828&r2=618829&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java Tue Feb 5 15:52:00 2008
@@ -19,17 +19,16 @@
* under the License.
*/
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* XML parser for <code>JiraIssue</code>s. This works on an XML file downloaded
* from JIRA and creates a List of issues that is exposed to the user of the
@@ -48,7 +47,7 @@
private JiraIssue issue;
- public JiraXML( String xmlPath )
+ public JiraXML( File xmlPath )
{
SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -58,7 +57,7 @@
{
SAXParser saxParser = factory.newSAXParser();
- saxParser.parse( new File( xmlPath ), this );
+ saxParser.parse( xmlPath, this );
}
catch ( Throwable t )
{