Jar Package Download, http://download.csdn.net/source/1879817
1. Check out source from http://svn.sonatype.org/flexmojos/tags/flexmojos-3.2.0
2. Modify the Flexmojos-maven-plugin/src/main/java/org/sonatype/flexmojos/compiler/applicationmojo.java source file as follows
/** * Copyright Marvin Herman Froeder * Licensed under the Apache License, Version 2.0 (the "License"); You are not a use of this file except in compliance with the License. Obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * unless required by applicable law O R agreed to writing, software distributed under the License are distributed on a "as is" BASIS, without warranties OR C Onditions of any KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. * * * Package org.sonatype.flexmojos.compiler; /* Copyright 2001-2005 the Apache software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * You are not a use this file except in compliance with the License. * Obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * unless required by applicable Law or agreed into writing, software * Distributed under the License is Distributed on an ' as is ' BASIS, * without warranties or CONDITIONS of any KIND, either express OR implied. * See the License for the specific language governing permissions and * limitations under the License. */import static java.util.Arrays.asList; Import Java.io.File; Import java.io.FileNotFoundException; Import Java.io.FileReader; Import Java.io.FileWriter; Import java.io.IOException; Import java.util.ArrayList; Import Java.util.Arrays; Import Java.util.HashSet; Import java.util.List; Import Java.util.Set; Import Org.codehaus.plexus.util.DirectoryScanner; Import Org.apache.commons.io.IOUtils; Import org.apache.maven.plugin.MojoExecutionException; Import org.apache.maven.plugin.MojoFailureException; Import org.sonatype.flexmojos.compatibilitykit.FlexCompatibility; Import Org.sonatype.flexmojos.utilities.FlashPlayerUtils; Import Org.sonatype.flexmojos.utilities.MavenUtils; Import Flex2.compiler.io.FileUtil; Import flex2.tools.oem.Application; Import Flex2.tools.oem.internal.OEMConfiguration; /** * <p> * Goal which compiles the flex sources into a application for either Flex or AIR depending on the package Type. * </p> * <p> * The Flex Compiler plugin compiles all ActionScript sources. It can compile the source into ' SwF ' files. The plugin * supports ' swf ' packaging. * </p> * * @author Marvin Herman froeder (velo.br@gmail.com) * @since 1.0 * @goal compile-swf * @requiresDependencyR Esolution * @phase Compile * * public class Applicationmojo extends abstractflexcompilermojo<application> {/** * the File to is compiled. The path must is relative with source folder * * @parameter */protected String sourcefile; /** * The list of modules files to be compiled. The path must is relative with source folder.<br> * Usage: * * <pre> * <moduleFiles> * <module>com/acme/AModule.mxml</module> * </moduleFiles> * </pre> * * @parameter * * Private string[] modulefiles; Private List<file> modules; Private string[] modulepaths; /** * When True, tells Flexmojos to use link reports/load externs on modules compilation * * @parameter default-value= "Tru E "expression=" ${loadexternsonmodules} "*/private Boolean loadexternsonmodules; /** * The file to is compiled */protected file source; /** * When True, Flexmojos would register register every compiled SWF files as trusted. These SWF files is assigned to * the local-trusted sandbox. They can interact with any other SWF files, and they can load data from anywhere, * remote or Local. On false what is done and so if the file is already trusted it would still as it is. * * @parameter default-value= "true" expression= "${updatesecuritysandbox}" */private Boolean updatesecuritysandbox; /** * Turn on generation of Debuggable SWFs. False By default for MXMLC, and true by default for COMPC. * * @parameter default-value= "false" */private Boolean debug; /** * Default locale for libraries. This is useful to non localized APPlications, just to define SWC.RB locale * * @parameter default-value= "en_US" */private String Defaultlocale; /** * The filename of the SWF movie to create * * @parameter default-value= "${project.build.directory}/${project.build.fin alname}.swf "*/protected File output; @Override protected void Fixconfigreport (Flexconfigbuilder configbuilder) {super.fixconfigreport (configbuilder); con Figbuilder.addlist (new string[] {Source.getabsolutepath ()}, "File-specs", "path-element"); } @Override public void SetUp () throws Mojoexecutionexception, mojofailureexception {file sourcedirectory = new file (Bui Ld.getsourcedirectory ()); if (!sourcedirectory.exists ()) {throw new Mojoexecutionexception ("Unable to found Sourcedirectory:" + sourcedirectory ); } if (source = = null) {GetLog (). Warn ("Source file is not defined, Flexmojos'll guess one."); source = MAVENUTILS.R Esolvesourcefile (project, sourcefile); } if (source = = null) {throw new Mojoexecutionexception ("Source file nOT expecified and no default found! "); } if (!source.exists ()) {throw new Mojofailureexception ("Unable to find" + sourcefile);} Need to initialize builder before go super try {builder = new application (source);} catch (FileNotFoundException E {throw new Mojofailureexception ("Unable to find" + source);} if (modulefiles! = null) {modules = new arraylist<file> (); DirectoryScanner ds = new DirectoryScanner (); Ds.setincludes (Modulefiles); Ds.setbasedir (sourcedirectory); Ds.setcasesensitive (TRUE); Ds.scan (); Modulepaths = Ds.getincludedfiles (); for (String modulepath:modulepaths) {file module = new File (sourcedirectory, Modulepath), if (!module.exists ()) { throw new Mojoexecutionexception ("module" + module + "not found."); Modules.add (module); } if (loadexternsonmodules) {super.linkreport = true;}} Super.setup (); Builder.setoutput (GetOutput ()); } @Override protected void TearDown () throws Mojoexecutionexception, Mojofailureexception {Super.teardown (); if (updatesecuritysandbox) {String trustedfile = Fileutil.getcanonicalpath (GetOutput ()); Updatesecuritysandbox (Trust Edfile); } if (modules! = null) {compilemodules ();}} protected void Compilemodules () throws Mojofailureexception, mojoexecutionexception {if (loadexternsonmodules) {Config Uration.addexterns (new file[] {linkreportfile}); } int i=0; for (File module:modules) {getLog (). info ("compiling module" + module); String modulename = Module.getname (); ModuleName = modulename.substring (0, Modulename.lastindexof ('. ')); Application ModuleBuilder; try {ModuleBuilder = new application (module),} catch (FileNotFoundException e) {throw new Mojofailureexception ("Un able to find "+ module, e);} Setmavenpathresolver (ModuleBuilder); Modulebuilder.setconfiguration (configuration); Modulebuilder.setlogger (New Compilelogger (GetLog ())); File Outputmodule = new file (build.getdirectory () + "/" +modulepaths[i].substring (0, MODULEPATHS[I].LAstindexof ('. ')) + "." + project.getpackaging ()); File Outputpath=outputmodule.getparentfile (); if ((outputpath!=null) && (!outputpath.exists ())) {Outputpath.mkdirs ();} i++; Modulebuilder.setoutput (Outputmodule); Build (ModuleBuilder, false); Projecthelper.attachartifact (Project, SWF, ModuleName, outputmodule); }} @FlexCompatibility (MinVersion = "3", maxversion = "3.1") protected void writeResourceBundleFlex30 (string[] bundles, String locale, File localepath) throws Mojoexecutionexception {//Dont break This method in parts, was a work around Fil E output = getruntimelocaleoutputfile (locale, SWF); /* * Mxmlc-locale=en_us-source-path=locale/{locale}-include-resource-bundles * =flightreservation2,sharedresources , collections, Containers,controls,core,effects,formatters,skins,styles *-output=src/resources_en_us.swf */String bundlesstring = arrays.tostring (bundles)//. Replace ("[", "")//Remove start [. replace ("]", "")//Remove end]. R Eplace (",", "," ); Remove spaces arraylist<file> external = new arraylist<file> (); arraylist<file> internal = new arraylist<file> (); arraylist<file> merged = new arraylist<file> (); External.addall (Aslist (Getglobaldependency ())); External.addall (Aslist (Getdependenciespath ("external")); External.addall (Aslist (Getdependenciespath ("RSL")); Internal.addall (Aslist (Getdependenciespath ("internal")); Merged.addall (Aslist (Getdependenciespath ("compile")); Merged.addall (Aslist (Getdependenciespath ("merged")); Merged.addall (Aslist (getresourcesbundles (locale))); set<string> args = new hashset<string> (); Args.addall (Arrays.aslist (configs)); Args.add ("-locale=" + locale); Args.add ("-source-path=" + Localepath.getabsolutepath ()); Args.add ("-include-resource-bundles=" + bundlesstring); Args.add ("-output=" + Output.getabsolutepath ()); Args.add ("-compiler.fonts.local-fonts-snapshot=" + getfontssnapshot (). GetabsolutEpath ()); Args.add ("-load-config=" + (ConfigFile = = null?) "": Configfile.getabsolutepath ())); Args.add ("-external-library-path=" + toString (external)); Args.add ("-include-libraries=" + toString (internal)); Args.add ("-library-path=" + toString (merged)); GetLog (). Debug ("Writeresourcebundle calling MXMLC with args:" + args.tostring ()); FORKMXMLC (args); RUNMXMLC (args); Projecthelper.attachartifact (Project, "SwF", locale, output); } @FlexCompatibility (maxversion = "2") private void Forkmxmlc (Set<string> args) throws Mojoexecutionexception { throw new Mojoexecutionexception ("not implemented yet"); } @FlexCompatibility (minversion = "3", maxversion = "3.1") private void Runmxmlc (set<string> args) {//Just a W Ork around//TODO https://bugs.adobe.com/jira/browse/SDK-15139 FLEX2.TOOLS.COMPILER.MXMLC (Args.toarray (New string[ Args.size ()]); } private String toString (list<file> Libs) {StringBuilder sb = new StringBuilder (); for (FileLib:libs) {if (Sb.length ()! = 0) {sb.append (', ');} sb.append (Lib.getabsolutepath ());} return sb.tostring (); } @Override protected void Writeresourcebundle (string[] bundlesnames, String locale, File localepath) throws Mojoexecuti onexception {writeResourceBundleFlex30 (bundlesnames, Locale, Localepath); writeResourceBundleFlex32 (Bundlesnames, Locale, Localepath); } @FlexCompatibility (minversion = "3.2") protected void writeResourceBundleFlex32 (string[] bundlesnames, String locale, File Localepath) throws mojoexecutionexception {Application Rbbuilder = new application (); File output = getruntimelocaleoutputfile (locale, SWF); Rbbuilder.setlogger (New Compilelogger (GetLog ())); Rbbuilder.setoutput (output); Rbbuilder.setconfiguration (configuration); if (configuration instanceof oemconfiguration) {oemconfiguration oemconfiguration = (oemconfiguration) configuration; o Emconfiguration.setincluderesourcebundles (Bundlesnames); } configuration.setlocale (New StRing[] {locale}); Configuration.setsourcepath (new file[] {localepath}); Configuration.includelibraries (NULL); Configuration.addexternallibrarypath (Getdependenciespath (INTERNAL)); Configuration.addlibrarypath (Getresourcesbundles (locale)); Build (Rbbuilder, true); if (Configurationreport) {try {flexconfigbuilder configbuilder = new Flexconfigbuilder (rbbuilder); configBuilder.add Output (output); Configbuilder.write (New File (Output.getparent (), Project.getartifactid () + "-" + project.getversion () + "-" + Locale + " -config-report.xml ")); } catch (Exception e) {throw new Mojoexecutionexception ("An error had ocurried while recording Config-report", E);} } projecthelper.attachartifact (Project, SWF, locale, output); } protected void Updatesecuritysandbox (String trustedfile) throws Mojoexecutionexception {File Fptrustfolder = Flashpla Yerutils.gettrustdir (); File Mavencfg = new file (Fptrustfolder, "maven.cfg"); if (!mavencfg.exists ()) {try {mavencfg.cReatenewfile (); } catch (IOException e) {throw new Mojoexecutionexception ("Unable to create Flashpayertrust file:" + MAVENCFG.GETABSO Lutepath (), E); }} getLog (). Debug ("Maven.cfg Location:" + mavencfg); try {//Load maven.cfg FileReader input = new FileReader (MAVENCFG); String cfg = ioutils.tostring (input); Input.close (); if (Cfg.contains (Trustedfile)) {GetLog (). Debug ("Already trust on" + trustedfile); Return } else {GetLog (). info ("Updating Flash Player Trust directory" + trustedfile);} if (!cfg.endswith ("/n")) {cfg = cfg + '/n ';}//Add Builder folder cfg = cfg + trustedfile + '/n '; Save maven.cfg FileWriter output = new FileWriter (MAVENCFG); Ioutils.write (cfg, output); Output.flush (); Output.close (); } catch (IOException e) {throw new Mojoexecutionexception ("Unable to edit Flashpayertrust file:" + Mavencfg.getabsolu Tepath (), E); }} @Override protected Boolean isdebug () {return this.debug;} @Override protected Boolean isapplication () { return true; } @Override protected String Getdefaultlocale () {return this.defaultlocale;} @Override protected File getoutput () {Retu RN This.output; } }
Compile the Install module to support wildcard characters.
<build> <plugins> <plugin> <groupId>org.sonatype.flexmojos</groupId> <artifactid >flexmojos-maven-plugin</artifactId> <version>${flex-mojos.version}</version> < extensions>true</extensions> <configuration> <moduleFiles> <module>**/*view.mxml</ module> <module>**/*Dialog.mxml</module> </moduleFiles> </configuration> </plugin > </plugins> </build>