Added:
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/ASDocMojo.java
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/AbstractFlexCompilerMojo.java
Modified:
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/AbstractFlexMojo.java
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/CompCompilerMojo.java
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/MXMLCompilerMojo.java
Log:
substantial refactor of parameter assembly and preparation into
compiler-specific subclass vs. a general plugin abstract class. Add in
a preliminary mojo for asdoc, which will use the generic parameters
that are common to all flex command-line executables
Added: trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/ASDocMojo.java
==============================================================================
--- (empty file)
+++
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/ASDocMojo.java
Mon Jan 7 03:53:47 2008
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2006 Israfil Consulting Services Corporation
+ * Copyright (c) 2006 Christian Edward Gruber
+ * All Rights Reserved
+ *
+ * This software is licensed under the Berkeley Standard Distribution license,
+ * (BSD license), as defined below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Israfil Consulting Services nor the names of
its contributors
+ * may be used to endorse or promote products derived from this
software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * $Id: CompCompilerMojo.java 573 2007-12-20 03:12:19Z
christianedwardgruber $
+ */
+package net.israfil.mojo.flex2;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import javax.xml.parsers.SAXParser;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+
+/**
+ * Compilation action for Flex2 actionscript 3 classes.
+ *
+ * @author <a href="cgr...@israfil.net">Christian Edward Gruber</a>
+ * @version $Id: CompCompilerMojo.java 573 2007-12-20 03:12:19Z
christianedwardgruber $
+ *
+ * @goal asdoc
+ * @requiresDependencyResolution
+ * @phase apidoc
+ * @requiresProject
+ */
+public class ASDocMojo extends AbstractFlexMojo {
+
+
+ protected String getCompilerClass() { return "flex2.tools.ASDoc"; }
+
+ protected void finalizeParameters(List parameterList)
+ throws MojoExecutionException, MojoFailureException {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected File getOutputFile() {
+ return getFile(outputDirectory, finalName, "asdoc");
+
+ }
+
+ protected String getFileExtension() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected List prepareParameters() throws MojoFailureException,
MojoExecutionException {
+ List parameters = super.prepareParameters();
+
+
+ return parameters;
+ }
+
+/*
+asdoc -source-path C:\flex\frameworks\source
+ -doc-classes mx.controls.Button
+ -main-title "Flex API Documentation"
+ -window-title "Flex API Documentation"
+ -output flex-framework-asdoc
+
+asdoc -source-path . -doc-classes comps.GraphingWidget comps.GraphingWidgetTwo
+
+asdoc -source-path C:\flex\class_dir -doc-classes comps.GraphingWidget comps.GraphingWidgetTwo
+
+asdoc -source-path . -doc-sources .
+
+asdoc -source-path frameworks
+ -namespace http://framework frameworks/core-framework-manifest.xml
+ -doc-namespaces http://framework
+
+asdoc -source-path . -doc-sources . -exclude-classes comps.PageWidget comps.ScreenWidget
+
+Option
+Description
+-doc-classes path-element [...]
+A list of classes to document. These classes must be in the source
path. This is the default option.
+This option works the same way as does the -include-classes option for
the compc component compiler. For more information, see Using the
component compiler.
+-doc-namespaces uri manifest
+A list of URIs whose classes should be documented. The classes must be
in the source path.
+You must include a URI and the location of the manifest file that
defines the contents of this namespace.
+This option works the same way as does the -include-namespaces option
for the compc component compiler. For more information, see Using the
component compiler.
+-doc-sources path-element [...]
+A list of files that should be documented. If a directory name is in
the list, it is recursively searched.
+This option works the same way as does the -include-sources option for
the compc component compiler. For more information, see Using the
component compiler.
+-exclude-classes string
+A list of classes that should not be documented. You must specify
individual class names. Alternatively, if the ASDoc comment for the
class contains the @private tag, is not documented.
+-exclude-dependencies true|false
+Whether all dependencies found by the compiler are documented. If
true, the dependencies of the input classes are not documented.
+The default value is false.
+-footer string
+The text that appears at the bottom of the HTML pages in the output documentation.
+-left-frameset-width int
+An integer that changes the width of the left frameset of the
documentation. You can change this size to accommodate the length of
your package names.
+The default value is 210 pixels.
+-main-title "string"
+The text that appears at the top of the HTML pages in the output documentation.
+The default value is "API Documentation".
+-output string
+The output directory for the generated documentation. The default
value is "asdoc-output".
+-package name "description"
+The descriptions to use when describing a package in the
documentation. You can specify more than one package option.
+The following example adds two package descriptions to the output:
+asdoc -doc-sources my_dir -output myDoc -package
com.my.business "Contains business classes and interfaces" -package
com.my.commands "Contains command base classes and interfaces"
+-templates-path string
+The path to the ASDoc template directory. The default is the
asdoc/templates directory in the ASDoc installation directory. This
directory contains all the HTML, CSS, XSL, and image files used for
generating the output.
+-window-title "string"
+The text that appears in the browser window in the output documentation.
+The default value is "API Documentation".
+The asdoc command also recognizes the following options from the compc
component compiler:
+
+-source-path
+-library-path
+-namespace
+-load-config
+-actionscript-file-encoding
+-help
+-advanced
+-benchmark
+-strict
+-warnings
+
+
+-benchmark
+-compiler.accessible
+-compiler.actionscript-file-encoding <string>
+-compiler.context-root <context-path>
+-compiler.debug
+-compiler.external-library-path [path-element] [...]
+-compiler.fonts.flash-type
+-compiler.fonts.max-glyphs-per-face <string>
+-compiler.include-libraries [library] [...]
+-compiler.incremental
+-compiler.library-path [path-element] [...]
+-compiler.locale <string>
+-compiler.namespaces.namespace <uri> <manifest>
+-compiler.optimize
+-compiler.services <filename>
+-compiler.show-actionscript-warnings
+-compiler.show-binding-warnings
+-compiler.show-deprecation-warnings
+-compiler.show-unused-type-selector-warnings
+-compiler.source-path [path-element] [...]
+-compiler.strict
+-compiler.theme [filename] [...]
+-compiler.use-resource-bundle-metadata
+-doc-classes [class] [...]
+-doc-namespaces [uri] [...]
+-doc-sources [path-element] [...]
+-exclude-classes [class] [...]
+-exclude-dependencies
+-footer <string>
+-help [keyword] [...]
+-left-frameset-width <int>
+-licenses.license <product> <serial-number>
+-load-config <filename>
+-main-title <string>
+-metadata.contributor <name>
+-metadata.creator <name>
+-metadata.date <text>
+-metadata.description <text>
+-metadata.language <code>
+-metadata.localized-description <text> <lang>
+-metadata.localized-title <title> <lang>
+-metadata.publisher <name>
+-metadata.title <text>
+-output <filename>
+-packages.package <string> <string>
+-runtime-shared-libraries [url] [...]
+-templates-path <string>
+-use-network
+-version
+-window-title <string>
+
+*/
+
+
+}
Added: trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/AbstractFlexCompilerMojo.java
==============================================================================
--- (empty file)
+++
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/AbstractFlexCompilerMojo.java
Mon Jan 7 03:53:47 2008
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2006-2007 Israfil Consulting Services Corporation
+ * Copyright (c) 2006-2007 Christian Edward Gruber
+ * All Rights Reserved
+ *
+ * This software is licensed under the Berkeley Standard Distribution license,
+ * (BSD license), as defined below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Israfil Consulting Services nor the names of
its contributors
+ * may be used to endorse or promote products derived from this
software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * $Id: AbstractFlexMojo.java 570 2007-11-22 13:07:05Z
christianedwardgruber $
+ */
+package net.israfil.mojo.flex2;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+
+/**
+ * Base class for flex2/actionscript3 plugin
+ *
+ * @author <a href="cgr...@israfil.net">Christian Edward Gruber</a>
+ * @author <a href="tspu...@gmail.com">Tim Spurway</a>
+ * @version $Id: AbstractFlexMojo.java 570 2007-11-22 13:07:05Z
christianedwardgruber $
+ */
+public abstract class AbstractFlexCompilerMojo extends
AbstractFlexMojo {
+
+
+ /**
+ * Resolve extra libraries (such as charts or fds) from
+ * ${flex.home}/frameworks/libs. Default is false, in which case
+ * these (and other) swcs should be deployed as flex artifacts (swcs).
+ *
+ * @parameter alias="resolve-extra-framework-libs" default="false"
+ */
+ protected boolean resolveExtraSwcsFromFlexFrameworksLibs = false;
+
+ /**
+ * The location of the flex configuration file. Uses the installed
+ * default flex-config.xml file if none supplied.
+ *
+ * @parameter expression="${flex.config}" default-value="${flex.home}/frameworks/flex-config.xml"
+ * @required
+ *
+ */
+ protected File flexConfig;
+
+ /**
+ * The current locale.
+ *
+ * @parameter expression="${flex.locale}" default="en_US"
+ */
+ protected String locale = "en_US";
+
+ /**
+ * @parameter expression="${flex.compiler.optimize}" default="false"
+ */
+ protected boolean optimize;
+
+ /**
+ * @parameter expression="${flex.compiler.profile}" default="false"
+ */
+ protected boolean profile;
+
+ /**
+ * @parameter expression="${flex.compiler.strict}" default="false"
+ */
+ protected boolean strict;
+
+ /**
+ * @parameter expression="${flex.compiler.use-network}" default="false"
+ */
+ protected boolean useNetwork;
+
+ /**
+ * @parameter expression="${flex.compiler.show-warnings}" default="false"
+ */
+ protected boolean warnings;
+
+ /**
+ * @parameter expression="${flex.compiler.incremental}" default="false"
+ */
+ protected boolean incremental;
+
+ /**
+ * @parameter
expression="${flex.compiler.show-actionscript-warnings}" default="false"
+ */
+ protected boolean showActionscriptWarnings;
+
+ /**
+ * @parameter expression="${flex.compiler.show-binding-warnings}" default="false"
+ */
+ protected boolean showBindingWarnings;
+
+ /**
+ * @parameter
expression="${flex.compiler.show-deprecation-warnings}" default="false"
+ */
+ protected boolean showDeprecationWarnings;
+
+
+ /**
+ * @parameter expression="${flex.licenses}"
+ */
+ protected License[] licenses;
+
+
+ /**
+ * @parameter expression="${flex.dataservices.config}"
+ */
+ protected File dataServicesConfig;
+
+ public AbstractFlexCompilerMojo() {
+ super();
+ }
+
+ /**
+ * Overload this to produce a test-jar, for example.
+ */
+ protected String getClassifier() {
+ return null;
+ }
+
+ protected File getOutputFile() {
+ return getFile(outputDirectory, finalName, classifier);
+ }
+
+
+ protected void addSourcePathToParameters(List parameterList) {
+ Iterator i = compileSourceRoots.iterator();
+ if (i.hasNext());
+ parameterList.add( "-source-path" );
+ while (i.hasNext()) {
+ String path = (String)i.next();
+ if (new File(path).exists()) {
+ getLog().debug("Adding source path: " + path);
+ parameterList.add( path );
+ } else {
+ getLog().debug("Ignoring missing source path: " + path);
+ }
+ }
+ }
+
+ protected List prepareParameters() throws MojoFailureException,
MojoExecutionException {
+ List parameters = super.prepareParameters();
+
+ parameters.add("-load-config");
+ try {
+ parameters.add(flexConfig.getCanonicalFile().getAbsolutePath());
+ } catch (IOException e) {
+ throw new MojoExecutionException("Config file does not exist.", e);
+ }
+
+ // add in locale
+ parameters.add("-compiler.locale");
+ parameters.add(locale);
+
+ // add in license
+
+ getLog().info("Attaching licenses.");
+ for (int i = 0; licenses != null && i < licenses.length; i++) {
+ getLog().debug("Adding license: " + licenses[i].getProduct() + "="
+ licenses[i].getSerialNumber());
+ parameters.add("-licenses.license");
+ parameters.add(licenses[i].getProduct());
+ parameters.add(licenses[i].getSerialNumber());
+ }
+
+
+ // add in binary options.
+ if (optimize) parameters.add("-compiler.optimize");
+ if (profile) parameters.add("-compiler.profile");
+ if (strict) parameters.add("-compiler.strict");
+ if (useNetwork) parameters.add("-use-network");
+ if (warnings) parameters.add("-warnings");
+ if (incremental) parameters.add("-compiler.incremental");
+ if (showActionscriptWarnings) parameters.add("-show-actionscript-warnings");
+ if (showBindingWarnings) parameters.add("-show-binding-warnings");
+ if (showDeprecationWarnings) parameters.add("-show-deprecation-warnings");
+ //verbose-stacktraces
+
+
+ if (dataServicesConfig != null) {
+ parameters.add("-compiler.services");
+ try {
+ parameters.add(dataServicesConfig.getCanonicalFile().getAbsolutePath());
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to set data services
config file.", e);
+ }
+ }
+
+ Set linkedLibraryPaths = new HashSet();
+ File fwLibDir = new File(flexHome,"frameworks/libs");
+ try {
+ linkedLibraryPaths.add(new File(fwLibDir,"framework.swc").getCanonicalFile().getAbsolutePath());
+ linkedLibraryPaths.add(new File(fwLibDir,"playerglobal.swc").getCanonicalFile().getAbsolutePath());
+ linkedLibraryPaths.add(new File(fwLibDir,"flex.swc").getCanonicalFile().getAbsolutePath());
+ linkedLibraryPaths.add(new File(fwLibDir,"utilities.swc").getCanonicalFile().getAbsolutePath());
+ linkedLibraryPaths.add(new File(fwLibDir,"rpc.swc").getCanonicalFile().getAbsolutePath());
+ if (resolveExtraSwcsFromFlexFrameworksLibs) {
+ if (new File(fwLibDir,"charts.swc").exists())
+ //javaParms.add("-include-libraries+=" + new File(fwLibDir,"charts.swc").getCanonicalFile().getAbsolutePath());
+ linkedLibraryPaths.add(new File(fwLibDir,"charts.swc").getCanonicalFile().getAbsolutePath());
+ if (new File(fwLibDir,"fds.swc").exists())
+ linkedLibraryPaths.add(new File(fwLibDir,"fds.swc").getCanonicalFile().getAbsolutePath());
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("IOException trying to add to
included libraries.",e);
+ }
+
+
+ // external-library-path path-element [...]
+ // Specifies a list of SWC files or directories to exclude from
linking when compiling a SWF file. This option provides compile-time
link checking for external components that are dynamically linked.
+ // For more information about dynamic linking, see About linking.
+ // You can use the += operator to append the new SWC file to the
list of external libraries.
+
+ // runtime-shared-libraries (deployed runtime lib location - 1 for each)
+
+ // Process
+ Set artifacts = project.getArtifacts();
+ getLog().debug("Dependency artifacts: " + artifacts);
+ Iterator depsIterator = artifacts.iterator();
+ while (depsIterator.hasNext()) {
+ Artifact dep = (Artifact)depsIterator.next();
+ // TODO: let the scope handler deal with this
+ if ( Artifact.SCOPE_COMPILE.equals( dep.getScope() ) ||
+ Artifact.SCOPE_PROVIDED.equals( dep.getScope() ) ||
+ Artifact.SCOPE_SYSTEM.equals( dep.getScope() ) ) {
+ if ("swc".equals(dep.getType())) {
+ getLog().debug("Linking dependency: " + dep);
+ try {
+ String absPath = dep.getFile().getCanonicalFile().getAbsolutePath();
+ linkedLibraryPaths.add(absPath);
+ //includedLibraryPaths.add(absPath);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Dependency file not present or
readable: " + dep.getFile().getAbsolutePath(),e);
+ }
+ } else if ("swf".equals(dep.getType())) {
+ throw new MojoExecutionException("Cannot link swf project '" +
+ dep + "' into other swf. Compile dependencies must be .swcs.");
+ }
+ } else {
+ getLog().debug("Skipping non-compile artifact: " + dep);
+ }
+
+ }
+
+ // FIXME: What do we do with include-libraries???
+ // add included library paths.
+ Set includedLibraryPaths = new HashSet();
+ Iterator inclLibsIter = includedLibraryPaths.iterator();
+ while (inclLibsIter.hasNext())
+ parameters.add("-include-libraries+=" + inclLibsIter.next());
+
+
+
+
+ /*
+ -benchmark
+ -compiler.accessible
+ -compiler.actionscript-file-encoding <string>
+ -compiler.context-root <context-path>
+ -compiler.fonts.max-glyphs-per-face <string>
+ -compiler.include-libraries [library] [...]
+
+ -compiler.namespaces.namespace <uri> <manifest>
+ -compiler.source-path [path-element] [...]
+ -compiler.theme [filename] [...]
+ -compiler.use-resource-bundle-metadata
+ -file-specs [path-element] [...]
+ -help [keyword] [...]
+ -metadata.contributor <name>
+ -metadata.creator <name>
+ -metadata.date <text>
+ -metadata.description <text>
+ -metadata.language <code>
+ -metadata.localized-description <text> <lang>
+ -metadata.localized-title <title> <lang>
+ -metadata.publisher <name>
+ -metadata.title <text>
+ -runtime-shared-libraries [url] [...]
+ */
+
+
+ return parameters;
+ }
+
+
+}
Modified: trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/AbstractFlexMojo.java
==============================================================================
---
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/AbstractFlexMojo.java (original)
+++
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/AbstractFlexMojo.java
Mon Jan 7 03:53:47 2008
@@ -63,7 +63,6 @@
* @version $Id$
*/
public abstract class AbstractFlexMojo extends AbstractMojo {
-
/**
* The directory in which Flex (command-line or builder) is installed.
@@ -74,36 +73,6 @@
*/
protected File flexHome;
- /**
- * Resolve extra libraries (such as charts or fds) from
- * ${flex.home}/frameworks/libs. Default is false, in which case
- * these (and other) swcs should be deployed as flex artifacts (swcs).
- *
- * @parameter alias="resolve-extra-framework-libs" default="false"
- */
- protected boolean resolveExtraSwcsFromFlexFrameworksLibs = false;
-
- /**
- * The location of the flex configuration file. Uses the installed
- * default flex-config.xml file if none supplied.
- *
- * @parameter expression="${flex.config}" default-value="${flex.home}/frameworks/flex-config.xml"
- * @required
- *
- */
- protected File flexConfig;
-
- /**
- * The directory into which to place the resulting artifact. note
that this is a read-only
- * parameter, satisfied from the build directory. Attempts to
configure this should use the
- * standard <build><directory/></build> approach.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
-
/**
* The source directories containing the sources to be compiled.
*
@@ -120,6 +89,17 @@
* @parameter expression="${flex.compiler.source}" default="src/main/flex"
*/
protected File source;
+
+ /**
+ * The directory into which to place the resulting artifact. note
that this is a read-only
+ * parameter, satisfied from the build directory. Attempts to
configure this should use the
+ * standard <build><directory/></build> approach.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
/**
* Name of the generated compiled binary file.
@@ -129,82 +109,40 @@
*/
protected String finalName;
- /**
- * The current locale.
- *
- * @parameter expression="${flex.locale}" default="en_US"
- */
- protected String locale = "en_US";
-
- /**
- * @parameter expression="${flex.compiler.optimize}" default="false"
- */
- protected boolean optimize;
-
- /**
- * @parameter expression="${flex.compiler.profile}" default="false"
- */
- protected boolean profile;
-
- /**
- * @parameter expression="${flex.compiler.strict}" default="false"
- */
- protected boolean strict;
-
- /**
- * @parameter expression="${flex.compiler.use-network}" default="false"
- */
- protected boolean useNetwork;
-
- /**
- * @parameter expression="${flex.compiler.show-warnings}" default="false"
- */
- protected boolean warnings;
/**
- * @parameter expression="${flex.compiler.incremental}" default="false"
- */
- protected boolean incremental;
-
- /**
- * @parameter
expression="${flex.compiler.show-actionscript-warnings}" default="false"
- */
- protected boolean showActionscriptWarnings;
-
- /**
- * @parameter expression="${flex.compiler.show-binding-warnings}" default="false"
- */
- protected boolean showBindingWarnings;
-
- /**
- * @parameter
expression="${flex.compiler.show-deprecation-warnings}" default="false"
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
*/
- protected boolean showDeprecationWarnings;
-
-
+ protected MavenProject project;
+
/**
- * @parameter expression="${flex.licenses}"
+ * @component
*/
- protected License[] licenses;
-
+ protected MavenProjectHelper projectHelper;
/**
- * @parameter expression="${flex.extraParameters}"
+ * @parameter expression="${plugin.artifacts}"
+ * @required
+ * @readonly
*/
- protected Parameter[] extraParameters;
+ protected List pluginArtifacts;
/**
- * @parameter expression="${flex.dataservices.config}"
- */
- protected File dataServicesConfig;
-
- /**
* These are additional JVM options used when invoking the Flex compiler
*
* @parameter expression="${flex.java.options}"
*/
protected String[] javaOpts;
+ /**
+ * @parameter expression="${flex.extraParameters}"
+ */
+ protected Parameter[] extraParameters;
+
/**
* Classifier to add to the artifact generated. If given, the
artifact will
* be an attachment instead.
@@ -213,45 +151,10 @@
*/
protected String classifier;
- /**
- * The maven project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * @parameter expression="${plugin.artifacts}"
- * @required
- * @readonly
- */
- protected List pluginArtifacts;
-
- /**
- * @component
- */
- protected MavenProjectHelper projectHelper;
-
-
- public AbstractFlexMojo() {
- super();
- }
-
- /**
- * Overload this to produce a test-jar, for example.
- */
- protected String getClassifier() {
- return null;
- }
+ protected abstract File getOutputFile();
protected abstract String getCompilerClass();
- protected File getOutputDirectory() {
- return outputDirectory;
- }
-
protected abstract String getFileExtension();
protected File getFile( File basedir, String finalName, String
classifier ) {
@@ -259,48 +162,69 @@
if ( classifier.trim().length() > 0
&& !classifier.startsWith( "-" )){
classifier = "-" + classifier;
}
- return new File( basedir, finalName + "-" +
getClassifier() + ".jar" );
+ return new File( basedir, finalName + "-" + classifier
+ ".jar" );
} else {
return new File( basedir, finalName + "." +
getFileExtension() );
}
}
-
+
/**
* Override and implement this method to take the existing java parameters
* and add any final information requried to provide source files
to the
* compiler.
* @param parameterList
*/
- protected abstract void finalizeParameters(List parameterList)
throws MojoExecutionException, MojoFailureException;
-
- protected final MavenProject getProject() {
- return project;
- }
-
- protected void addSourcePath(List parameterList) {
- Iterator i = compileSourceRoots.iterator();
- if (i.hasNext());
- parameterList.add( "-source-path" );
- while (i.hasNext()) {
- String path = (String)i.next();
- if (new File(path).exists()) {
- getLog().debug("Adding source path: " + path);
- parameterList.add( path );
- } else {
- getLog().debug("Ignoring missing source path: " + path);
+ protected List prepareParameters() throws MojoFailureException,
MojoExecutionException {
+ List parameters = new ArrayList();
+
+ // define output file.
+ File outFile = getOutputFile();
+ parameters.add("-output");
+ try {
+ parameters.add(outFile.getCanonicalFile().getAbsolutePath());
+ } catch (IOException e) {
+ throw new MojoExecutionException("Exception attempting to set
output file: " + outFile, e);
+ }
+
+
+
+
+
+
+
+
+
+ // hack in the source, since we're not using a proper plexus
compiler yet.
+ compileSourceRoots.add(new File(project.getBasedir(),"src/main/flex").getPath());
+
+ return parameters;
+ }
+
+ private void finalizeParameters(List parameters) throws
MojoExecutionException, MojoFailureException {
+ getLog().info("Adding Extra Parameters: " + Arrays.asList(extraParameters));
+ Iterator extraParmsIter = Arrays.asList(extraParameters).iterator();
+ while (extraParmsIter.hasNext()) {
+ Parameter p = (Parameter)extraParmsIter.next();
+ getLog().debug("Adding parameter " + p.getName());
+ parameters.add("-" + p.getName());
+ if (p.getValues() != null) {
+ Iterator values = Arrays.asList(p.getValues()).iterator();
+ while (values.hasNext()) {
+ String value = (String)values.next();
+ getLog().debug("Adding parameter value" + value);
+ parameters.add(value);
+ }
}
- }
+ }
}
-
+
public void execute() throws MojoExecutionException,
MojoFailureException {
if (!flexHome.exists())
throw new MojoExecutionException(flexHome + " does not exist.
flex.home property must be set.");
- Set includedLibraryPaths = new HashSet();
- Set linkedLibraryPaths = new HashSet();
- this.getLog().debug("Creating output directory: " + getOutputDirectory());
+ this.getLog().debug("Creating output directory: " + outputDirectory);
outputDirectory.mkdirs();
@@ -308,9 +232,6 @@
if (source == null) source = new File(project.getBasedir(),"src/main/flex");
if ( !source.exists() )
throw new MojoExecutionException("Source directory " + source + "
does not exist.");
- else
- this.getLog().info("Compiling Flex 2 code");
-
//
// Setup the Command-line of java execution.
@@ -370,172 +291,9 @@
// Setup the Java parameters.
//
- List javaParms = new ArrayList();
+ List parameters = prepareParameters();
+ finalizeParameters(parameters); // stuff
- // define output file.
- String classifier = getClassifier();
- File outFile = getFile(outputDirectory, finalName, classifier);
- javaParms.add("-output");
- try {
- javaParms.add(outFile.getCanonicalFile().getAbsolutePath());
- } catch (IOException e) {
- throw new MojoExecutionException("Exception attempting to set
output file: " + outFile, e);
- }
-
- javaParms.add("-load-config");
- try {
- javaParms.add(flexConfig.getCanonicalFile().getAbsolutePath());
- } catch (IOException e) {
- throw new MojoExecutionException("Exception attempting to set
output file: " + outFile, e);
- }
-
- // add in locale
- javaParms.add("-compiler.locale");
- javaParms.add(locale);
-
- // add in license
-
- getLog().info("Attaching licenses.");
- for (int i = 0; licenses != null && i < licenses.length; i++) {
- getLog().debug("Adding license: " + licenses[i].getProduct() + "="
+ licenses[i].getSerialNumber());
- javaParms.add("-licenses.license");
- javaParms.add(licenses[i].getProduct());
- javaParms.add(licenses[i].getSerialNumber());
- }
-
- // add in binary options.
- if (optimize) javaParms.add("-compiler.optimize");
- if (profile) javaParms.add("-compiler.profile");
- if (strict) javaParms.add("-compiler.strict");
- if (useNetwork) javaParms.add("-use-network");
- if (warnings) javaParms.add("-warnings");
- if (incremental) javaParms.add("-compiler.incremental");
- if (showActionscriptWarnings) javaParms.add("-show-actionscript-warnings");
- if (showBindingWarnings) javaParms.add("-show-binding-warnings");
- if (showDeprecationWarnings) javaParms.add("-show-deprecation-warnings");
- //verbose-stacktraces
-
- if (dataServicesConfig != null) {
- javaParms.add("-compiler.services");
- try {
- javaParms.add(dataServicesConfig.getCanonicalFile().getAbsolutePath());
- } catch (IOException e) {
- throw new MojoExecutionException("Exception attempting to set
output file: " + outFile, e);
- }
- }
- File fwLibDir = new File(flexHome,"frameworks/libs");
- try {
- linkedLibraryPaths.add(new File(fwLibDir,"framework.swc").getCanonicalFile().getAbsolutePath());
- linkedLibraryPaths.add(new File(fwLibDir,"playerglobal.swc").getCanonicalFile().getAbsolutePath());
- linkedLibraryPaths.add(new File(fwLibDir,"flex.swc").getCanonicalFile().getAbsolutePath());
- linkedLibraryPaths.add(new File(fwLibDir,"utilities.swc").getCanonicalFile().getAbsolutePath());
- linkedLibraryPaths.add(new File(fwLibDir,"rpc.swc").getCanonicalFile().getAbsolutePath());
- if (resolveExtraSwcsFromFlexFrameworksLibs) {
- if (new File(fwLibDir,"charts.swc").exists())
- //javaParms.add("-include-libraries+=" + new File(fwLibDir,"charts.swc").getCanonicalFile().getAbsolutePath());
- linkedLibraryPaths.add(new File(fwLibDir,"charts.swc").getCanonicalFile().getAbsolutePath());
- if (new File(fwLibDir,"fds.swc").exists())
- linkedLibraryPaths.add(new File(fwLibDir,"fds.swc").getCanonicalFile().getAbsolutePath());
- }
- } catch (IOException e) {
- throw new MojoExecutionException("IOException trying to add to
included libraries.",e);
- }
-
-
- // external-library-path path-element [...]
- // Specifies a list of SWC files or directories to exclude from
linking when compiling a SWF file. This option provides compile-time
link checking for external components that are dynamically linked.
- // For more information about dynamic linking, see About linking.
- // You can use the += operator to append the new SWC file to the
list of external libraries.
-
- // runtime-shared-libraries (deployed runtime lib location - 1 for each)
-
-
- // Process
- Set artifacts = project.getArtifacts();
- getLog().debug("Dependency artifacts: " + artifacts);
- Iterator depsIterator = artifacts.iterator();
- while (depsIterator.hasNext()) {
- Artifact dep = (Artifact)depsIterator.next();
- // TODO: let the scope handler deal with this
- if ( Artifact.SCOPE_COMPILE.equals( dep.getScope() ) ||
- Artifact.SCOPE_PROVIDED.equals( dep.getScope() ) ||
- Artifact.SCOPE_SYSTEM.equals( dep.getScope() ) ) {
- if ("swc".equals(dep.getType())) {
- getLog().debug("Linking dependency: " + dep);
- try {
- String absPath = dep.getFile().getCanonicalFile().getAbsolutePath();
- linkedLibraryPaths.add(absPath);
- //includedLibraryPaths.add(absPath);
- } catch (IOException e) {
- throw new MojoExecutionException("Dependency file not present or
readable: " + dep.getFile().getAbsolutePath(),e);
- }
- } else if ("swf".equals(dep.getType())) {
- throw new MojoExecutionException("Cannot link swf project '" +
- dep + "' into other swf. Compile dependencies must be .swcs.");
- }
- } else {
- getLog().debug("Skipping non-compile artifact: " + dep);
- }
-
- }
-
-
-
-
- // add included and linked library paths.
- Iterator inclLibsIter = includedLibraryPaths.iterator();
- while (inclLibsIter.hasNext())
- javaParms.add("-include-libraries+=" + inclLibsIter.next());
-
-
-
-
- /*
- -benchmark
- -compiler.accessible
- -compiler.actionscript-file-encoding <string>
- -compiler.context-root <context-path>
- -compiler.fonts.max-glyphs-per-face <string>
- -compiler.include-libraries [library] [...]
-
- -compiler.namespaces.namespace <uri> <manifest>
- -compiler.source-path [path-element] [...]
- -compiler.theme [filename] [...]
- -compiler.use-resource-bundle-metadata
- -file-specs [path-element] [...]
- -help [keyword] [...]
- -metadata.contributor <name>
- -metadata.creator <name>
- -metadata.date <text>
- -metadata.description <text>
- -metadata.language <code>
- -metadata.localized-description <text> <lang>
- -metadata.localized-title <title> <lang>
- -metadata.publisher <name>
- -metadata.title <text>
- -runtime-shared-libraries [url] [...]
- */
-
- // hack in the source, since we're not using a proper plexus
compiler yet.
- compileSourceRoots.add(new File(project.getBasedir(),"src/main/flex").getPath());
-
- finalizeParameters(javaParms);
-
- getLog().info("Adding Extra Parameters: " + Arrays.asList(extraParameters));
- Iterator extraParmsIter = Arrays.asList(extraParameters).iterator();
- while (extraParmsIter.hasNext()) {
- Parameter p = (Parameter)extraParmsIter.next();
- getLog().debug("Adding parameter " + p.getName());
- javaParms.add("-" + p.getName());
- if (p.getValues() != null) {
- Iterator values = Arrays.asList(p.getValues()).iterator();
- while (values.hasNext()) {
- String value = (String)values.next();
- getLog().debug("Adding parameter value" + value);
- javaParms.add(value);
- }
- }
- }
int result = -1;
@@ -544,7 +302,7 @@
} catch (IOException e) {}
try {
- result = executeJavaCommand("java",
source.getAbsolutePath(), commandLineArgs, getCompilerClass(), javaParms);
+ result = executeJavaCommand("java",
source.getAbsolutePath(), commandLineArgs, getCompilerClass(), parameters);
if ( result != 0 )
throw new MojoExecutionException( "Result of " +
getCompilerClass() + " execution is: '" + result + "'." );
} catch ( CommandLineException e ) {
@@ -552,10 +310,11 @@
}
// Point Maven2 at the outbound file.
+ File outFile = getOutputFile();
if (classifier != null) {
- projectHelper.attachArtifact(getProject(), "", classifier, outFile);
+ projectHelper.attachArtifact(project, classifier, outFile);
} else {
- getProject().getArtifact().setFile(outFile);
+ project.getArtifact().setFile(outFile);
}
}
@@ -597,6 +356,5 @@
return CommandLineUtils.executeCommandLine( cl, argIs,
consumer, consumer );
}
-
}
Modified: trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/CompCompilerMojo.java
==============================================================================
---
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/CompCompilerMojo.java (original)
+++
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/CompCompilerMojo.java
Mon Jan 7 03:53:47 2008
@@ -62,7 +62,7 @@
* @phase compile
* @requiresProject
*/
-public class CompCompilerMojo extends AbstractFlexMojo {
+public class CompCompilerMojo extends AbstractFlexCompilerMojo {
/**
*
@@ -117,16 +117,17 @@
protected String getFileExtension() { return "swc"; }
- public void finalizeParameters(List parameterList) throws
MojoFailureException, MojoExecutionException {
+ protected List prepareParameters() throws MojoFailureException,
MojoExecutionException {
+ List parameters = super.prepareParameters();
- parameterList.add("-compiler.debug=" + debug);
+ parameters.add("-compiler.debug=" + debug);
- addSourcePath(parameterList);
+ addSourcePathToParameters(parameters);
if (flexLibPropertiesFile == null) {
getLog().debug("No flex lib properties specified - checking for
included resources or classes.");
if (includedClasses == null) {
- includeSourceRoots(parameterList);
+ includeSourceRoots(parameters);
}
if (includedResources == null) {
includeAllResources();
@@ -138,11 +139,11 @@
if (includedClasses != null && !includedClasses.isEmpty()) {
getLog().info("Including actionscript classes.");
- parameterList.add( "-include-classes" );
+ parameters.add( "-include-classes" );
for (Iterator i = includedClasses.iterator() ; i.hasNext();) {
String parm = (String)i.next();
getLog().debug("Included class: " + parm);
- parameterList.add( parm );
+ parameters.add( parm );
}
} else {
getLog().info("No explicit classes declared for inclusion.");
@@ -150,11 +151,11 @@
if (includedNamespaces != null && !includedNamespaces.isEmpty()) {
getLog().info("Including declared namespaces.");
- parameterList.add( "-include-namespaces" );
+ parameters.add( "-include-namespaces" );
for (Iterator i = includedNamespaces.iterator() ; i.hasNext();) {
String parm = (String)i.next();
getLog().debug("Included namespace: " + parm);
- parameterList.add( parm );
+ parameters.add( parm );
}
} else {
getLog().info("No namespaces declared for inclusion.");
@@ -165,8 +166,8 @@
List resourceRoots = new ArrayList(compileSourceRoots);
resourceRoots.add("src/main/resources/");
ComponentResource cr = (ComponentResource)i.next();
- parameterList.add( "-include-file" );
- parameterList.add( cr.getDestPath() );
+ parameters.add( "-include-file" );
+ parameters.add( cr.getDestPath() );
File file = new File(cr.getSourcePath()).getAbsoluteFile();
for (int c = 0; c < resourceRoots.size() && !file.exists() ;
c++) {
file = new File((String)resourceRoots.get(c), cr.getSourcePath()).getAbsoluteFile();
@@ -174,10 +175,11 @@
}
if (file == null || !file.exists())
throw new MojoFailureException("Cannot load file for path " + cr.getSourcePath());
- parameterList.add(file.getAbsolutePath());
+ parameters.add(file.getAbsolutePath());
getLog().debug("Adding resource: " + file.getAbsolutePath());
}
}
+ return parameters;
}
private void includeSourceRoots(List parameterList) {
Modified: trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/MXMLCompilerMojo.java
==============================================================================
---
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/MXMLCompilerMojo.java (original)
+++
trunk/maven-flex2-plugin/src/main/java/net/israfil/mojo/flex2/MXMLCompilerMojo.java
Mon Jan 7 03:53:47 2008
@@ -35,6 +35,9 @@
import java.util.List;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
/**
* Compilation action for Flex2 actionscript 3 classes.
@@ -47,7 +50,7 @@
* @phase compile
* @requiresProject
*/
-public class MXMLCompilerMojo extends AbstractFlexMojo {
+public class MXMLCompilerMojo extends AbstractFlexCompilerMojo {
/**
*
@@ -73,17 +76,19 @@
protected String getFileExtension() { return "swf"; }
- public void finalizeParameters(List parameterList) {
+ protected List prepareParameters() throws MojoFailureException,
MojoExecutionException {
+ List parameters = super.prepareParameters();
- parameterList.add("-compiler.debug=" + debug);
+ parameters.add("-compiler.debug=" + debug);
- addSourcePath(parameterList);
+ addSourcePathToParameters(parameters);
- parameterList.add("--");
+ parameters.add("--");
// Add in main mxml file.
- parameterList.add(mainMxmlFile);
-
+ parameters.add(mainMxmlFile);
+
+ return parameters;
}