Permalink
Browse files

Merge branches 'CoreMedia' and 'flexmojos-4.x' into flexmojos-4.x

  • Loading branch information...
2 parents 109921b + 03fc13a commit 9a0e5a9372db7c39bbb0d3c7da36a1ed6d960f05 @velo velo committed May 3, 2011
@@ -1,131 +1,137 @@
-package org.sonatype.flexmojos.compiler;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.sonatype.flexmojos.compiler.command.Command;
-import org.sonatype.flexmojos.compiler.command.CommandUtil;
-import org.sonatype.flexmojos.compiler.command.Result;
-import org.sonatype.flexmojos.compiler.util.FlexCompilerArgumentParser;
-
-import flex2.tools.ASDoc;
-import flex2.tools.Compc;
-import flex2.tools.DigestTool;
-import flex2.tools.Mxmlc;
-import flex2.tools.Optimizer;
-
-@Component( role = FlexCompiler.class )
-public class DefaultFlexCompiler
- extends AbstractLogEnabled
- implements FlexCompiler
-{
-
- @Requirement
- private FlexCompilerArgumentParser parser;
-
- public Result compileSwc( final ICompcConfiguration configuration, boolean sychronize )
- throws Exception
- {
- return CommandUtil.execute( new Command()
- {
- public void command()
- throws Exception
- {
- String[] args = parser.parseArguments( configuration, ICompcConfiguration.class );
- logArgs( args );
- Compc.compc( args );
- }
- }, sychronize );
- }
-
- public Result compileSwf( MxmlcConfigurationHolder cfgHolder, boolean sychronize )
- throws Exception
- {
- final List<String> argsList =
- parser.getArgumentsList( cfgHolder.configuration, ICommandLineConfiguration.class );
- if ( cfgHolder.sourceFile != null )
- {
- argsList.add( cfgHolder.sourceFile.getAbsolutePath() );
- }
- return CommandUtil.execute( new Command()
- {
- public void command()
- {
- String[] args = argsList.toArray( new String[argsList.size()] );
- logArgs( args );
- Mxmlc.mxmlc( args );
- }
- }, sychronize );
- }
-
- public Result asdoc( final IASDocConfiguration configuration, boolean sychronize )
- throws Exception
- {
- return CommandUtil.execute( new Command()
- {
- public void command()
- {
- String[] args = parser.parseArguments( configuration, IASDocConfiguration.class );
- logArgs( args );
- ASDoc.asdoc( args );
- }
- }, sychronize );
- }
-
- public Result digest( final IDigestConfiguration configuration, boolean sychronize )
- throws Exception
- {
- return CommandUtil.execute( new Command()
- {
- public void command()
- throws Exception
- {
- String[] args = parser.parseArguments( configuration, IDigestConfiguration.class );
- logArgs( args );
- Method m = DigestTool.class.getDeclaredMethod( "digestTool", String[].class );
- m.setAccessible( true );
- m.invoke( null, new Object[] { args } );
- }
- }, sychronize );
- }
-
- public Result optimize( final IOptimizerConfiguration configuration, boolean sychronize )
- throws Exception
- {
- return CommandUtil.execute( new Command()
- {
- public void command()
- throws Exception
- {
- String[] args = parser.parseArguments( configuration, IOptimizerConfiguration.class );
- logArgs( args );
- Optimizer.main( args );
- }
- }, sychronize );
- }
-
- private void logArgs( String[] args )
- {
- if ( getLogger().isDebugEnabled() )
- {
- StringBuilder sb = new StringBuilder();
- for ( String arg : args )
- {
- if ( arg.startsWith( "-" ) )
- {
- sb.append( '\n' );
- }
- sb.append( arg );
- sb.append( ' ' );
- }
- synchronized ( getLogger() )
- {
- getLogger().debug( "Compilation arguments:" + sb );
- }
- }
- }
-
-}
+package org.sonatype.flexmojos.compiler;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.sonatype.flexmojos.compiler.command.Command;
+import org.sonatype.flexmojos.compiler.command.CommandUtil;
+import org.sonatype.flexmojos.compiler.command.Result;
+import org.sonatype.flexmojos.compiler.util.FlexCompilerArgumentParser;
+
+import flex2.tools.ASDoc;
+import flex2.tools.Compc;
+import flex2.tools.DigestTool;
+import flex2.tools.Mxmlc;
+import flex2.tools.Optimizer;
+
+@Component( role = FlexCompiler.class )
+public class DefaultFlexCompiler
+ extends AbstractLogEnabled
+ implements FlexCompiler
+{
+
+ @Requirement
+ private FlexCompilerArgumentParser parser;
+
+ public Result compileSwc( final ICompcConfiguration configuration, boolean sychronize )
+ throws Exception
+ {
+ return CommandUtil.execute( new Command()
+ {
+ public void command()
+ throws Exception
+ {
+ String[] args = parser.parseArguments( configuration, ICompcConfiguration.class );
+ logArgs( args );
+ Compc.compc( args );
+ }
+ }, sychronize );
+ }
+
+ public Result compileSwf( MxmlcConfigurationHolder cfgHolder, boolean sychronize )
+ throws Exception
+ {
+ final List<String> argsList =
+ parser.getArgumentsList( cfgHolder.configuration, ICommandLineConfiguration.class );
+ if ( cfgHolder.sourceFile != null )
+ {
+ argsList.add( cfgHolder.sourceFile.getAbsolutePath() );
+ }
+ return CommandUtil.execute( new Command()
+ {
+ public void command()
+ {
+ String[] args = argsList.toArray( new String[argsList.size()] );
+ logArgs( args );
+ Mxmlc.mxmlc( args );
+ }
+ }, sychronize );
+ }
+
+ public Result asdoc( final IASDocConfiguration configuration, boolean sychronize )
+ throws Exception
+ {
+ return CommandUtil.execute( new Command()
+ {
+ public void command()
+ {
+ String[] args = parser.parseArguments( configuration, IASDocConfiguration.class );
+ logArgs( args );
+ // Force the XML Transformer to the Xalan version that comes with Flex
+ String defaultTransfomer = System.getProperty( "javax.xml.transform.TransformerFactory" );
+ System.setProperty( "javax.xml.transform.TransformerFactory",
+ "org.apache.xalan.processor.TransformerFactoryImpl" );
+ ASDoc.main( args );
+ // and set it back to the default
+ System.setProperty( "javax.xml.transform.TransformerFactory", defaultTransfomer );
+ }
+ }, sychronize );
+ }
+
+ public Result digest( final IDigestConfiguration configuration, boolean sychronize )
+ throws Exception
+ {
+ return CommandUtil.execute( new Command()
+ {
+ public void command()
+ throws Exception
+ {
+ String[] args = parser.parseArguments( configuration, IDigestConfiguration.class );
+ logArgs( args );
+ Method m = DigestTool.class.getDeclaredMethod( "digestTool", String[].class );
+ m.setAccessible( true );
+ m.invoke( null, new Object[] { args } );
+ }
+ }, sychronize );
+ }
+
+ public Result optimize( final IOptimizerConfiguration configuration, boolean sychronize )
+ throws Exception
+ {
+ return CommandUtil.execute( new Command()
+ {
+ public void command()
+ throws Exception
+ {
+ String[] args = parser.parseArguments( configuration, IOptimizerConfiguration.class );
+ logArgs( args );
+ Optimizer.main( args );
+ }
+ }, sychronize );
+ }
+
+ private void logArgs( String[] args )
+ {
+ if ( getLogger().isDebugEnabled() )
+ {
+ StringBuilder sb = new StringBuilder();
+ for ( String arg : args )
+ {
+ if ( arg.startsWith( "-" ) )
+ {
+ sb.append( '\n' );
+ }
+ sb.append( arg );
+ sb.append( ' ' );
+ }
+ synchronized ( getLogger() )
+ {
+ getLogger().debug( "Compilation arguments:" + sb );
+ }
+ }
+ }
+
+}

0 comments on commit 9a0e5a9

Please sign in to comment.