- Refactored the Ant task code to be located in a separate module
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/d1f0c033 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/d1f0c033 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/d1f0c033 Branch: refs/heads/develop Commit: d1f0c033ec1ed9fb7f1504bd3586997dee09249f Parents: 3d9cba1 Author: Christofer Dutz <[email protected]> Authored: Fri Jul 8 23:08:45 2016 +0200 Committer: Christofer Dutz <[email protected]> Committed: Fri Jul 8 23:08:45 2016 +0200 ---------------------------------------------------------------------- compiler/pom.xml | 6 + .../org/apache/flex/compiler/ant/COMPCTask.java | 512 ------------------- .../org/apache/flex/compiler/ant/FlexTask.java | 418 --------------- .../org/apache/flex/compiler/ant/MXMLCTask.java | 493 ------------------ .../compiler/ant/config/BaseConfigVariable.java | 74 --- .../compiler/ant/config/ConfigAppendString.java | 48 -- .../flex/compiler/ant/config/ConfigBoolean.java | 75 --- .../flex/compiler/ant/config/ConfigInt.java | 84 --- .../flex/compiler/ant/config/ConfigString.java | 70 --- .../compiler/ant/config/ConfigVariable.java | 54 -- .../flex/compiler/ant/config/IOptionSource.java | 33 -- .../ant/config/NestedAttributeElement.java | 170 ------ .../flex/compiler/ant/config/OptionSpec.java | 76 --- .../ant/config/RepeatableConfigString.java | 66 --- .../ant/config/RepeatableConfigVariable.java | 55 -- .../flex/compiler/ant/config/package.html | 27 - .../org/apache/flex/compiler/ant/package.html | 32 -- .../compiler/ant/types/DefaultScriptLimits.java | 79 --- .../flex/compiler/ant/types/DefaultSize.java | 71 --- .../flex/compiler/ant/types/FlexFileSet.java | 116 ----- .../flex/compiler/ant/types/FlexSWCFileSet.java | 55 -- .../apache/flex/compiler/ant/types/Fonts.java | 151 ------ .../flex/compiler/ant/types/Metadata.java | 168 ------ .../ant/types/RuntimeSharedLibraryPath.java | 92 ---- .../flex/compiler/ant/types/URLElement.java | 64 --- .../apache/flex/compiler/ant/types/package.html | 27 - compiler/src/main/resources/flexTasks.tasks | 21 - flexjs-ant-tasks/pom.xml | 44 ++ .../org/apache/flex/compiler/ant/COMPCTask.java | 512 +++++++++++++++++++ .../org/apache/flex/compiler/ant/FlexTask.java | 418 +++++++++++++++ .../org/apache/flex/compiler/ant/MXMLCTask.java | 493 ++++++++++++++++++ .../compiler/ant/config/BaseConfigVariable.java | 74 +++ .../compiler/ant/config/ConfigAppendString.java | 48 ++ .../flex/compiler/ant/config/ConfigBoolean.java | 75 +++ .../flex/compiler/ant/config/ConfigInt.java | 84 +++ .../flex/compiler/ant/config/ConfigString.java | 70 +++ .../compiler/ant/config/ConfigVariable.java | 54 ++ .../flex/compiler/ant/config/IOptionSource.java | 33 ++ .../ant/config/NestedAttributeElement.java | 170 ++++++ .../flex/compiler/ant/config/OptionSpec.java | 76 +++ .../ant/config/RepeatableConfigString.java | 66 +++ .../ant/config/RepeatableConfigVariable.java | 55 ++ .../flex/compiler/ant/config/package.html | 27 + .../org/apache/flex/compiler/ant/package.html | 32 ++ .../compiler/ant/types/DefaultScriptLimits.java | 79 +++ .../flex/compiler/ant/types/DefaultSize.java | 71 +++ .../flex/compiler/ant/types/FlexFileSet.java | 116 +++++ .../flex/compiler/ant/types/FlexSWCFileSet.java | 55 ++ .../apache/flex/compiler/ant/types/Fonts.java | 151 ++++++ .../flex/compiler/ant/types/Metadata.java | 168 ++++++ .../ant/types/RuntimeSharedLibraryPath.java | 92 ++++ .../flex/compiler/ant/types/URLElement.java | 64 +++ .../apache/flex/compiler/ant/types/package.html | 27 + .../src/main/resources/flexTasks.tasks | 21 + pom.xml | 1 + 55 files changed, 3182 insertions(+), 3131 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/pom.xml ---------------------------------------------------------------------- diff --git a/compiler/pom.xml b/compiler/pom.xml index c9745bd..7da563f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -407,6 +407,12 @@ <groupId>de.jflex</groupId> <artifactId>jflex</artifactId> <version>1.6.0</version> + <exclusions> + <exclusion> + <groupId>org.apache.ant</groupId> + <artifactId>ant</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.b1.pack</groupId> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java b/compiler/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java deleted file mode 100644 index 71ddc25..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java +++ /dev/null @@ -1,512 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant; - -import java.util.ArrayList; -import java.util.Iterator; -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DynamicConfigurator; - -import org.apache.flex.compiler.ant.config.ConfigBoolean; -import org.apache.flex.compiler.ant.config.ConfigInt; -import org.apache.flex.compiler.ant.config.ConfigString; -import org.apache.flex.compiler.ant.config.ConfigVariable; -import org.apache.flex.compiler.ant.config.NestedAttributeElement; -import org.apache.flex.compiler.ant.config.IOptionSource; -import org.apache.flex.compiler.ant.config.OptionSpec; -import org.apache.flex.compiler.ant.config.RepeatableConfigString; -import org.apache.flex.compiler.ant.types.DefaultScriptLimits; -import org.apache.flex.compiler.ant.types.DefaultSize; -import org.apache.flex.compiler.ant.types.FlexFileSet; -import org.apache.flex.compiler.ant.types.FlexSWCFileSet; -import org.apache.flex.compiler.ant.types.Fonts; -import org.apache.flex.compiler.ant.types.Metadata; -import org.apache.flex.compiler.ant.types.RuntimeSharedLibraryPath; - -/** - * Implements the {@code <compc>} Ant task. - * <p> - * For example: - * <pre> - * <compc fork="true" - * output="${FLEX_HOME}/frameworks/libs/sparkskins.swc" - * resource-bundle-list="${basedir}/bundles.properties"> - * <target-player>10</target-player> - * <jvmarg line="${compc.jvm.args}"/> - * <include-classes>SparkSkinsClasses</include-classes> - * <source-path path-element="${basedir}/src"/> - * <library-path/> - * <external-library-path dir="${FLEX_HOME}/frameworks/libs"> - * <include name="player/${local.playerglobal.version}/playerglobal.swc"/> - * <include name="framework.swc"/> - * <include name="spark.swc" /> - * <include name="textLayout.swc"/> - * </external-library-path> - * <locale/> - * <accessible>true</accessible> - * </compc> - * </pre> - * All the simple compc configuration parameters are supported as tag - * attributes. Complex configuration options, like - * -compiler.namespaces.namespace, are implemented as child tags. For - * example: - * <p> - * </code> - * <namespace uri="http://www.adobe.com/2006/mxml" manifest="${basedir}/manifest.xml"/> - * </code> - */ -public final class COMPCTask extends FlexTask implements DynamicConfigurator -{ - /*=======================================================================* - * Constants - *=======================================================================*/ - - private static final String TASK_NAME = "compc"; - - private static final String TOOL_JAR_FILE_NAME = "compiler.jar"; - - private static final String TOOL_CLASS_NAME = "org.apache.flex.compiler.clients.COMPC"; - - private static final String TOOL_METHOD_NAME = "staticMainNoExit"; - - private static final String TOOL_FAILURE_METHOD_NAME = "isFatalFailure"; // inherited from MXMLC - - private static final ConfigVariable[] CONFIG_VARIABLES = - { - // Basic Boolean options - new ConfigBoolean(new OptionSpec("benchmark")), - new ConfigBoolean(new OptionSpec("compiler.accessible")), - new ConfigBoolean(new OptionSpec("compiler.debug")), - new ConfigBoolean(new OptionSpec("compiler.incremental")), - new ConfigBoolean(new OptionSpec("compiler.mobile")), - new ConfigBoolean(new OptionSpec("compiler.optimize")), - new ConfigBoolean(new OptionSpec("compiler.report-invalid-styles-as-warnings")), - new ConfigBoolean(new OptionSpec("compiler.report-missing-required-skin-parts-as-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-actionscript-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-binding-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-deprecation-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-invalid-css-property-warnings")), - new ConfigBoolean(new OptionSpec("compiler.strict")), - new ConfigBoolean(new OptionSpec("compiler.use-resource-bundle-metadata")), - new ConfigBoolean(new OptionSpec("directory")), - new ConfigBoolean(new OptionSpec("use-network")), - new ConfigBoolean(new OptionSpec("warnings")), - - // Advanced Boolean options - new ConfigBoolean(new OptionSpec("compiler.allow-source-path-overlap")), - new ConfigBoolean(new OptionSpec("compiler.as3")), - new ConfigBoolean(new OptionSpec("compiler.doc")), - new ConfigBoolean(new OptionSpec("compiler.es")), - new ConfigBoolean(new OptionSpec("compiler.generate-abstract-syntax-tree")), - new ConfigBoolean(new OptionSpec("compiler.headless-server")), - new ConfigBoolean(new OptionSpec("compiler.isolate-styles")), - new ConfigBoolean(new OptionSpec("compiler.keep-all-type-selectors")), - new ConfigBoolean(new OptionSpec("compiler.keep-generated-actionscript", "keep")), - new ConfigBoolean(new OptionSpec("compiler.verbose-stacktraces")), - new ConfigBoolean(new OptionSpec("compiler.warn-array-tostring-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-assignment-within-conditional")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-array-cast")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-bool-assignment")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-date-cast")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-es3-type-method")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-es3-type-prop")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-nan-comparison")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-null-assignment")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-null-comparison")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-undefined-comparison")), - new ConfigBoolean(new OptionSpec("compiler.warn-boolean-constructor-with-no-args")), - new ConfigBoolean(new OptionSpec("compiler.warn-changes-in-resolve")), - new ConfigBoolean(new OptionSpec("compiler.warn-class-is-sealed")), - new ConfigBoolean(new OptionSpec("compiler.warn-const-not-initialized")), - new ConfigBoolean(new OptionSpec("compiler.warn-constructor-returns-value")), - new ConfigBoolean(new OptionSpec("compiler.warn-deprecated-event-handler-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-deprecated-function-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-deprecated-property-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-duplicate-argument-names")), - new ConfigBoolean(new OptionSpec("compiler.warn-duplicate-variable-def")), - new ConfigBoolean(new OptionSpec("compiler.warn-for-var-in-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-import-hides-classes")), - new ConfigBoolean(new OptionSpec("compiler.warn-instance-of-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-internal-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-level-not-supported")), - new ConfigBoolean(new OptionSpec("compiler.warn-missing-namespace-decl")), - new ConfigBoolean(new OptionSpec("compiler.warn-negative-uint-literal")), - new ConfigBoolean(new OptionSpec("compiler.warn-no-constructor")), - new ConfigBoolean(new OptionSpec("compiler.warn-no-explicit-super-call-in-constructor")), - new ConfigBoolean(new OptionSpec("compiler.warn-no-type-decl")), - new ConfigBoolean(new OptionSpec("compiler.warn-number-from-string-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-scoping-change-in-this")), - new ConfigBoolean(new OptionSpec("compiler.warn-slow-text-field-addition")), - new ConfigBoolean(new OptionSpec("compiler.warn-unlikely-function-value")), - new ConfigBoolean(new OptionSpec("compiler.warn-xml-class-has-changed")), - new ConfigBoolean(new OptionSpec("compiler.generate-abstract-syntax-tree")), - new ConfigBoolean(new OptionSpec("compute-digest")), - new ConfigBoolean(new OptionSpec("include-inheritance-dependencies-only")), - new ConfigBoolean(new OptionSpec("include-lookup-only")), - new ConfigBoolean(new OptionSpec("static-link-runtime-shared-libraries", "static-rsls")), - new ConfigBoolean(new OptionSpec("use-direct-blit")), - new ConfigBoolean(new OptionSpec("use-gpu")), - new ConfigBoolean(new OptionSpec("flex")), - - // String options - new ConfigString(new OptionSpec("compiler.actionscript-file-encoding")), - new ConfigString(new OptionSpec("compiler.context-root")), - new ConfigString(new OptionSpec("compiler.defaults-css-url")), - new ConfigString(new OptionSpec("compiler.enable-swc-version-filtering", "esvf")), - new ConfigString(new OptionSpec("compiler.locale")), - new ConfigString(new OptionSpec("compiler.minimum-supported-version", "msv")), - new ConfigString(new OptionSpec("compiler.services")), - new ConfigString(new OptionSpec("debug-password")), - new ConfigString(new OptionSpec("dump-config")), - new ConfigString(new OptionSpec("link-report")), - new ConfigString(new OptionSpec("load-externs")), - new ConfigString(new OptionSpec("raw-metadata")), - new ConfigString(new OptionSpec("resource-bundle-list")), - new ConfigString(new OptionSpec("size-report")), - new ConfigString(new OptionSpec("target-player")), - new ConfigString(new OptionSpec("tools-locale")), - - // Int options - new ConfigInt(new OptionSpec("default-background-color")), - new ConfigInt(new OptionSpec("default-frame-rate")), - new ConfigInt(new OptionSpec("swf-version")) - }; - - private static final OptionSpec NAMESPACE = - new OptionSpec("compiler.namespaces.namespace"); - - private static final OptionSpec LICENSE = - new OptionSpec("licenses.license"); - - private static final OptionSpec EXTERNS = - new OptionSpec("externs"); - - private static final OptionSpec INCLUDES = - new OptionSpec("includes"); - - private static final OptionSpec RUNTIME_SHARED_LIBRARIES = - new OptionSpec("runtime-shared-libraries", "rsl"); - - private static final OptionSpec FRAME = - new OptionSpec("frames.frame"); - - private static final OptionSpec DEFINE = - new OptionSpec("compiler.define"); - - private static final OptionSpec EXTERNAL_LIBRARY_PATH = - new OptionSpec("compiler.external-library-path", "el"); - - private static final OptionSpec INCLUDE_LIBRARIES = - new OptionSpec("compiler.include-libraries"); - - private static final OptionSpec LIBRARY_PATH = - new OptionSpec("compiler.library-path", "l"); - - private static final OptionSpec SOURCE_PATH = - new OptionSpec("compiler.source-path", "sp"); - - private static final OptionSpec THEME = - new OptionSpec("compiler.theme"); - - private static final OptionSpec KEEP_AS3_METADATA = - new OptionSpec("compiler.keep-as3-metadata"); - - private static final OptionSpec LOAD_CONFIG = - new OptionSpec("load-config"); - - private static final OptionSpec INCLUDE_CLASSES = - new OptionSpec("include-classes", "ic"); - - private static final OptionSpec INCLUDE_FILE = - new OptionSpec("include-file", "if"); - - private static final OptionSpec INCLUDE_NAMESPACES = - new OptionSpec("include-namespaces", "in"); - - private static final OptionSpec INCLUDE_RESOURCE_BUNDLES = - new OptionSpec("include-resource-bundles", "ir"); - - private static final OptionSpec INCLUDE_SOURCES = - new OptionSpec("include-sources", "is"); - - /*=======================================================================* - * Variables - *=======================================================================*/ - - private final ConfigString output; - private final RepeatableConfigString includeClasses; - - private Metadata metadata; - private Fonts fonts; - private DefaultScriptLimits defaultScriptLimits; - private DefaultSize defaultSize; - - private final ArrayList<IOptionSource> nestedFileSets; - - /*=======================================================================* - * Constructor - *=======================================================================*/ - - /** - * Constructor. - */ - public COMPCTask() - { - super(TASK_NAME, CONFIG_VARIABLES, TOOL_JAR_FILE_NAME, - TOOL_CLASS_NAME, TOOL_METHOD_NAME, TOOL_FAILURE_METHOD_NAME); - - nestedAttribs = new ArrayList<IOptionSource>(); - nestedFileSets = new ArrayList<IOptionSource>(); - - output = new ConfigString(new OptionSpec("output", "o")); - includeClasses = new RepeatableConfigString(new OptionSpec("include-classes", "ic")); - } - - /*=======================================================================* - * Required Attributes * - *=======================================================================*/ - - // output="..." - - /* - * Necessary to override inherited setOutput method since ant gives - * priority to parameter types more specific than String. - */ - public void setOutput(File o) - { - setDynamicAttribute("output", o.getAbsolutePath()); - } - - // other attributes - - public void setDynamicAttribute(String name, String value) - { - // Handle required attributes and then delegate to super. - if (output.matches(name)) - output.set(value); - - else if (includeClasses.matches(name)) - includeClasses.addAll(value.split(" ")); - - else - super.setDynamicAttribute(name, value); - } - - /*=======================================================================* - * Child Elements * - *=======================================================================*/ - - // <metadata> - - public Metadata createMetadata() - { - if (metadata == null) - return metadata = new Metadata(); - else - throw new BuildException("Only one nested <metadata> element is allowed in an <" + TASK_NAME + "> task."); - } - - // <fonts> - - public Fonts createFonts() - { - if (fonts == null) - return fonts = new Fonts(this); - else - throw new BuildException("Only one nested <fonts> element is allowed in an <" + TASK_NAME + "> task."); - } - - // <namespace> - - public NestedAttributeElement createNamespace() - { - return createElem(new String[] { "uri", "manifest" }, NAMESPACE); - } - - // <license> - - public NestedAttributeElement createLicense() - { - return createElem(new String[] { "product", "serial-number" }, LICENSE); - } - - // <externs> - - public NestedAttributeElement createExterns() - { - return createElem("symbol", EXTERNS); - } - - // <include> - - public NestedAttributeElement createIncludes() - { - return createElem("symbol", INCLUDES); - } - - // <frame> - - public NestedAttributeElement createFrame() - { - return createElem(new String[] { "label", "classname" }, FRAME); - } - - // other child elements - - public Object createDynamicElement(String name) - { - if (KEEP_AS3_METADATA.matches(name)) - { - return createElem("name", KEEP_AS3_METADATA); - } - else if (RUNTIME_SHARED_LIBRARIES.matches(name)) - { - return createElem("url", RUNTIME_SHARED_LIBRARIES); - } - else if (RUNTIME_SHARED_LIBRARY_PATH.matches(name)) - { - RuntimeSharedLibraryPath runtimeSharedLibraryPath = new RuntimeSharedLibraryPath(); - nestedAttribs.add(runtimeSharedLibraryPath); - return runtimeSharedLibraryPath; - } - else if (DEFINE.matches(name)) - { - return createElem(new String[] { "name", "value" }, DEFINE); - } - else if (LOAD_CONFIG.matches(name)) - { - return createElemAllowAppend(new String[] {"filename"} , LOAD_CONFIG); - } - else if (SOURCE_PATH.matches(name)) - { - return createElem("path-element", SOURCE_PATH); - } - else if (DefaultScriptLimits.DEFAULT_SCRIPT_LIMITS.matches(name)) - { - if (defaultScriptLimits == null) - return defaultScriptLimits = new DefaultScriptLimits(); - else - throw new BuildException("Only one nested <default-script-limits> element is allowed in an <" + TASK_NAME + "> task."); - } - else if (DefaultSize.DEFAULT_SIZE.matches(name)) - { - if (defaultSize == null) - return defaultSize = new DefaultSize(); - else - throw new BuildException("Only one nested <default-size> element is allowed in an <" + TASK_NAME + "> task."); - } - else if (EXTERNAL_LIBRARY_PATH.matches(name)) - { - FlexFileSet fs = new FlexSWCFileSet(EXTERNAL_LIBRARY_PATH, true); - nestedFileSets.add(fs); - return fs; - } - else if (INCLUDE_LIBRARIES.matches(name)) - { - FlexFileSet fs = new FlexSWCFileSet(INCLUDE_LIBRARIES, true); - nestedFileSets.add(fs); - return fs; - } - else if (LIBRARY_PATH.matches(name)) - { - FlexFileSet fs = new FlexSWCFileSet(LIBRARY_PATH, true); - nestedFileSets.add(fs); - return fs; - } - else if (THEME.matches(name)) - { - FlexFileSet fs = new FlexFileSet(THEME); - nestedFileSets.add(fs); - return fs; - } - else if (EXTERNS.matches(name)) - { - return createExterns(); - } - /* The following are unique to compc */ - else if (INCLUDE_CLASSES.matches(name)) - { - return createElem("class", INCLUDE_CLASSES); - } - else if (INCLUDE_FILE.matches(name)) - { - return createElem(new String[] { "name", "path" }, INCLUDE_FILE); - } - else if (INCLUDE_NAMESPACES.matches(name)) - { - return createElemAllowAppend(new String[] { "uri" }, INCLUDE_NAMESPACES); - } - else if (INCLUDE_SOURCES.matches(name)) - { - FlexFileSet fs = new FlexFileSet(INCLUDE_SOURCES, true); - nestedFileSets.add(fs); - return fs; - } - else if (INCLUDE_RESOURCE_BUNDLES.matches(name)) - { - return createElem("bundle", INCLUDE_RESOURCE_BUNDLES); - } - - return super.createDynamicElement(name); - } - - /*=======================================================================* - * Execute and Related Functions * - *=======================================================================*/ - - protected void prepareCommandline() throws BuildException - { - for (int i = 0; i < configVariables.length; i++) - { - configVariables[i].addToCommandline(cmdline); - } - - if (metadata != null) - metadata.addToCommandline(cmdline); - - if(fonts != null) - fonts.addToCommandline(cmdline); - - if (defaultScriptLimits != null) - defaultScriptLimits.addToCommandline(cmdline); - - if (defaultSize != null) - defaultSize.addToCommandline(cmdline); - - includeClasses.addToCommandline(cmdline); - - Iterator<IOptionSource> it = nestedAttribs.iterator(); - - while (it.hasNext()) - it.next().addToCommandline(cmdline); - - it = nestedFileSets.iterator(); - - while (it.hasNext()) - it.next().addToCommandline(cmdline); - - if (output.isSet()) - output.addToCommandline(cmdline); - else - throw new BuildException(output.getSpec().getFullName() + " attribute must be set!", getLocation()); - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/FlexTask.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/FlexTask.java b/compiler/src/main/java/org/apache/flex/compiler/ant/FlexTask.java deleted file mode 100644 index 6b32540..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/FlexTask.java +++ /dev/null @@ -1,418 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant; - -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.List; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Environment.Variable; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.taskdefs.Java; - -import org.apache.flex.compiler.ant.config.ConfigVariable; -import org.apache.flex.compiler.ant.config.NestedAttributeElement; -import org.apache.flex.compiler.ant.config.IOptionSource; -import org.apache.flex.compiler.ant.config.OptionSpec; - -/** - * This class contains common data and logic used by all the Flex Ant tasks. - */ -public abstract class FlexTask extends Java -{ - protected static OptionSpec RUNTIME_SHARED_LIBRARY_PATH = - new OptionSpec("runtime-shared-library-path", "rslp"); - - /** - * Constructor. - * - * @param taskName The name of the Ant task. - * @param configVariables An array of ConfigVariables that will be set by attributes of the task. - * @param toolJARFileName The build tool's jar file. - * @param toolClassName The build tool's class name. - * @param toolMethodName The build tool's method name. - * @param toolFailureMethodName The build tool's method to determine - * whether an exit code means failure. - */ - protected FlexTask(String taskName, ConfigVariable[] configVariables, - String toolJARFileName, String toolClassName, - String toolMethodName, String toolFailureMethodName) - { - this.taskName = taskName; - this.configVariables = configVariables; - this.toolJARFileName = toolJARFileName; - this.toolClassName = toolClassName; - this.toolMethodName = toolMethodName; - this.toolFailureMethodName = toolFailureMethodName; - - cmdline = new Commandline(); - } - - /** - * The name of the Ant task. - */ - private final String taskName; - - /** - * An array of ConfigVariabes that are set by setDynamicAttribute(). - */ - protected final ConfigVariable[] configVariables; - - /** - * The build tool's jar file name. - */ - private final String toolJARFileName; - - /** - * The build tool's class name. - */ - private final String toolClassName; - - /** - * The build tool's entry point. - * It must be a static method that takes a String[] - * and returns an int exit code. - */ - private final String toolMethodName; - - /** - * The build tools' method that determines whether the - * exit code should make the Ant task fail. - * It must be a static method that takes an int - * and returns a boolean. - */ - private final String toolFailureMethodName; - - /** - * The commandline used in execute() - */ - protected final Commandline cmdline; - - protected List<IOptionSource> nestedAttribs; - - /** - * fork attribute - */ - protected boolean fork; - - private ClassLoader originalContextClassLoader; - - protected NestedAttributeElement createElem(String attrib, OptionSpec spec) - { - NestedAttributeElement e = new NestedAttributeElement(attrib, spec, this); - nestedAttribs.add(e); - return e; - } - - protected NestedAttributeElement createElem(String[] attribs, OptionSpec spec) - { - NestedAttributeElement e = new NestedAttributeElement(attribs, spec, this); - nestedAttribs.add(e); - return e; - } - - protected NestedAttributeElement createElemAllowAppend(String[] attribs, OptionSpec spec) - { - NestedAttributeElement e = new NestedAttributeElement(attribs, spec, this, true); - nestedAttribs.add(e); - return e; - } - - /*=======================================================================* - * Static Attributes * - *=======================================================================*/ - /** - * Sets whether to run the task in a separate VM. - * - * @param f if true then run in a separate VM. - */ - public void setFork(boolean f) - { - super.setFork(f); - this.fork = f; - } - - /*=======================================================================* - * Dynamic Attributes * - *=======================================================================*/ - - /** - * Set the named attribute to the given value. - * - * @param attributeName The name of the attribute to set - * @param value The value to set the named attribute to - */ - public void setDynamicAttribute(String attributeName, String value) - { - ConfigVariable var = null; - - for (int i = 0; i < configVariables.length && var == null; i++) - { - if (configVariables[i].matches(attributeName)) - var = configVariables[i]; - } - - if (var != null) - { - var.set(value); - } - else - { - throw new BuildException("The <" + taskName + "> type doesn't support the \"" + - attributeName + "\" attribute.", getLocation()); - } - } - - /*=======================================================================* - * Dynamic Elements * - *=======================================================================*/ - - public Object createDynamicElement(String elementName) - { - ConfigVariable var = null; - - for (int i = 0; i < configVariables.length && var == null; i++) - { - if (configVariables[i].matches(elementName)) - var = configVariables[i]; - } - - if (var != null) - { - return createElem(elementName, var.getSpec()); - } - else - { - throw new BuildException("The <" + taskName + "> type doesn't support the \"" + - elementName + "\" nested element.", getLocation()); - } - } - - /*=======================================================================* - * Execute and Related Functions * - *=======================================================================*/ - - /** - * Called by execute after the set ConfigVariables in <code>vars</code> has - * been added to the commandline. This function is responsible for adding - * all tool-specific options to the commandline as well as setting the - * default options of a build tool. - */ - protected abstract void prepareCommandline() throws BuildException; - - /** - * Execute the task - * - * @throws BuildException If running build tool failed - */ - public final void execute() throws BuildException - { - String flexHomeProperty = getProject().getProperty("FLEX_HOME"); - - if (flexHomeProperty == null) - throw new BuildException("FLEX_HOME must be set to use the Flex Ant Tasks"); - - String falconHomeProperty = getProject().getProperty("FALCON_HOME"); - if (falconHomeProperty == null) - throw new BuildException("FALCON_HOME must be set to use the Flex Ant Tasks"); - - System.setProperty("FLEX_HOME", flexHomeProperty); - String flexlibProperty = flexHomeProperty.concat("/frameworks/"); - System.setProperty("flexlib", flexlibProperty); - - final Variable variable = new Variable(); - variable.setKey("flexlib"); - variable.setValue(flexHomeProperty); - addSysproperty(variable); - - // This allows the tool to find the default config file. - cmdline.createArgument().setValue("+flexlib=" + flexlibProperty); - - prepareCommandline(); - - if (fork) - executeOutOfProcess(); - else - executeInProcess(); - } - - /** - * Executes the task in a separate VM - */ - private void executeOutOfProcess() throws BuildException - { - try - { - // Without this, the tool class won't be found by executeJava(). - Class<?> toolClass = resolveClass(toolClassName); - - super.setClassname(toolClassName); - - // convert arguments into a string for use by executeJava() - // also auto-quotes arguments with spaces - String line = Commandline.toString(cmdline.getArguments()); - super.createArg().setLine(line); - - int exitCode = super.executeJava(); - - // Check exit code. - if (isFatalFailure(toolClass, exitCode)) - throw new BuildException(taskName + " task failed."); - } - finally - { - if (originalContextClassLoader != null) - Thread.currentThread().setContextClassLoader(originalContextClassLoader); - } - } - - /** - * Executes the task in the same VM - */ - private void executeInProcess() throws BuildException - { - try - { - Class<?> toolClass = resolveClass(toolClassName); - - log("FlexTask.execute: " + cmdline, Project.MSG_DEBUG); - - int exitCode = -1; - - try - { - Method toolMethod = toolClass.getMethod(toolMethodName, new Class[] {String[].class}); - Object result = toolMethod.invoke(null, new Object[] {cmdline.getArguments()}); - exitCode = ((Integer)result).intValue(); - } - catch (Exception e) - { - StringWriter stringWriter = new StringWriter(); - PrintWriter printWriter = new PrintWriter(stringWriter); - e.printStackTrace(printWriter); - log(stringWriter.toString(), Project.MSG_DEBUG); - throw new BuildException("Unable to run " + toolMethodName + ": " + e.getMessage(), e); - } - - if (isFatalFailure(toolClass, exitCode)) - throw new BuildException(taskName + " task failed");// } - } - finally - { - if (originalContextClassLoader != null) - Thread.currentThread().setContextClassLoader(originalContextClassLoader); - } - } - - private boolean isFatalFailure(Class<?> toolClass, int exitCode) - { - boolean fatal = true; - - try - { - Method toolFailureMethod = toolClass.getMethod(toolFailureMethodName, new Class[] {int.class}); - Object result = toolFailureMethod.invoke(null, new Object[] {exitCode}); - fatal = ((Boolean)result).booleanValue(); - } - catch (Exception e) - { - StringWriter stringWriter = new StringWriter(); - PrintWriter printWriter = new PrintWriter(stringWriter); - e.printStackTrace(printWriter); - log(stringWriter.toString(), Project.MSG_DEBUG); - throw new BuildException("Unable to run " + toolFailureMethodName + ": " + e.getMessage(), e); - } - - return fatal; - } - - private Class<?> resolveClass(String className) - { - Class<?> result = null; - - try - { - result = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); - } - catch (ClassNotFoundException ignoredClassNotFoundException) - { - String flexHomeProperty = getProject().getProperty("FALCON_HOME"); - - if (flexHomeProperty != null) - { - File flexHome = new File(flexHomeProperty); - - if ( flexHome.exists() ) - { - File jarFile = new File(flexHome + "/lib", toolJARFileName); - - if (jarFile.exists()) - { - try - { - URL url = jarFile.toURI().toURL(); - URLClassLoader urlClassLoader = new URLClassLoader(new URL[] {url}); - result = Class.forName(className, true, urlClassLoader); - originalContextClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(urlClassLoader); - - if (fork) - super.setClasspath(new Path(getProject(), jarFile.getAbsolutePath())); - } - catch (MalformedURLException malformedURLException) - { - // We shouldn't really get here, but just in case. - malformedURLException.printStackTrace(); - } - catch (ClassNotFoundException classNotFoundException) - { - throw new BuildException("The class " + className + " was not found in jar file " + toolJARFileName, - getLocation()); - } - } - else - { - throw new BuildException("File does not exist: " + toolJARFileName, getLocation()); - } - } - else - { - throw new BuildException("FALCON_HOME does not exist.", getLocation()); - } - } - else - { - throw new BuildException("The class, " + className + - ", must be in the classpath or the FALCON_HOME property must be set.", - getLocation()); - } - } - - return result; - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java b/compiler/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java deleted file mode 100644 index 5df9ddd..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DynamicConfigurator; - -import org.apache.flex.compiler.ant.config.ConfigAppendString; -import org.apache.flex.compiler.ant.config.ConfigBoolean; -import org.apache.flex.compiler.ant.config.ConfigInt; -import org.apache.flex.compiler.ant.config.ConfigString; -import org.apache.flex.compiler.ant.config.ConfigVariable; -import org.apache.flex.compiler.ant.config.NestedAttributeElement; -import org.apache.flex.compiler.ant.config.IOptionSource; -import org.apache.flex.compiler.ant.config.OptionSpec; -import org.apache.flex.compiler.ant.types.DefaultScriptLimits; -import org.apache.flex.compiler.ant.types.DefaultSize; -import org.apache.flex.compiler.ant.types.FlexFileSet; -import org.apache.flex.compiler.ant.types.FlexSWCFileSet; -import org.apache.flex.compiler.ant.types.Fonts; -import org.apache.flex.compiler.ant.types.Metadata; -import org.apache.flex.compiler.ant.types.RuntimeSharedLibraryPath; - -/** - * Implements the {@code <mxmlc>} Ant task. - * <p> - * For example: - * <pre> - * <mxmlc file="${bug}.mxml" - * debug="false" - * keep="true" - * verbose-stacktraces="false" - * incremental="false" - * strict="true" - * benchmark="true" - * report-invalid-styles-as-warnings="true" - * show-invalid-css-property-warnings="false" - * tools-locale="de_DE" - * fork="false"> - * <source-path path-element="${FLEX_HOME}/frameworks/projects/framework/src"/> - * </mxmlc> - * </pre> - * - * All the simple mxmlc configuration parameters are supported as tag - * attributes. Complex configuration options, like - * -compiler.namespaces.namespace, are implemented as child tags. For - * example: - * <p> - * <code> - * <namespace uri="http://www.adobe.com/2006/mxml" manifest="${basedir}/manifest.xml"/> - * </code> - */ -public final class MXMLCTask extends FlexTask implements DynamicConfigurator -{ - /*=======================================================================* - * Constants - *=======================================================================*/ - - private static final String TASK_NAME = "mxmlc"; - - private static final String TOOL_JAR_FILE_NAME = "compiler.jar"; - - private static final String TOOL_CLASS_NAME = "org.apache.flex.compiler.clients.MXMLC"; - - private static final String TOOL_METHOD_NAME = "staticMainNoExit"; - - private static final String TOOL_FAILURE_METHOD_NAME = "isFatalFailure"; - - private static final ConfigVariable[] CONFIG_VARIABLES = - { - // Basic Boolean options - new ConfigBoolean(new OptionSpec("benchmark")), - new ConfigBoolean(new OptionSpec("compiler.accessible")), - new ConfigBoolean(new OptionSpec("compiler.debug")), - new ConfigBoolean(new OptionSpec("compiler.incremental")), - new ConfigBoolean(new OptionSpec("compiler.mobile")), - new ConfigBoolean(new OptionSpec("compiler.optimize")), - new ConfigBoolean(new OptionSpec("compiler.report-invalid-styles-as-warnings")), - new ConfigBoolean(new OptionSpec("compiler.report-missing-required-skin-parts-as-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-actionscript-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-binding-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-deprecation-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-invalid-css-property-warnings")), - new ConfigBoolean(new OptionSpec("compiler.show-unused-type-selector-warnings")), - new ConfigBoolean(new OptionSpec("compiler.strict")), - new ConfigBoolean(new OptionSpec("compiler.use-resource-bundle-metadata")), - new ConfigBoolean(new OptionSpec("remove-unused-rsls")), - new ConfigBoolean(new OptionSpec("use-network")), - new ConfigBoolean(new OptionSpec("warnings")), - - // Advanced Boolean options - new ConfigBoolean(new OptionSpec("compiler.allow-source-path-overlap")), - new ConfigBoolean(new OptionSpec("compiler.as3")), - new ConfigBoolean(new OptionSpec("compiler.doc")), - new ConfigBoolean(new OptionSpec("compiler.es")), - new ConfigBoolean(new OptionSpec("compiler.generate-abstract-syntax-tree")), - new ConfigBoolean(new OptionSpec("compiler.headless-server")), - new ConfigBoolean(new OptionSpec("compiler.isolate-styles")), - new ConfigBoolean(new OptionSpec("compiler.keep-all-type-selectors")), - new ConfigBoolean(new OptionSpec("compiler.keep-generated-actionscript", "keep")), - new ConfigBoolean(new OptionSpec("compiler.verbose-stacktraces")), - new ConfigBoolean(new OptionSpec("compiler.warn-array-tostring-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-assignment-within-conditional")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-array-cast")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-bool-assignment")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-date-cast")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-es3-type-method")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-es3-type-prop")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-nan-comparison")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-null-assignment")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-null-comparison")), - new ConfigBoolean(new OptionSpec("compiler.warn-bad-undefined-comparison")), - new ConfigBoolean(new OptionSpec("compiler.warn-boolean-constructor-with-no-args")), - new ConfigBoolean(new OptionSpec("compiler.warn-changes-in-resolve")), - new ConfigBoolean(new OptionSpec("compiler.warn-class-is-sealed")), - new ConfigBoolean(new OptionSpec("compiler.warn-const-not-initialized")), - new ConfigBoolean(new OptionSpec("compiler.warn-constructor-returns-value")), - new ConfigBoolean(new OptionSpec("compiler.warn-deprecated-event-handler-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-deprecated-function-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-deprecated-property-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-duplicate-argument-names")), - new ConfigBoolean(new OptionSpec("compiler.warn-duplicate-variable-def")), - new ConfigBoolean(new OptionSpec("compiler.warn-for-var-in-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-import-hides-classes")), - new ConfigBoolean(new OptionSpec("compiler.warn-instance-of-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-internal-error")), - new ConfigBoolean(new OptionSpec("compiler.warn-level-not-supported")), - new ConfigBoolean(new OptionSpec("compiler.warn-missing-namespace-decl")), - new ConfigBoolean(new OptionSpec("compiler.warn-negative-uint-literal")), - new ConfigBoolean(new OptionSpec("compiler.warn-no-constructor")), - new ConfigBoolean(new OptionSpec("compiler.warn-no-explicit-super-call-in-constructor")), - new ConfigBoolean(new OptionSpec("compiler.warn-no-type-decl")), - new ConfigBoolean(new OptionSpec("compiler.warn-number-from-string-changes")), - new ConfigBoolean(new OptionSpec("compiler.warn-scoping-change-in-this")), - new ConfigBoolean(new OptionSpec("compiler.warn-slow-text-field-addition")), - new ConfigBoolean(new OptionSpec("compiler.warn-unlikely-function-value")), - new ConfigBoolean(new OptionSpec("compiler.warn-xml-class-has-changed")), - new ConfigBoolean(new OptionSpec("static-link-runtime-shared-libraries", "static-rsls")), - new ConfigBoolean(new OptionSpec("verify-digests")), - new ConfigBoolean(new OptionSpec("use-direct-blit")), - new ConfigBoolean(new OptionSpec("use-gpu")), - new ConfigBoolean(new OptionSpec("flex")), - - // String options - new ConfigString(new OptionSpec("compiler.actionscript-file-encoding")), - new ConfigString(new OptionSpec("compiler.context-root")), - new ConfigString(new OptionSpec("compiler.defaults-css-url")), - new ConfigString(new OptionSpec("compiler.locale")), - new ConfigString(new OptionSpec("compiler.mxml.compatibility-version")), - new ConfigString(new OptionSpec("compiler.services")), - new ConfigString(new OptionSpec("debug-password")), - new ConfigString(new OptionSpec("dump-config")), - new ConfigString(new OptionSpec("link-report")), - new ConfigString(new OptionSpec("load-externs")), - new ConfigString(new OptionSpec("output", "o")), - new ConfigString(new OptionSpec("raw-metadata")), - new ConfigString(new OptionSpec("resource-bundle-list")), - new ConfigString(new OptionSpec("size-report")), - new ConfigString(new OptionSpec("target-player")), - new ConfigString(new OptionSpec("tools-locale")), - new ConfigAppendString(new OptionSpec("configname")), - - // Int options - new ConfigInt(new OptionSpec("default-background-color")), - new ConfigInt(new OptionSpec("default-frame-rate")), - new ConfigInt(new OptionSpec("swf-version")) - }; - - private static final OptionSpec NAMESPACE = - new OptionSpec("compiler.namespaces.namespace"); - - private static final OptionSpec LICENSE = - new OptionSpec("licenses.license"); - - private static final OptionSpec EXTERNS = - new OptionSpec("externs"); - - private static final OptionSpec INCLUDES = - new OptionSpec("includes"); - - private static final OptionSpec INCLUDE_RESOURCE_BUNDLES = - new OptionSpec("include-resource-bundles", "ir"); - - private static final OptionSpec RUNTIME_SHARED_LIBRARIES = - new OptionSpec("runtime-shared-libraries", "rsl"); - - private static final OptionSpec FRAME = - new OptionSpec("frames.frame"); - - private static final OptionSpec DEFINE = - new OptionSpec("compiler.define"); - - private static final OptionSpec EXTERNAL_LIBRARY_PATH = - new OptionSpec("compiler.external-library-path", "el"); - - private static final OptionSpec INCLUDE_LIBRARIES = - new OptionSpec("compiler.include-libraries"); - - private static final OptionSpec LIBRARY_PATH = - new OptionSpec("compiler.library-path", "l"); - - private static final OptionSpec SOURCE_PATH = - new OptionSpec("compiler.source-path", "sp"); - - private static final OptionSpec THEME = - new OptionSpec("compiler.theme"); - - private static final OptionSpec LOAD_CONFIG = - new OptionSpec("load-config"); - - private static final OptionSpec KEEP_AS3_METADATA = - new OptionSpec("compiler.keep-as3-metadata"); - - private static final OptionSpec FORCE_RSLS = new OptionSpec( - "runtime-shared-library-settings.force-rsls"); - - private static final OptionSpec APPLICATION_DOMAIN = new OptionSpec( - "runtime-shared-library-settings.application-domain", "rsl-domain"); - - /*=======================================================================* - * Variables - *=======================================================================*/ - - private String file; - private String output; - - private Metadata metadata; - private Fonts fonts; - private DefaultScriptLimits defaultScriptLimits; - private DefaultSize defaultSize; - - private final List<IOptionSource> nestedFileSets; - - /*=======================================================================* - * Constructor. * - *=======================================================================*/ - - /** - * Constructor. - */ - public MXMLCTask() - { - super(TASK_NAME, CONFIG_VARIABLES, TOOL_JAR_FILE_NAME, - TOOL_CLASS_NAME, TOOL_METHOD_NAME, TOOL_FAILURE_METHOD_NAME); - - nestedAttribs = new ArrayList<IOptionSource>(); - nestedFileSets = new ArrayList<IOptionSource>(); - } - - /*=======================================================================* - * Required Attributes * - *=======================================================================*/ - - // file="..." - - public void setFile(String file) - { - this.file = file; - } - - /*=======================================================================* - * Other Attributes * - *=======================================================================*/ - - // output="..." - - /* - * Necessary to override inherited setOutput method since ant gives - * priority to parameter types more specific than String. - */ - public void setOutput(File o) - { - setOutput(o.getAbsolutePath()); - } - - public void setOutput(String o) - { - this.output = o; - } - - /*=======================================================================* - * Child Elements * - *=======================================================================*/ - - // <metadata> - - public Metadata createMetadata() - { - if (metadata == null) - return metadata = new Metadata(); - else - throw new BuildException("Only one nested <metadata> element is allowed in an " + TASK_NAME + " task."); - } - - // <fonts> - - public Fonts createFonts() - { - if (fonts == null) - return fonts = new Fonts(this); - else - throw new BuildException("Only one nested <fonts> element is allowed in an " + TASK_NAME + " task."); - } - - // <namespace> - - public NestedAttributeElement createNamespace() - { - return createElem(new String[] { "uri", "manifest" }, NAMESPACE); - } - - // <license> - - public NestedAttributeElement createLicense() - { - return createElem(new String[] { "product", "serial-number" }, LICENSE); - } - - // <externs> - - public NestedAttributeElement createExterns() - { - return createElem("symbol", EXTERNS); - } - - // <includes> - - public NestedAttributeElement createIncludes() - { - return createElem("symbol", INCLUDES); - } - - // <frame> - - public NestedAttributeElement createFrame() - { - return createElem(new String[] { "label", "classname" }, FRAME); - } - - // other child elements - - public Object createDynamicElement(String name) - { - if (KEEP_AS3_METADATA.matches(name)) - { - return createElem("name", KEEP_AS3_METADATA); - } - else if (DEFINE.matches(name)) - { - return createElem(new String[] { "name", "value" }, DEFINE); - } - else if (RUNTIME_SHARED_LIBRARIES.matches(name)) - { - return createElem("url", RUNTIME_SHARED_LIBRARIES); - } - else if (RUNTIME_SHARED_LIBRARY_PATH.matches(name)) - { - RuntimeSharedLibraryPath runtimeSharedLibraryPath = new RuntimeSharedLibraryPath(); - nestedAttribs.add(runtimeSharedLibraryPath); - return runtimeSharedLibraryPath; - } - else if (LOAD_CONFIG.matches(name)) - { - return createElemAllowAppend(new String[] {"filename"} , LOAD_CONFIG); - } - else if (SOURCE_PATH.matches(name)) - { - return createElem("path-element", SOURCE_PATH); - } - else if (DefaultScriptLimits.DEFAULT_SCRIPT_LIMITS.matches(name)) - { - if (defaultScriptLimits == null) - return defaultScriptLimits = new DefaultScriptLimits(); - else - throw new BuildException("Only one nested <default-script-limits> element is allowed in an " + TASK_NAME + " task."); - } - else if (DefaultSize.DEFAULT_SIZE.matches(name)) - { - if (defaultSize == null) - return defaultSize = new DefaultSize(); - else - throw new BuildException("Only one nested <default-size> element is allowed in an " + TASK_NAME + " task."); - } - else if (EXTERNAL_LIBRARY_PATH.matches(name)) - { - FlexFileSet fs = new FlexSWCFileSet(EXTERNAL_LIBRARY_PATH, true); - nestedFileSets.add(fs); - return fs; - } - else if (INCLUDE_LIBRARIES.matches(name)) - { - FlexFileSet fs = new FlexSWCFileSet(INCLUDE_LIBRARIES, true); - nestedFileSets.add(fs); - return fs; - } - else if (LIBRARY_PATH.matches(name)) - { - FlexFileSet fs = new FlexSWCFileSet(LIBRARY_PATH, true); - nestedFileSets.add(fs); - return fs; - } - else if (THEME.matches(name)) - { - FlexFileSet fs = new FlexFileSet(THEME); - nestedFileSets.add(fs); - return fs; - } - else if (INCLUDE_RESOURCE_BUNDLES.matches(name)) - { - return createElem("bundle", INCLUDE_RESOURCE_BUNDLES); - } - else if (FORCE_RSLS.matches(name)) - { - FlexFileSet fs = new FlexFileSet(FORCE_RSLS); - nestedFileSets.add(fs); - return fs; - } - else if (APPLICATION_DOMAIN.matches(name)) - { - return createElem(new String[] { "path-element", "application-domain-target" }, APPLICATION_DOMAIN); - } - - return super.createDynamicElement(name); - } - - /*=======================================================================* - * Execute and Related Functions * - *=======================================================================*/ - - protected void prepareCommandline() throws BuildException - { - for (int i = 0; i < configVariables.length; i++) - { - configVariables[i].addToCommandline(cmdline); - } - - if (metadata != null) - metadata.addToCommandline(cmdline); - - if(fonts != null) - fonts.addToCommandline(cmdline); - - if (defaultScriptLimits != null) - defaultScriptLimits.addToCommandline(cmdline); - - if (defaultSize != null) - defaultSize.addToCommandline(cmdline); - - Iterator<IOptionSource> it = nestedAttribs.iterator(); - - while (it.hasNext()) - { - ((IOptionSource)it.next()).addToCommandline(cmdline); - } - - it = nestedFileSets.iterator(); - - while (it.hasNext()) - ((IOptionSource)it.next()).addToCommandline(cmdline); - - if (output != null) - (new ConfigString(new OptionSpec("output", "o"), output)).addToCommandline(cmdline); - - // end of arguments - cmdline.createArgument().setValue("--"); - - // file-DEFAULT_SCRIPT_LIMITS may not be specified if building, e.g. a resource bundle SWF - if (file != null) - cmdline.createArgument().setValue(file); - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java deleted file mode 100644 index 7253d22..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -import org.apache.tools.ant.types.Commandline; - -/** - * Provides a base class for <code>ConfigVariable</code> and - * <code>RepeatableConfigVariable</code>. This abstract class encapsulates all - * of the functionality that any ConfigVariable must have that does not - * involve "setting" it. - * - * Consumers of this class must implement the <code>addToCommandline</code> - * method. - */ -public abstract class BaseConfigVariable implements IOptionSource -{ - /** - * Constructor. - * <p> - * Creates a Configuration Variable with the specified <code>OptionSpec</code>. - */ - protected BaseConfigVariable(OptionSpec spec) - { - this.spec = spec; - } - - /** - * The <code>OptionSpec</code> describing the names that this <code>ConfigVariable</code> should match. - */ - protected final OptionSpec spec; - - /** - * Adds arguments to the end of <code>cmdline</code> corresponding to the state of this variable. - * - * @param cmdline The Commandline object to which arguments correspond to this option should be added - */ - public abstract void addToCommandline(Commandline cmdline); - - /** - * @return the OptionSpec associated with this instance. - */ - public OptionSpec getSpec() - { - return spec; - } - - /** - * Returns the result of calling matches() on <code>DEFAULT_SCRIPT_LIMITS</code> with <code>option</code> as the argument. - * - * @return true of <code>option</code> matches <code>DEFAULT_SCRIPT_LIMITS</code>, and false otherwise. - */ - public boolean matches(String option) - { - return spec.matches(option); - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java deleted file mode 100644 index f264db5..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -import org.apache.tools.ant.types.Commandline; - -/** - * Extends ConfigString by overriding addToCommandline to use +foo=bar - * syntax to support appending the configuration option to any - * existing values. - */ -public class ConfigAppendString extends ConfigString -{ - public ConfigAppendString(OptionSpec option) - { - super(option); - } - - public ConfigAppendString(OptionSpec option, String value) - { - super(option, value); - } - - public void addToCommandline(Commandline cmdlline) - { - String value = value(); - - if ((value != null) && (value.length() > 0)) - cmdlline.createArgument().setValue("+" + spec.getFullName() + "=" + value); - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java deleted file mode 100644 index 455d30c..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -import org.apache.tools.ant.types.Commandline; - -/** - * Extends ConfigVariable to support setting boolean configuration - * options. Values of "true", "yes", and "on" are supported. - */ -public final class ConfigBoolean extends ConfigVariable -{ - public ConfigBoolean(OptionSpec spec) - { - super(spec); - - this.enabled = false; - this.isSet = false; - } - - public ConfigBoolean(OptionSpec spec, boolean enabled) - { - super(spec); - this.set(enabled); - } - - private boolean enabled; - private boolean isSet; - - - public void set(boolean value) - { - this.enabled = value; - this.isSet = true; - } - - public void set(String value) - { - this.enabled = parseValue(value); - this.isSet = true; - } - - public boolean isSet() - { - return isSet; - } - - public void addToCommandline(Commandline cmdline) - { - if (isSet) - cmdline.createArgument(true).setValue("-" + spec.getFullName() + "=" + enabled); - } - - private boolean parseValue(String value) - { - return value.toLowerCase().matches("\\s*(true|yes|on)\\s*"); - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java deleted file mode 100644 index 0a7a737..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.FlexInteger; - -/** - * Extends ConfigVariable to add support for parsing values into - * integers and reporting build exceptions when the value isn't an - * integer. - */ -public class ConfigInt extends ConfigVariable -{ - public ConfigInt(OptionSpec option) - { - super(option); - this.isSet = false; - } - - public ConfigInt(OptionSpec option, int value) - { - super(option); - set(value); - } - - private int value; - private boolean isSet; - - public void set(int value) - { - this.value = value; - this.isSet = true; - } - - public void set(String value) - { - int intVal; - - try - { - intVal = new FlexInteger(value).intValue(); - } - catch (NumberFormatException e) - { - throw new BuildException("Not an integer: " + value); - } - - this.value = intVal; - this.isSet = true; - } - - public boolean isSet() - { - return isSet; - } - - public void addToCommandline(Commandline cmdline) - { - if (this.isSet) - { - cmdline.createArgument().setValue("-" + spec.getFullName()); - cmdline.createArgument().setValue(String.valueOf(this.value)); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java deleted file mode 100644 index af68b06..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -import org.apache.tools.ant.types.Commandline; - -/** - * Extends ConfigVariable by overriding addToCommandline to use the - * -foo=bar syntax unless the value is null, in which case, -foo= - * syntax is used. Note this is different than not setting foo at - * all, because it overrides any existing values for foo. - */ -public class ConfigString extends ConfigVariable -{ - public ConfigString(OptionSpec option) - { - this(option, null); - } - - public ConfigString(OptionSpec option, String value) - { - super(option); - this.set(value); - } - - private String value; - - public void set(String value) - { - this.value = value; - } - - public boolean isSet() - { - return value != null; - } - - public String value() - { - return value; - } - - public void addToCommandline(Commandline cmdline) - { - if (value != null) - { - if (value.length() > 0) - cmdline.createArgument().setValue("-" + spec.getFullName() + "=" + value); - else - cmdline.createArgument().setValue("-" + spec.getFullName() + "="); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java deleted file mode 100644 index a366527..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -/** - * Provides a base class for Configuration Variables that can be set with a - * String value. - * - * Consumers of this class must implement the <code>set</code> - * <code>isSet</code> methods. - */ -public abstract class ConfigVariable extends BaseConfigVariable -{ - /** - * Constructor. - * <p> - * Creates a <code>ConfigVariable</code> instance with the specified <code>OptionSpec</code>. - */ - protected ConfigVariable(OptionSpec spec) - { - super(spec); - } - - /** - * Set the value of this <code>ConfigVariable</code> - * - * @param value the value (as a String) that this <code>ConfigVariable</code> should be set to. - */ - public abstract void set(String value); - - /** - * Predicate specifying whether this ConfigVariable has been set. Implementation depends on the implementation of <code>set</code>. - * - * @return true if this <code>ConfigVariable</code> has been set, false otherwise. - */ - public abstract boolean isSet(); -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java deleted file mode 100644 index 99e15f7..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -import org.apache.tools.ant.types.Commandline; - -/** - * Interface to describe an object that can represent a commandline argument. - */ -public interface IOptionSource -{ - /** - * Adds the object's commandline representation to <code>cmdline</code>. - */ - void addToCommandline(Commandline cmdline); -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java deleted file mode 100644 index 0a7687b..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DynamicAttribute; -import org.apache.tools.ant.types.Commandline; - -import org.apache.flex.compiler.ant.FlexTask; - -/** - * This class supports setting configuration option parameters via - * child tag attributes. For example: - * </code> - * <namespace uri="http://www.adobe.com/2006/mxml" manifest="${basedir}/manifest.xml"/> - * </code> - */ -public class NestedAttributeElement implements DynamicAttribute, IOptionSource -{ - private static final String COMMA = ","; - - public NestedAttributeElement(String attrib, OptionSpec spec) - { - this(new String[] { attrib }, spec, null); - } - - public NestedAttributeElement(String[] attribs, OptionSpec spec) - { - this(attribs, spec, null); - } - - public NestedAttributeElement(String attrib, OptionSpec spec, FlexTask task) - { - this(new String[] { attrib }, spec, task); - } - - public NestedAttributeElement(String[] attribs, OptionSpec spec, FlexTask task) - { - this(attribs, spec, task, false); - } - - public NestedAttributeElement(String[] attribs, OptionSpec spec, FlexTask task, boolean allowAppend) - { - /* - * Note: Do not try and be clever and sort attribs in order to increase - * lookup time using binary search. The order of the attributes is - * meaningful! - */ - this.attribs = attribs; - this.values = new String[attribs.length]; - this.spec = spec; - this.task = task; - this.allowAppendAttribute = allowAppend; - this.isAppend = false; - } - - private String[] attribs; - private String[] values; - protected OptionSpec spec; - private boolean valueHasComma; - private FlexTask task; - private boolean isAppend; - - // Although "append" is a special-case attribute, we still need to throw error if "append" is not - // expected on the element. - private final boolean allowAppendAttribute ; - - public void addText(String value) - { - // if we have a task then replace any ant properties in the value. - if (task != null) - value = task.getProject().replaceProperties(value); - - values[0] = value; - - if (value.indexOf(COMMA) != -1) - valueHasComma = true; - } - - /** - * Assign attribute value. If {@code name} is in the expected attribute list, the {@code value} will - * be recorded. Otherwise, throw exception about unknown attribute. - * <p> - * "append" attribute is a special case. If <code>append="true"</code>, the command-line argument will - * use <code>+=</code> instead of <code>=</code>. - * @param name attribute name - * @param value attribute value - */ - public void setDynamicAttribute(String name, String value) - { - if (allowAppendAttribute && name.equals("append")) - { - isAppend = Boolean.parseBoolean(value); - return; - } - - boolean isSet = false; - - for (int i = 0; i < attribs.length && !isSet; i++) - { - if (attribs[i].equals(name)) - { - values[i] = value; - isSet = true; - } - } - - if (value.indexOf(COMMA) != -1) - valueHasComma = true; - - if (!isSet) - throw new BuildException("The <" + spec.getFullName() - + "> type doesn't support the \"" - + name + "\" attribute."); - } - - public void addToCommandline(Commandline cmdline) - { - if (valueHasComma) - { - cmdline.createArgument().setValue("-" + spec.getFullName()); - - for (int i = 0; i < attribs.length; i++) - { - if (values[i] != null) - cmdline.createArgument().setValue(values[i].replaceAll("\\s*,\\s*", COMMA)); - } - } - else - { - StringBuilder stringBuffer = new StringBuilder(); - - for (int i = 0; i < attribs.length; i++) - { - if (values[i] != null) - { - stringBuffer.append(values[i]); - - if ((i + 1) < attribs.length) - stringBuffer.append(COMMA); - } - } - - final String cmdLineArgument = String.format( - "-%s%s=%s", - spec.getFullName(), - isAppend ? "+" : "", - stringBuffer); - - cmdline.createArgument().setValue(cmdLineArgument); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java deleted file mode 100644 index ee0aa9b..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in 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. - * - */ - -package org.apache.flex.compiler.ant.config; - -/** - * Represents the name of a configuration option. - */ -public class OptionSpec -{ - public OptionSpec(String fullName, String alias) - { - this.fullName = fullName; - - int i = fullName.lastIndexOf('.'); - shortName = i != -1 ? fullName.substring(i + 1) : fullName; - - this.alias = alias; - } - - public OptionSpec(String fullName) - { - this(fullName, null); - } - - private String fullName; - private String shortName; - private String alias; - - public String getFullName() - { - return fullName; - } - - public String getShortName() - { - return shortName; - } - - public String getAlias() - { - return alias; - } - - public boolean matches(String option) - { - boolean result = false; - - if (option.equals(getFullName())) - result = true; - - else if (option.equals(getShortName())) - result = true; - - else if (option.equals(getAlias())) - result = true; - - return result; - } -}
