http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java deleted file mode 100644 index 0d87dbb..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigString.java +++ /dev/null @@ -1,66 +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 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/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java b/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java deleted file mode 100644 index ca2355f..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/RepeatableConfigVariable.java +++ /dev/null @@ -1,55 +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 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/compiler/src/main/java/org/apache/flex/compiler/ant/config/package.html ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/config/package.html b/compiler/src/main/java/org/apache/flex/compiler/ant/config/package.html deleted file mode 100644 index 721451c..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/config/package.html +++ /dev/null @@ -1,27 +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. - ---> - -<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/compiler/src/main/java/org/apache/flex/compiler/ant/package.html ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/package.html b/compiler/src/main/java/org/apache/flex/compiler/ant/package.html deleted file mode 100644 index 2009c58..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/package.html +++ /dev/null @@ -1,32 +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. - ---> - -<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/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java deleted file mode 100644 index a5bdbdf..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultScriptLimits.java +++ /dev/null @@ -1,79 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java deleted file mode 100644 index c7f846a..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/DefaultSize.java +++ /dev/null @@ -1,71 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java deleted file mode 100644 index 7963172..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexFileSet.java +++ /dev/null @@ -1,116 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java deleted file mode 100644 index ee3d2ff..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/FlexSWCFileSet.java +++ /dev/null @@ -1,55 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java deleted file mode 100644 index 47ea5e1..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/Fonts.java +++ /dev/null @@ -1,151 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java deleted file mode 100644 index 38c7759..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/Metadata.java +++ /dev/null @@ -1,168 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java deleted file mode 100644 index 150cc18..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/RuntimeSharedLibraryPath.java +++ /dev/null @@ -1,92 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java b/compiler/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java deleted file mode 100644 index 9fb9d39..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/URLElement.java +++ /dev/null @@ -1,64 +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.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/compiler/src/main/java/org/apache/flex/compiler/ant/types/package.html ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/ant/types/package.html b/compiler/src/main/java/org/apache/flex/compiler/ant/types/package.html deleted file mode 100644 index 00a733a..0000000 --- a/compiler/src/main/java/org/apache/flex/compiler/ant/types/package.html +++ /dev/null @@ -1,27 +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. - ---> - -<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> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/compiler/src/main/resources/flexTasks.tasks ---------------------------------------------------------------------- diff --git a/compiler/src/main/resources/flexTasks.tasks b/compiler/src/main/resources/flexTasks.tasks deleted file mode 100644 index 089d1f5..0000000 --- a/compiler/src/main/resources/flexTasks.tasks +++ /dev/null @@ -1,21 +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. -## -################################################################################ - -mxmlc=org.apache.flex.compiler.ant.MXMLCTask -compc=org.apache.flex.compiler.ant.COMPCTask http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/pom.xml ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/pom.xml b/flexjs-ant-tasks/pom.xml new file mode 100644 index 0000000..aebecab --- /dev/null +++ b/flexjs-ant-tasks/pom.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.flex.flexjs</groupId> + <artifactId>flexjs-parent</artifactId> + <version>0.7.0-SNAPSHOT</version> + </parent> + + <groupId>org.apache.flex.flexjs.compiler</groupId> + <artifactId>flexjs-ant-tasks</artifactId> + <version>0.7.0-SNAPSHOT</version> + + <name>Apache Flex - FlexJS: FlexJS Ant Tasks</name> + + <dependencies> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant</artifactId> + <version>1.7.0</version> + </dependency> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d1f0c033/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java new file mode 100644 index 0000000..71ddc25 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/COMPCTask.java @@ -0,0 +1,512 @@ +/* + * + * 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/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/FlexTask.java ---------------------------------------------------------------------- diff --git a/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/FlexTask.java b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/FlexTask.java new file mode 100644 index 0000000..6b32540 --- /dev/null +++ b/flexjs-ant-tasks/src/main/java/org/apache/flex/compiler/ant/FlexTask.java @@ -0,0 +1,418 @@ +/* + * + * 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; + } +}
