http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java new file mode 100644 index 0000000..5df9ddd --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/MXMLCTask.java @@ -0,0 +1,493 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java new file mode 100644 index 0000000..7253d22 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/BaseConfigVariable.java @@ -0,0 +1,74 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java new file mode 100644 index 0000000..f264db5 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigAppendString.java @@ -0,0 +1,48 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java new file mode 100644 index 0000000..455d30c --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigBoolean.java @@ -0,0 +1,75 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java new file mode 100644 index 0000000..0a7a737 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigInt.java @@ -0,0 +1,84 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java new file mode 100644 index 0000000..af68b06 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigString.java @@ -0,0 +1,70 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java new file mode 100644 index 0000000..a366527 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/ConfigVariable.java @@ -0,0 +1,54 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java new file mode 100644 index 0000000..99e15f7 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/IOptionSource.java @@ -0,0 +1,33 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java new file mode 100644 index 0000000..0a7687b --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/NestedAttributeElement.java @@ -0,0 +1,170 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java new file mode 100644 index 0000000..ee0aa9b --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/OptionSpec.java @@ -0,0 +1,76 @@ +/* + * + * 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; + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java new file mode 100644 index 0000000..0d87dbb --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java @@ -0,0 +1,66 @@ +/* + * + * 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 java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.tools.ant.types.Commandline; + +/** + * Extends RepeatableConfigVariable by overriding addToCommandline(). + */ +public class RepeatableConfigString extends RepeatableConfigVariable +{ + public RepeatableConfigString(OptionSpec spec) + { + super(spec); + + values = new ArrayList<String>(); + } + + private final List<String> values; + + public void add(String value) + { + values.add(value); + } + + public void addToCommandline(Commandline cmdline) + { + if (values.size() != 0) + cmdline.createArgument().setValue("-" + spec.getFullName() + "=" + makeArgString()); + } + + private String makeArgString() + { + String arg = ""; + Iterator<String> it = values.iterator(); + + while (it.hasNext()) + { + arg += (String) it.next(); + arg += it.hasNext() ? "," : ""; + } + + return arg; + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java new file mode 100644 index 0000000..ca2355f --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java @@ -0,0 +1,55 @@ +/* + * + * 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 take on multiple values. + * + * Consumers of this class must implement the <code>add</code> method. + */ +public abstract class RepeatableConfigVariable extends BaseConfigVariable +{ + /** + * Creates a <code>RepeatableConfigVariable</code> instance with the specified <code>OpitonSpec</code>. + */ + protected RepeatableConfigVariable(OptionSpec spec) + { + super(spec); + } + + /** + * Adds <code>value</code> as a value to this <code>RepeatableConfigVariable</code>. + * + * @param value the value to this <code>RepeatableConfigVariable</code> + */ + public abstract void add(String value); + + /** + * Adds every String in <code>values</code> as a value of this <code>RepeatableConfigVariable</code> by calling the <code>add</code> method with each String as an argument. + * @param values an array of Strings + */ + public void addAll(String[] values) + { + for (int i = 0; i < values.length; i++) + { + this.add(values[i]); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/package.html ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/package.html b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/package.html new file mode 100644 index 0000000..721451c --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/config/package.html @@ -0,0 +1,27 @@ +<!-- + + 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. + +--> + +<html> +<body> + +This package contains classes supporting configuration of the two +Ant tasks <code><mxmlc></code> and <code><compc></code>. + +</body> +</html> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/package.html ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/package.html b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/package.html new file mode 100644 index 0000000..2009c58 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/package.html @@ -0,0 +1,32 @@ +<!-- + + 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. + +--> + +<html> +<body> + +This package contains classes implementing the two Ant tasks +<code><mxmlc></code> and <code><compc></code>. + +<p> +For example, the <code><mxmlc></code> task runs the +<code>staticMainNoExit</code> entry point of the <code>MXMLC</code> class. +</p> + +</body> +</html> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java new file mode 100644 index 0000000..a5bdbdf --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java @@ -0,0 +1,79 @@ +/* + * + * 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.types; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DynamicAttribute; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.FlexInteger; + +import org.apache.flex.compiler.ant.config.IOptionSource; +import org.apache.flex.compiler.ant.config.OptionSpec; + +/** + * Implements <default-script-limits>. + */ +public class DefaultScriptLimits implements DynamicAttribute, IOptionSource +{ + public static final OptionSpec DEFAULT_SCRIPT_LIMITS = new OptionSpec("default-script-limits"); + + private int maxRecursionDepth = -1; + private int maxExecutionTime = -1; + + public void setDynamicAttribute(String name, String value) + { + int intVal = new FlexInteger(value).intValue(); + + if (name.equals("max-recursion-depth")) + { + maxRecursionDepth = intVal; + } + else if (name.equals("max-execution-time")) + { + maxExecutionTime = intVal; + } + else + { + throw new BuildException("The <default-script-limits> type doesn't support the \"" + + name + "\" attribute."); + } + + if (intVal < 0) + throw new BuildException(name + "attribute must be a positive integer!"); + } + + public void addToCommandline(Commandline cmdline) + { + if (maxRecursionDepth == -1) + { + throw new BuildException("max-recursion-depth attribute must be set!"); + } + else if (maxExecutionTime == -1) + { + throw new BuildException("max-execution-time attribute must be set!"); + } + else + { + cmdline.createArgument().setValue("-" + DEFAULT_SCRIPT_LIMITS.getFullName()); + cmdline.createArgument().setValue(String.valueOf(maxRecursionDepth)); + cmdline.createArgument().setValue(String.valueOf(maxExecutionTime)); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java new file mode 100644 index 0000000..c7f846a --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java @@ -0,0 +1,71 @@ +/* + * + * 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.types; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.types.Commandline; + +import org.apache.flex.compiler.ant.config.IOptionSource; +import org.apache.flex.compiler.ant.config.OptionSpec; + +/** + * Implements <default-size>. + */ +public class DefaultSize implements IOptionSource +{ + public static final OptionSpec DEFAULT_SIZE = new OptionSpec("default-size"); + + private int width = -1; + private int height = -1; + + public void setWidth(int val) + { + if (val <= 0) + throw new BuildException("width attribute must be a positive integer!"); + + width = val; + } + + public void setHeight(int val) + { + if (val <= 0) + throw new BuildException("height attribute must be a positive integer!"); + + height = val; + } + + public void addToCommandline(Commandline cmdline) + { + if (width == -1) + { + throw new BuildException("width attribute must be set!"); + } + else if (height == -1) + { + throw new BuildException("height attribute must be set!"); + } + else + { + cmdline.createArgument().setValue("-" + DEFAULT_SIZE.getFullName()); + cmdline.createArgument().setValue(String.valueOf(width)); + cmdline.createArgument().setValue(String.valueOf(height)); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java new file mode 100644 index 0000000..7963172 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java @@ -0,0 +1,116 @@ +/* + * + * 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.types; + +import java.io.File; + +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.util.FileUtils; + +import org.apache.flex.compiler.ant.config.IOptionSource; +import org.apache.flex.compiler.ant.config.OptionSpec; + +/** + * Adds support for setting Flex configuration options using Ant FileSets. For example: + * <code> + * <library-path dir="${FLEX_HOME}/libs" includes="flex.swc" append="true"/> + * </code> + */ +public class FlexFileSet extends FileSet implements IOptionSource +{ + public FlexFileSet() + { + this(false); + } + + public FlexFileSet(OptionSpec spec) + { + this(spec, false); + } + + public FlexFileSet(boolean dirs) + { + spec = null; + includeDirs = dirs; + append = false; + } + + public FlexFileSet(OptionSpec spec, boolean dirs) + { + this.spec = spec; + includeDirs = dirs; + append = false; + } + + protected final OptionSpec spec; + protected final boolean includeDirs; + + protected boolean append; + + public void setAppend(boolean value) + { + append = value; + } + + public void addToCommandline(Commandline cmdline) + { + if (hasSelectors() || hasPatterns()) + { + DirectoryScanner scanner = getDirectoryScanner(getProject()); + + if (includeDirs) + addFiles(scanner.getBasedir(), scanner.getIncludedDirectories(), cmdline); + + addFiles(scanner.getBasedir(), scanner.getIncludedFiles(), cmdline); + } + else if (spec != null) + { + cmdline.createArgument().setValue("-" + spec.getFullName() + equalString()); + } + } + + protected void addFiles(File base, String[] files, Commandline cmdline) + { + FileUtils utils = FileUtils.getFileUtils(); + + if (spec == null) + { + for (int i = 0; i < files.length; i++) + { + cmdline.createArgument().setValue(utils.resolveFile(base, files[i]).getAbsolutePath()); + } + } + else + { + for (int i = 0; i < files.length; i++) + { + cmdline.createArgument().setValue("-" + spec.getFullName() + equalString() + + utils.resolveFile(base, files[i]).getAbsolutePath()); + } + } + } + + protected String equalString() + { + return append ? "+=" : "="; + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java new file mode 100644 index 0000000..ee3d2ff --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java @@ -0,0 +1,55 @@ +/* + * + * 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.types; + +import java.io.File; + +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.util.FileUtils; + +import org.apache.flex.compiler.ant.config.OptionSpec; + +public class FlexSWCFileSet extends FlexFileSet +{ + public FlexSWCFileSet(OptionSpec spec, boolean dirs) + { + super(spec, dirs); + } + + // Only accept directories, and *.swc files + protected void addFiles(File base, String[] files, Commandline cmdline) + { + FileUtils utils = FileUtils.getFileUtils(); + + for (int i = 0; i < files.length; i++) + { + File f = utils.resolveFile(base, files[i]); + String absolutePath = f.getAbsolutePath(); + + if (f.isFile() && !absolutePath.endsWith(".swc")) + continue; + + if (spec != null) + cmdline.createArgument().setValue("-" + spec.getFullName() + equalString() + absolutePath); + else + cmdline.createArgument().setValue(absolutePath); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java new file mode 100644 index 0000000..47ea5e1 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java @@ -0,0 +1,151 @@ +/* + * + * 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.types; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DynamicConfigurator; +import org.apache.tools.ant.types.Commandline; + +import org.apache.flex.compiler.ant.FlexTask; +import org.apache.flex.compiler.ant.config.ConfigBoolean; +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; + +/** + * Supports the nested <fonts> tag. + */ +public final class Fonts implements IOptionSource, DynamicConfigurator +{ + /* + * Use this defintion of LANGUAGE_RANGE if you want to allow users to set the + * compiler.fonts.languages.language-range by using a nested element named + * languages.language-range: + * + * private static OptionSpec LANGUAGE_RANGE = new OptionSpec("compiler.fonts.languages.language-range", "languages.language-range"); + * + * Note that using this will no longer allow users to set the option by + * using a language-range nested element. + */ + private static final OptionSpec LANGUAGE_RANGE = + new OptionSpec("compiler.fonts.languages.language-range"); + + private static final OptionSpec MANAGERS = + new OptionSpec("compiler.fonts.managers"); + + public Fonts() + { + this(null); + } + + public Fonts(FlexTask task) + { + attribs = new ConfigVariable[] + { + new ConfigBoolean(new OptionSpec("compiler.fonts.flash-type")), + new ConfigBoolean(new OptionSpec("compiler.fonts.advanced-anti-aliasing")), + new ConfigString(new OptionSpec("compiler.fonts.local-fonts-snapshot")), + new ConfigString(new OptionSpec("compiler.fonts.max-cached-fonts")), + new ConfigString(new OptionSpec("compiler.fonts.max-glyphs-per-face")) + }; + + nestedAttribs = new ArrayList<NestedAttributeElement>(); + this.task = task; + } + + private final ConfigVariable[] attribs; + + private final ArrayList<NestedAttributeElement> nestedAttribs; + private final FlexTask task; + + /*=======================================================================* + * Attributes * + *=======================================================================*/ + + public void setDynamicAttribute(String name, String value) + { + ConfigVariable var = null; + + for (int i = 0; i < attribs.length && var == null; i++) + { + if (attribs[i].matches(name)) + var = attribs[i]; + } + + if (var != null) + { + var.set(value); + } + else + { + throw new BuildException("The <font> type doesn't support the \"" + + name + "\" attribute."); + } + } + + /*=======================================================================* + * Nested Elements * + *=======================================================================*/ + + public Object createDynamicElement(String name) + { + if (LANGUAGE_RANGE.matches(name)) + { + NestedAttributeElement e = new NestedAttributeElement(new String[] { "lang", "range" }, LANGUAGE_RANGE, task); + nestedAttribs.add(e); + return e; + } + else + { + throw new BuildException("Invalid element: " + name); + } + } + + public NestedAttributeElement createManager() + { + NestedAttributeElement e = new NestedAttributeElement("class", MANAGERS, task); + nestedAttribs.add(e); + return e; + } + + /*=======================================================================* + * IOptionSource interface * + *=======================================================================*/ + + public void addToCommandline(Commandline cmdline) + { + for (int i = 0; i < attribs.length; i++) + { + attribs[i].addToCommandline(cmdline); + } + + Iterator<NestedAttributeElement> it = nestedAttribs.iterator(); + + while (it.hasNext()) + { + ((IOptionSource)it.next()).addToCommandline(cmdline); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java new file mode 100644 index 0000000..38c7759 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java @@ -0,0 +1,168 @@ +/* + * + * 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.types; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DynamicElement; +import org.apache.tools.ant.types.Commandline; + +import org.apache.flex.compiler.ant.FlexTask; +import org.apache.flex.compiler.ant.config.ConfigString; +import org.apache.flex.compiler.ant.config.NestedAttributeElement; +import org.apache.flex.compiler.ant.config.IOptionSource; +import org.apache.flex.compiler.ant.config.OptionSpec; + +/** + * Supports the nested <metadata> tag. + */ +public final class Metadata implements IOptionSource, DynamicElement +{ + private static final OptionSpec LOCALIZED_DESCRIPTION = new OptionSpec("metadata.localized-description"); + private static final OptionSpec LOCALIZED_TITLE = new OptionSpec("metadata.localized-title"); + + private static final OptionSpec CONTRIBUTOR = new OptionSpec("metadata.contributor"); + private static final OptionSpec CREATOR = new OptionSpec("metadata.creator"); + private static final OptionSpec LANGUAGE = new OptionSpec("metadata.language"); + private static final OptionSpec PUBLISHER = new OptionSpec("metadata.publisher"); + + public Metadata() + { + this(null); + } + + public Metadata(FlexTask task) + { + date = new ConfigString(new OptionSpec("metadata", "date")); + description = new ConfigString(new OptionSpec("metadata", "description")); + title = new ConfigString(new OptionSpec("metadata", "title")); + + nestedAttribs = new ArrayList<NestedAttributeElement>(); + this.task = task; + } + + private final ConfigString date; + private final ConfigString description; + private final ConfigString title; + + private final ArrayList<NestedAttributeElement> nestedAttribs; + private final FlexTask task; + + /*=======================================================================* + * Attributes * + *=======================================================================*/ + + public void setDate(String value) + { + date.set(value); + } + + public void setDescription(String value) + { + description.set(value); + } + + public void setTitle(String value) + { + title.set(value); + } + + /*=======================================================================* + * Nested Elements + *=======================================================================*/ + + public NestedAttributeElement createContributor() + { + return createElem("name", CONTRIBUTOR); + } + + public NestedAttributeElement createCreator() + { + return createElem("name", CREATOR); + } + + public NestedAttributeElement createLanguage() + { + return createElem("code", LANGUAGE); + } + + public NestedAttributeElement createPublisher() + { + return createElem("name", PUBLISHER); + } + + public Object createDynamicElement(String name) + { + /* + * Name is checked against getAlias() because both of these options + * have prefixes. We don't want to allow something like: + * + * <metadata> + * <metadata.localized-title title="foo" lang="en" /> + * </metadata> + */ + if (LOCALIZED_DESCRIPTION.matches(name)) + { + return createElem(new String[] { "text", "lang" }, LOCALIZED_DESCRIPTION); + } + else if (LOCALIZED_TITLE.matches(name)) + { + return createElem(new String[] { "title", "lang" }, LOCALIZED_TITLE); + } + else + { + throw new BuildException("Invalid element: " + name); + } + } + + private NestedAttributeElement createElem(String attrib, OptionSpec spec) + { + NestedAttributeElement e = new NestedAttributeElement(attrib, spec, task); + nestedAttribs.add(e); + return e; + } + + private NestedAttributeElement createElem(String[] attribs, OptionSpec spec) + { + NestedAttributeElement e = new NestedAttributeElement(attribs, spec, task); + nestedAttribs.add(e); + return e; + } + + /*=======================================================================* + * IOptionSource interface * + *=======================================================================*/ + + public void addToCommandline(Commandline cmdline) + { + date.addToCommandline(cmdline); + description.addToCommandline(cmdline); + title.addToCommandline(cmdline); + + Iterator<NestedAttributeElement> it = nestedAttribs.iterator(); + + while (it.hasNext()) + { + ((IOptionSource) it.next()).addToCommandline(cmdline); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java new file mode 100644 index 0000000..150cc18 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java @@ -0,0 +1,92 @@ +/* + * + * 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.types; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DynamicConfigurator; +import org.apache.tools.ant.types.Commandline; + +import org.apache.flex.compiler.ant.config.IOptionSource; +import org.apache.flex.compiler.ant.config.OptionSpec; + +/** + * Supports the nested <runtime-shared-library-path> tag. + */ +public final class RuntimeSharedLibraryPath implements IOptionSource, DynamicConfigurator +{ + private static final String RUNTIME_SHARED_LIBRARY_PATH = "-runtime-shared-library-path"; + private static final String PATH_ELEMENT = "path-element"; + + private static final OptionSpec URL = new OptionSpec("url"); + + public RuntimeSharedLibraryPath() + { + } + + private String pathElement; + private List<URLElement> urlElements = new ArrayList<URLElement>(); + + public void addToCommandline(Commandline cmdline) + { + cmdline.createArgument().setValue(RUNTIME_SHARED_LIBRARY_PATH); + cmdline.createArgument().setValue(pathElement); + + Iterator<URLElement> it = urlElements.iterator(); + + while (it.hasNext()) + { + ((IOptionSource)it.next()).addToCommandline(cmdline); + } + } + + public Object createDynamicElement(String name) + { + URLElement result; + + if (URL.matches(name)) + { + result = new URLElement(); + urlElements.add(result); + } + else + { + throw new BuildException("Invalid element: " + name); + } + + return result; + } + + public void setDynamicAttribute(String name, String value) + { + if (name.equals(PATH_ELEMENT)) + { + pathElement = value; + } + else + { + throw new BuildException("The <rutime-shared-library-path> type doesn't support the \"" + + name + "\" attribute."); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java new file mode 100644 index 0000000..9fb9d39 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java @@ -0,0 +1,64 @@ +/* + * + * 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.types; + +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.config.IOptionSource; + +/** + * Supports the nested URL based tags of RuntimeSharedLibraryPath. + */ +public class URLElement implements DynamicAttribute, IOptionSource +{ + private static final String RSL_URL = "rsl-url"; + private static final String POLICY_FILE_URL = "policy-file-url"; + + private String rslURL; + private String policyFileURL; + + public void setDynamicAttribute(String name, String value) + { + if (name.equals(RSL_URL)) + { + rslURL = value; + } + else if (name.equals(POLICY_FILE_URL)) + { + policyFileURL = value; + } + else + { + throw new BuildException("The <url> type doesn't support the \"" + + name + "\" attribute."); + } + } + + public void addToCommandline(Commandline cmdline) + { + if (rslURL != null) + cmdline.createArgument().setValue(rslURL); + + if (policyFileURL != null) + cmdline.createArgument().setValue(policyFileURL); + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/package.html ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/package.html b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/package.html new file mode 100644 index 0000000..00a733a --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/types/package.html @@ -0,0 +1,27 @@ +<!-- + + 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. + +--> + +<html> +<body> + +This package contains data types for various configuration options of the two +Ant tasks <code><mxmlc></code> and <code><compc></code>. + +</body> +</html>
