You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2008/11/04 00:19:55 UTC
svn commit: r710219 - in
/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin:
announcement/AnnouncementMojo.java changes/ChangesXML.java
Author: olamy
Date: Mon Nov 3 15:19:54 2008
New Revision: 710219
URL: http://svn.apache.org/viewvc?rev=710219&view=rev
Log:
[MCHANGES-71] need add template encoding to announcement-generate
Modified:
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/ChangesXML.java
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=710219&r1=710218&r2=710219&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 Mon Nov 3 15:19:54 2008
@@ -20,7 +20,9 @@
*/
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileWriter;
+import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
@@ -33,11 +35,14 @@
import org.apache.maven.plugins.changes.model.Release;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
+import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.VelocityException;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.velocity.VelocityComponent;
/**
@@ -263,6 +268,14 @@
* @since 2.1
*/
private String jiraPassword;
+
+ /**
+ * The template encoding.
+ *
+ * @parameter expression="${changes.templateEncoding}" default-value="${project.build.sourceEncoding}"
+ * @since 2.1
+ */
+ private String templateEncoding;
//=======================================//
// announcement-generate execution //
@@ -437,13 +450,26 @@
f.getParentFile().mkdirs();
}
- Writer writer = new FileWriter( f );
+
VelocityEngine engine = velocity.getEngine();
engine.setApplicationAttribute( "baseDirectory", basedir );
- engine.mergeTemplate( templateDirectory + "/" + template, context, writer );
+ if ( StringUtils.isEmpty( templateEncoding ) )
+ {
+ templateEncoding = ReaderFactory.FILE_ENCODING;
+ 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 );
+
+ Template velocityTemplate = engine.getTemplate( templateDirectory + "/" + template, templateEncoding );
+
+ velocityTemplate.merge( context, writer );
writer.flush();
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=710219&r1=710218&r2=710219&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 Mon Nov 3 15:19:54 2008
@@ -76,7 +76,7 @@
{
if ( properties.getAuthor() != null )
{
- this.author =properties.getAuthor().getName();
+ this.author = properties.getAuthor().getName();
this.authorEmail = properties.getAuthor().getName();
}
this.title = properties.getTitle();