Hi Dennis, Like Benjamin wrote in the issue, a new parameter should not be necessary since XML is declaring encoding: you just have tu use ReaderFactory.newXmlReader() to avoid relying on the parser to detect encoding.
Such an argument is usefull only if Jira generates wrong XML, with content not consistent with encoding declared in its prolog: such a case would be a bug in Jira. Don't hesitate to ping me if this isn't clear (I know, encoding stays bizarre for a lot of people :) ) Regards, Hervé Le samedi 1 janvier 2011, [email protected] a écrit : > Author: dennisl > Date: Sat Jan 1 17:41:56 2011 > New Revision: 1054263 > > URL: http://svn.apache.org/viewvc?rev=1054263&view=rev > Log: > [MCHANGES-144] Add configuration if the encoding of JIRA xml file is not > UTF-8. > > Modified: > > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/announcement/AnnouncementMojo.java > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/jira/JiraMojo.java > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/jira/JiraXML.java > > Modified: > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/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=10 > 54263&r1=1054262&r2=1054263&view=diff > ========================================================================== > ==== --- > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/announcement/AnnouncementMojo.java (original) +++ > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/announcement/AnnouncementMojo.java Sat Jan 1 17:41:56 2011 @@ -247,7 > +247,7 @@ public class AnnouncementMojo > private String resolutionIds; > > /** > - * The path of the XML file of JIRA-announcements to be parsed. > + * Path to the JIRA XML file, which will be parsed. > * > * @parameter > expression="${project.build.directory}/jira-announcement.xml" * @required > @@ -256,6 +256,15 @@ public class AnnouncementMojo > private File jiraXML; > > /** > + * The encoding used in the JIRA XML file. You only need to change > this if + * your JIRA server is returning responses in an encoding > other than UTF-8. + * > + * @parameter default-value="UTF-8" > expression="${changes.jiraXmlEncoding}" + * @since 2.4 > + */ > + private String jiraXmlEncoding; > + > + /** > * The maximum number of issues to fetch from JIRA. > * <p> > * <b>Note:</b> In versions 2.0-beta-3 and earlier this parameter was > @@ -607,7 +616,7 @@ public class AnnouncementMojo > > if ( jiraXMLFile.exists() ) > { > - JiraXML jiraParser = new JiraXML( jiraXMLFile ); > + JiraXML jiraParser = new JiraXML( jiraXMLFile, > jiraXmlEncoding ); > > List issues = jiraParser.getIssueList(); > > > Modified: > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/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=1054263&r1=1054262 > &r2=1054263&view=diff > ========================================================================== > ==== --- > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/jira/JiraMojo.java (original) +++ > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/jira/JiraMojo.java Sat Jan 1 17:41:56 2011 @@ -42,13 +42,22 @@ public > class JiraMojo > /** > * Path to the JIRA XML file, which will be parsed. > * > - * @parameter expression="${project.build.directory}/jira-results.xml > " + * @parameter > expression="${project.build.directory}/jira-results.xml" * @required > * @readonly > */ > private File jiraXmlPath; > > /** > + * The encoding used in the JIRA XML file. You only need to change > this if + * your JIRA server is returning responses in an encoding > other than UTF-8. + * > + * @parameter default-value="UTF-8" > expression="${changes.jiraXmlEncoding}" + * @since 2.4 > + */ > + private String jiraXmlEncoding; > + > + /** > * Settings XML configuration. > * > * @parameter expression="${settings}" > @@ -248,7 +257,7 @@ public class JiraMojo > > if ( jiraXmlPath.isFile() ) > { > - JiraXML jira = new JiraXML( jiraXmlPath ); > + JiraXML jira = new JiraXML( jiraXmlPath, jiraXmlEncoding > ); List issueList = jira.getIssueList(); > > report = new JiraReportGenerator( columnNames ); > > Modified: > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/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=1054263&r1=1054262& > r2=1054263&view=diff > ========================================================================== > ==== --- > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/jira/JiraXML.java (original) +++ > maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/pl > ugin/jira/JiraXML.java Sat Jan 1 17:41:56 2011 @@ -20,18 +20,16 @@ package > org.apache.maven.plugin.jira; > */ > > import java.io.File; > +import java.io.FileInputStream; > +import java.io.IOException; > import java.util.ArrayList; > -import java.util.HashMap; > -import java.util.Iterator; > import java.util.List; > -import java.util.Map; > > import javax.xml.parsers.SAXParser; > import javax.xml.parsers.SAXParserFactory; > > -import org.apache.maven.plugins.changes.model.Action; > -import org.apache.maven.plugins.changes.model.Release; > import org.xml.sax.Attributes; > +import org.xml.sax.InputSource; > import org.xml.sax.SAXException; > import org.xml.sax.helpers.DefaultHandler; > > @@ -53,9 +51,10 @@ public class JiraXML > > private JiraIssue issue; > > - public JiraXML( File xmlPath ) > + public JiraXML( File xmlPath, String encoding ) > { > SAXParserFactory factory = SAXParserFactory.newInstance(); > + FileInputStream fis = null; > > issueList = new ArrayList(); > > @@ -63,12 +62,30 @@ public class JiraXML > { > SAXParser saxParser = factory.newSAXParser(); > > - saxParser.parse( xmlPath, this ); > + fis = new FileInputStream( xmlPath ); > + InputSource inputSource = new InputSource( fis ); > + inputSource.setEncoding( encoding ); > + > + saxParser.parse( inputSource, this ); > } > catch ( Throwable t ) > { > t.printStackTrace(); > } > + finally > + { > + if ( fis != null ) > + { > + try > + { > + fis.close(); > + } > + catch ( IOException e ) > + { > + // Ignore > + } > + } > + } > } > > public void startElement( String namespaceURI, String sName, String > qName, Attributes attrs ) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
