You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by vs...@apache.org on 2009/02/04 14:12:42 UTC
svn commit: r740726 - in /maven/doxia/doxia/trunk/doxia-maven-plugin: pom.xml
src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java
Author: vsiveton
Date: Wed Feb 4 13:12:41 2009
New Revision: 740726
URL: http://svn.apache.org/viewvc?rev=740726&view=rev
Log:
o add more parameters: locale and input/output encoding due to r740705
Modified:
maven/doxia/doxia/trunk/doxia-maven-plugin/pom.xml
maven/doxia/doxia/trunk/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java
Modified: maven/doxia/doxia/trunk/doxia-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-maven-plugin/pom.xml?rev=740726&r1=740725&r2=740726&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-maven-plugin/pom.xml (original)
+++ maven/doxia/doxia/trunk/doxia-maven-plugin/pom.xml Wed Feb 4 13:12:41 2009
@@ -54,6 +54,11 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-doxia-tools</artifactId>
+ <version>1.0.1</version>
+ </dependency>
</dependencies>
<reporting>
Modified: maven/doxia/doxia/trunk/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java?rev=740726&r1=740725&r2=740726&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java (original)
+++ maven/doxia/doxia/trunk/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java Wed Feb 4 13:12:41 2009
@@ -24,16 +24,19 @@
import org.apache.maven.doxia.book.InvalidBookDescriptorException;
import org.apache.maven.doxia.book.model.BookModel;
import org.apache.maven.doxia.book.services.validation.ValidationResult;
+import org.apache.maven.doxia.tools.SiteTool;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
/**
* A Mojo to create books in different output formats.
@@ -61,6 +64,13 @@
*/
private BookDoxia bookDoxia;
+ /**
+ * SiteTool.
+ *
+ * @component
+ */
+ protected SiteTool siteTool;
+
// ----------------------------------------------------------------------
// Mojo parameters
// ----------------------------------------------------------------------
@@ -69,6 +79,7 @@
* A list of books.
*
* @parameter
+ * @required
*/
private List books;
@@ -86,6 +97,28 @@
*/
private File generatedDocs;
+ /**
+ * A comma separated list of locales supported by Maven. The first valid token will be the default Locale
+ * for this instance of the Java Virtual Machine.
+ *
+ * @parameter expression="${locales}"
+ */
+ protected String locales;
+
+ /**
+ * Specifies the input encoding.
+ *
+ * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
+ */
+ private String inputEncoding;
+
+ /**
+ * Specifies the output encoding.
+ *
+ * @parameter expression="${outputEncoding}" default-value="${project.reporting.outputEncoding}"
+ */
+ private String outputEncoding;
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -207,28 +240,64 @@
// Render the book in all the formats
// -----------------------------------------------------------------------
- for ( Iterator j = book.getFormats().iterator(); j.hasNext(); )
- {
- Format format = (Format) j.next();
+ List localesList = siteTool.getAvailableLocales( locales );
- File outputDirectory = new File( generatedDocs, format.getId() );
- File directory = new File( outputDirectory, bookModel.getId() );
+ // Default is first in the list
+ Locale defaultLocale = (Locale) localesList.get( 0 );
+ Locale.setDefault( defaultLocale );
- try
- {
- bookDoxia.renderBook( bookModel, format.getId(), files, directory );
- }
- catch ( BookDoxiaException e )
+ for ( Iterator iterator = localesList.iterator(); iterator.hasNext(); )
+ {
+ Locale locale = (Locale) iterator.next();
+
+ for ( Iterator j = book.getFormats().iterator(); j.hasNext(); )
{
- throw new MojoExecutionException(
- "Error while generating book in format '" + format.getId() + "'.",
- e );
+ Format format = (Format) j.next();
+
+ File outputDirectory = new File( generatedDocs, format.getId() );
+ File directory = new File( outputDirectory + "/" + locale.toString(), bookModel.getId() );
+
+ if ( locale.equals( defaultLocale ) )
+ {
+ directory = new File( outputDirectory, bookModel.getId() );
+ }
+
+ try
+ {
+ bookDoxia.renderBook( bookModel, format.getId(), files, directory, locale,
+ getInputEncoding(), getOutputEncoding() );
+ }
+ catch ( BookDoxiaException e )
+ {
+ throw new MojoExecutionException( "Error while generating book in format '"
+ + format.getId() + "'.", e );
+ }
}
}
}
}
/**
+ * Gets the input files encoding.
+ *
+ * @return The input files encoding, never <code>null</code>.
+ */
+ protected String getInputEncoding()
+ {
+ return ( inputEncoding == null ) ? ReaderFactory.ISO_8859_1 : inputEncoding;
+ }
+
+ /**
+ * Gets the effective reporting output files encoding.
+ *
+ * @return The effective reporting output file encoding, never <code>null</code>.
+ */
+ protected String getOutputEncoding()
+ {
+ return ( outputEncoding == null ) ? ReaderFactory.UTF_8 : outputEncoding;
+ }
+
+ /**
* Returns a formatted message of a ValidationResult.
*
* @param result the ValidationResult to format.