[jboss-svn-commits] JBL Code SVN: r25597 - in labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin: src/main/java/org/jboss/jdocbook/i18n/gettext and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 11 13:57:23 EDT 2009
Author: steve.ebersole at jboss.com
Date: 2009-03-11 13:57:23 -0400 (Wed, 11 Mar 2009)
New Revision: 25597
Removed:
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/maven/shared/process/
Modified:
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java
labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java
Log:
MPJDOCBOOK-22 - migrate to use of commons-exec instead of hand-rolled stuff
Property changes on: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin
___________________________________________________________________
Name: svn:ignore
- target
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
.clover
+ target
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
.classpath
.project
.settings
.nbattrs
*.log
.clover
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml 2009-03-11 17:16:16 UTC (rev 25596)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml 2009-03-11 17:57:23 UTC (rev 25597)
@@ -12,10 +12,11 @@
<artifactId>maven-jdocbook-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>2.1.3-SNAPSHOT</version>
+
<name>jDocBook Maven Plugin</name>
<description>This plugin adds support for DocBook handling to Maven.</description>
+ <inceptionYear>2007</inceptionYear>
- <inceptionYear>2007</inceptionYear>
<organization>
<name>JBoss, a division of Red Hat, Inc</name>
<url>http://jboss.org/</url>
@@ -77,7 +78,6 @@
</plugins>
</build>
-
<reporting>
<plugins>
<plugin>
@@ -100,13 +100,19 @@
</reporting>
<dependencies>
- <!-- DocBook (this is the version used, unless user project imports one...) -->
<dependency>
+ <!-- DocBook (this is the version used, unless user project imports one...) -->
<groupId>net.sf.docbook</groupId>
<artifactId>docbook</artifactId>
<version>1.72.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-exec</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
<!-- XML APIs -->
<dependency>
<groupId>xml-resolver</groupId>
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java 2009-03-11 17:16:16 UTC (rev 25596)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PoSynchronizerImpl.java 2009-03-11 17:57:23 UTC (rev 25597)
@@ -20,12 +20,11 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
-
package org.jboss.jdocbook.i18n.gettext;
import java.io.File;
+import java.io.IOException;
import java.util.Locale;
import org.jboss.jdocbook.JDocBookProcessException;
@@ -34,7 +33,9 @@
import org.jboss.jdocbook.util.FileUtils;
import org.jboss.jdocbook.util.I18nUtils;
import org.jboss.jdocbook.util.VCSDirectoryExclusionFilter;
-import org.jboss.maven.shared.process.Executor;
+import org.jboss.jdocbook.util.LocaleUtils;
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
/**
* Implementation of the {@link PoSynchronizer} contract based on system calls
@@ -84,17 +85,41 @@
return;
}
- final String cmd;
+ final String translationLocaleString = LocaleUtils.render( translationLocale, options.getLocaleSeparator() );
+
+ CommandLine commandLine;
if ( translation.exists() ) {
- cmd = "msgmerge --quiet --backup=none --update " + FileUtils.resolveFullPathName( translation )
- + " " + FileUtils.resolveFullPathName( template );
+ commandLine = CommandLine.parse( "msgmerge" );
+ commandLine.addArgument( "--quiet" );
+ commandLine.addArgument( "--update" );
+ commandLine.addArgument( "--backup=none" );
+ commandLine.addArgument( FileUtils.resolveFullPathName( translation ) );
+ commandLine.addArgument( FileUtils.resolveFullPathName( template ) );
}
else {
- translation.getParentFile().mkdirs();
- cmd = "msginit --no-translator -l " + translationLocale
- + " -i " + FileUtils.resolveFullPathName( template )
- + " -o " + FileUtils.resolveFullPathName( translation );
+ if ( ! translation.getParentFile().exists() ) {
+ boolean created = translation.getParentFile().mkdirs();
+ if ( ! created ) {
+ options.getLog().info( "Unable to create translation directory : {}", translationLocaleString );
+ }
+ }
+ commandLine = CommandLine.parse( "msginit" );
+ commandLine.addArgument( "--no-translator" );
+ commandLine.addArgument( "--locale=" + LocaleUtils.render( translationLocale, options.getLocaleSeparator() ) );
+ commandLine.addArgument( "-i" );
+ commandLine.addArgument( FileUtils.resolveFullPathName( template ) );
+ commandLine.addArgument( "-o" );
+ commandLine.addArgument( FileUtils.resolveFullPathName( translation ) );
}
- Executor.execute( cmd );
+
+ options.getLog().info( "po-synch -> " + commandLine.toString() );
+
+ DefaultExecutor executor = new DefaultExecutor();
+ try {
+ executor.execute( commandLine );
+ }
+ catch ( IOException e ) {
+ throw new JDocBookProcessException( "Error synchronizing PO file [" + template.getName() + "] for " + translationLocaleString, e );
+ }
}
}
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java 2009-03-11 17:16:16 UTC (rev 25596)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/PotSynchronizerImpl.java 2009-03-11 17:57:23 UTC (rev 25597)
@@ -35,7 +35,9 @@
import org.jboss.jdocbook.util.FileUtils;
import org.jboss.jdocbook.util.I18nUtils;
import org.jboss.jdocbook.util.XIncludeHelper;
-import org.jboss.maven.shared.process.Executor;
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.PumpStreamHandler;
/**
* Implementation of the {@link PotSynchronizer} contract based on system calls
@@ -79,18 +81,28 @@
return;
}
- potFile.getParentFile().mkdirs();
+ if ( !potFile.getParentFile().exists() ) {
+ boolean created = potFile.getParentFile().mkdirs();
+ if ( !created ) {
+ options.getLog().info( "Unable to generate POT directory {}" + FileUtils.resolveFullPathName( potFile.getParentFile() ) );
+ }
+ }
executeXml2pot( masterFile, potFile, options );
}
private void executeXml2pot(File masterFile, File potFile, Options options) {
- final String cmd = "xml2pot " + FileUtils.resolveFullPathName( masterFile );
+ CommandLine commandLine = CommandLine.parse( "xml2pot" );
+ commandLine.addArgument( FileUtils.resolveFullPathName( masterFile ) );
+ DefaultExecutor executor = new DefaultExecutor();
+
try {
final FileOutputStream xmlStream = new FileOutputStream( potFile );
+ PumpStreamHandler streamDirector = new PumpStreamHandler( xmlStream, System.err );
+ executor.setStreamHandler( streamDirector );
try {
options.getLog().trace( "updating POT file {0}", potFile );
- Executor.execute( cmd, xmlStream );
+ executor.execute( commandLine );
}
finally {
try {
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java 2009-03-11 17:16:16 UTC (rev 25596)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/TranslationBuilderImpl.java 2009-03-11 17:57:23 UTC (rev 25597)
@@ -34,7 +34,9 @@
import org.jboss.jdocbook.util.FileUtils;
import org.jboss.jdocbook.util.I18nUtils;
import org.jboss.jdocbook.util.XIncludeHelper;
-import org.jboss.maven.shared.process.Executor;
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.PumpStreamHandler;
/**
* Implementation of the {@link org.jboss.jdocbook.i18n.TranslationBuilder} contract based on system calls
@@ -95,13 +97,24 @@
return;
}
- translatedFile.getParentFile().mkdirs();
- final String cmd = "po2xml " + FileUtils.resolveFullPathName( masterFile ) + " " + FileUtils.resolveFullPathName( poFile );
+ if ( ! translatedFile.getParentFile().exists() ) {
+ boolean created = translatedFile.getParentFile().mkdirs();
+ if ( ! created ) {
+ options.getLog().info( "Unable to create directories for translation" );
+ }
+ }
+
+ CommandLine commandLine = CommandLine.parse( "po2xml" );
+ commandLine.addArgument( FileUtils.resolveFullPathName( masterFile ) );
+ commandLine.addArgument( FileUtils.resolveFullPathName( poFile ) );
+
try {
final FileOutputStream xmlStream = new FileOutputStream( translatedFile );
+ DefaultExecutor executor = new DefaultExecutor();
try {
- options.getLog().trace( "<execute>" + cmd + "</execution>" );
- Executor.execute( cmd, xmlStream );
+ PumpStreamHandler streamDirector = new PumpStreamHandler( xmlStream, System.err );
+ executor.setStreamHandler( streamDirector );
+ executor.execute( commandLine );
}
finally {
try {
More information about the jboss-svn-commits
mailing list