[jboss-svn-commits] JBL Code SVN: r25604 - labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 11 19:56:28 EDT 2009
Author: steve.ebersole at jboss.com
Date: 2009-03-11 19:56:28 -0400 (Wed, 11 Mar 2009)
New Revision: 25604
Modified:
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java
Log:
MPJDOCBOOK-23 - allow easy disabling of processing translations from profiles etc
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java 2009-03-11 20:32:04 UTC (rev 25603)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/AbstractDocBookMojo.java 2009-03-11 23:56:28 UTC (rev 25604)
@@ -215,6 +215,15 @@
// translation-specific config setting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
+ * Should we ignore translations? This is useful for temporarily suspending processing of translations from a
+ * profile or other environment specific means. Note that this setting only affects the docbook processing
+ * phases, not the PO/POT management goals.
+ *
+ * @parameter default-value="false"
+ */
+ protected boolean ignoreTranslations;
+
+ /**
* The locale of the master translation.
*
* @parameter default-value="en-US"
@@ -255,6 +264,14 @@
private File resolvedMasterSourceDirectory;
+ protected boolean excludeIngoredTranslationsFromPublishSources() {
+ return false;
+ }
+
+ protected boolean excludeIngoredTranslationsFromI18nSources() {
+ return false;
+ }
+
/**
* The override method to perform the actual processing of the
* mojo.
@@ -395,18 +412,52 @@
ArrayList<PublishingSource> descriptors = new ArrayList<PublishingSource>();
descriptors.add( getMasterTranslationDescriptor() );
- for ( String locale : translations ) {
- descriptors.add( new TranslationDescriptor( parseLocale( locale ) ) );
+ Locale requestedLocale = getRequestedLocale();
+ boolean skipAllTranslations = ignoreTranslations && excludeIngoredTranslationsFromPublishSources();
+
+ if ( skipAllTranslations ) {
+ getLog().info( "Skipping all translations" );
}
+ else {
+ for ( String localeStr : translations ) {
+ final Locale locale = parseLocale( localeStr );
+ final boolean skipThisLocale = requestedLocale != null
+ && !requestedLocale.equals( locale )
+ && excludeIngoredTranslationsFromPublishSources();
+ if ( skipThisLocale ) {
+ getLog().info( "skipping non-requested lang [" + localeStr + "]" );
+ continue;
+ }
+ descriptors.add( new TranslationDescriptor( locale ) );
+ }
+ }
return descriptors;
}
protected List<I18nSource> getI18nSources() {
ArrayList<I18nSource> descriptors = new ArrayList<I18nSource>();
- for ( String locale : translations ) {
- descriptors.add( new TranslationDescriptor( parseLocale( locale ) ) );
+
+ Locale requestedLocale = getRequestedLocale();
+ boolean skipAllTranslations = ignoreTranslations && excludeIngoredTranslationsFromI18nSources();
+
+ if ( skipAllTranslations ) {
+ getLog().info( "Skipping all translations" );
}
+ else {
+ for ( String localeStr : translations ) {
+ final Locale locale = parseLocale( localeStr );
+ final boolean skipThisLocale = requestedLocale != null
+ && !requestedLocale.equals( locale )
+ && excludeIngoredTranslationsFromPublishSources();
+ if ( skipThisLocale ) {
+ getLog().info( "skipping non-requested lang [" + localeStr + "]" );
+ continue;
+ }
+ descriptors.add( new TranslationDescriptor( locale ) );
+ }
+ }
+
return descriptors;
}
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java 2009-03-11 20:32:04 UTC (rev 25603)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/GenerationMojo.java 2009-03-11 23:56:28 UTC (rev 25604)
@@ -21,12 +21,10 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.jboss.maven.plugins.jdocbook;
import java.io.File;
import java.util.List;
-import java.util.Locale;
import org.apache.maven.artifact.Artifact;
import org.jboss.jdocbook.profile.ProfilerFactory;
@@ -48,7 +46,17 @@
* @author Steve Ebersole
*/
public class GenerationMojo extends AbstractDocBookMojo {
+ @Override
+ protected boolean excludeIngoredTranslationsFromPublishSources() {
+ return true;
+ }
+ @Override
+ protected boolean excludeIngoredTranslationsFromI18nSources() {
+ return true;
+ }
+
+ @Override
protected void process(FormatPlan[] plans) throws XSLTException, RenderingException {
if ( !sourceDirectory.exists() ) {
getLog().info( "sourceDirectory [" + sourceDirectory.getAbsolutePath() + "] did not exist" );
@@ -56,7 +64,10 @@
}
if ( !workDirectory.exists() ) {
- workDirectory.mkdirs();
+ boolean created = workDirectory.mkdirs();
+ if ( !created ) {
+ options.getLog().info( "Unable to create work directory {}", workDirectory.getAbsolutePath() );
+ }
}
if ( options.getDocbookVersion() == null ) {
@@ -77,16 +88,11 @@
}
RendererFactory rendererFactory = new RendererFactory( options );
- Locale requestedLocale = getRequestedLocale();
String requestedFormat = getRequestedFormat();
List<PublishingSource> sources = getPublishingSources();
for ( PublishingSource source : sources ) {
- if ( requestedLocale != null && !requestedLocale.equals( source.getLocale() ) ) {
- getLog().info( "skipping non-requested lang [" + stringify( source.getLocale() ) + "]" );
- continue;
- }
-
+ options.getLog().info( "Starting generation " + stringify( source.getLocale() ) );
File sourceFile = source.resolveDocumentFile();
if ( !sourceFile.exists() ) {
getLog().info( "Source document [" + sourceFile.getAbsolutePath() + "] did not exist; skipping" );
@@ -94,8 +100,11 @@
}
File publishingDirectory = source.resolvePublishingDirectory();
- if ( !publishingDirectory.exists() ) {
- publishingDirectory.mkdirs();
+ if ( ! publishingDirectory.exists() ) {
+ boolean created = publishingDirectory.mkdirs();
+ if ( !created ) {
+ options.getLog().info( "Unable to create publishing directory {}", publishingDirectory.getAbsolutePath() );
+ }
}
final String lang = stringify( source.getLocale() );
@@ -104,6 +113,7 @@
boolean hasBeenProfiled = false;
for ( FormatPlan plan : plans ) {
+ options.getLog().info( "Processing " + lang + " -> " + plan.getName() );
if ( requestedFormat != null && !requestedFormat.equals( plan.getName() ) ) {
getLog().info( "skipping non-requested format [" + plan.getName() + "]" );
continue;
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java 2009-03-11 20:32:04 UTC (rev 25603)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/PackageMojo.java 2009-03-11 23:56:28 UTC (rev 25604)
@@ -50,6 +50,7 @@
/**
* {@inheritDoc}
*/
+ @Override
protected void process(FormatPlan[] formatPlans) throws RenderingException, XSLTException {
File projectArtifactFile = new File( project.getBuild().getOutputDirectory(), project.getBuild().getFinalName() + ".war" );
JarArchiver archiver = new JarArchiver();
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java 2009-03-11 20:32:04 UTC (rev 25603)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/plugins/jdocbook/TranslationMojo.java 2009-03-11 23:56:28 UTC (rev 25604)
@@ -21,11 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.jboss.maven.plugins.jdocbook;
-import java.util.Locale;
-
import org.jboss.jdocbook.JDocBookProcessException;
import org.jboss.jdocbook.i18n.Factory;
@@ -38,19 +35,27 @@
* @author Steve Ebersole
*/
public class TranslationMojo extends AbstractDocBookMojo {
+ @Override
+ protected boolean excludeIngoredTranslationsFromPublishSources() {
+ return true;
+ }
+
+ @Override
+ protected boolean excludeIngoredTranslationsFromI18nSources() {
+ return true;
+ }
+
+ @Override
protected void doExecute() throws JDocBookProcessException {
- Locale requestedLocale = getRequestedLocale();
MasterTranslationDescriptor masterTranslationDescriptor = getMasterTranslationDescriptor();
for ( I18nSource source : getI18nSources() ) {
- if ( requestedLocale == null || requestedLocale.equals( source.getLocale() ) ) {
- getLog().info( "Processing translation [" + stringify( source.getLocale() ) + "]" );
- Factory.getTranslationBuilder().buildTranslation(
- masterTranslationDescriptor.resolveDocumentFile(),
- source.resolvePoDirectory(),
- source.resolveTranslatedXmlDirectory(),
- options
- );
- }
+ getLog().info( "Processing translation [" + stringify( source.getLocale() ) + "]" );
+ Factory.getTranslationBuilder().buildTranslation(
+ masterTranslationDescriptor.resolveDocumentFile(),
+ source.resolvePoDirectory(),
+ source.resolveTranslatedXmlDirectory(),
+ options
+ );
}
}
}
More information about the jboss-svn-commits
mailing list