THRIFT-4750: as3 changes to build and publish to maven central
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0c69019..901c3ef 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -20,6 +20,10 @@
 SUBDIRS = json xml
 PRECROSS_TARGET =
 
+if WITH_AS3
+SUBDIRS += as3
+endif
+
 if WITH_CPP
 # cpp dir is picked directly by plugin build
 if !WITH_PLUGIN
diff --git a/lib/as3/CMakeLists.txt b/lib/as3/CMakeLists.txt
new file mode 100644
index 0000000..999905d
--- /dev/null
+++ b/lib/as3/CMakeLists.txt
@@ -0,0 +1,68 @@
+#
+# 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.
+#
+
+if (IS_ABSOLUTE "${LIB_INSTALL_DIR}")
+    set(AS3_INSTALL_DIR "${LIB_INSTALL_DIR}/as3")
+else ()
+    set(AS3_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/as3")
+endif ()
+
+set(PRELEASE "true")
+if (CMAKE_BUILD_TYPE MATCHES DEBUG)
+    set(PRELEASE "false")
+endif ()
+
+add_custom_target(ThriftAs3 ALL
+    COMMENT "Building as3 library using Gradle Wrapper"
+    COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} compileFlex
+        --console=plain --no-daemon
+        -Prelease=${PRELEASE}
+        "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    )
+
+# Enable publishing from CMake if the publishing information is provided
+if (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
+    add_custom_target(MavenPublishAs3
+        COMMENT "Publishing as3 library to Apache Maven staging"
+        COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} clean publishMavenPublicationToMavenRepository
+            --console=plain --no-daemon
+            -Prelease=${PRELEASE}
+            -Psign=${PRELEASE}
+            "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    )
+endif ()
+
+# Hook the CMake install process to the results from make ALL.
+# This works best when 'make all && sudo make install/fast' is used.
+# Using slash to end the source location to avoid copying the directory path.
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/libs/
+        DESTINATION ${AS3_INSTALL_DIR}
+        FILES_MATCHING PATTERN "libthrift-as3.swc")
+
+if (BUILD_TESTING)
+    add_test(NAME As3Test
+            COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test
+                --console=plain --no-daemon
+                -Prelease=${PRELEASE}
+                "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
+                "-Pthrift.compiler=${THRIFT_COMPILER}"
+            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endif ()
diff --git a/lib/as3/Makefile.am b/lib/as3/Makefile.am
new file mode 100644
index 0000000..5a078c6
--- /dev/null
+++ b/lib/as3/Makefile.am
@@ -0,0 +1,56 @@
+#
+# 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.
+#
+
+all-local:
+	./gradlew $(GRADLE_OPTS) compile \
+		-Prelease=true \
+		--console=plain
+
+install-exec-hook:
+	./gradlew $(GRADLE_OPTS) publishToMavenLocal \
+		-Prelease=true \
+		--console=plain
+
+clean-local:
+	./gradlew $(GRADLE_OPTS) clean \
+		-Prelease=true \
+                --console=plain
+
+check-local: $(THRIFT)
+	./gradlew $(GRADLE_OPTS) test \
+		-Prelease=true \
+		--console=plain
+
+maven-publish:
+	./gradlew $(GRADLE_OPTS) publishMavenPublicationToMavenRepository \
+		-Prelease=true \
+                -Psign=true \
+		--console=plain
+
+EXTRA_DIST = \
+	CMakeLists.txt \
+	README.md \
+	build.gradle \
+	coding_standards.md \
+	gradle \
+	gradle.properties \
+	gradlew \
+	gradlew.bat \
+	settings.gradle \
+	src
diff --git a/lib/as3/README.md b/lib/as3/README.md
new file mode 100644
index 0000000..c14f8c7
--- /dev/null
+++ b/lib/as3/README.md
@@ -0,0 +1,37 @@
+# Apache Thrift ActionScript Library
+
+## Building
+
+We use gradle and gradlefx to build the as3 library.  Unfortunately gradlefx requires
+an older version of gradle (2.5) but it still works - for now.  If you use the docker
+container to do the build, the Adobe Flex SDK 4.6 is installed and the FLEX_HOME
+environment variable is configured:
+
+    dev@ubuntu:~/thrift$ docker run -v $(pwd):/thrift/src:rw -it thrift/thrift-build:ubuntu-bionic /bin/bash
+    root@7624b61bbf84:/thrift/src# cd lib/as3
+    root@7624b61bbf84:/thrift/src/lib/as3# ./gradlew -Prelease=true compileFlex
+
+    ...
+
+    :compileFlex UP-TO-DATE
+
+    BUILD SUCCESSFUL
+
+    Total time: 10.784 secs
+
+    root@7624b61bbf84:/thrift/src/lib/as3# ls -ls build/
+    total 4
+    4 -rw-r--r-- 1 root root 1379 Jan 22 19:23 libthrift-as3.swc
+
+## Publishing
+
+We use a similar gradle-based signing and publishing mechanism as in the java
+library.  See the java library [README.md](../java/README.md) for more details.
+
+To publish into a local .m2 repository you can mount a directory into the docker container,
+for example:
+
+    dev@ubuntu:~/thrift$ docker run -v~/.m2:/root/.m2 -v $(pwd):/thrift/src:rw -it thrift/thrift-build:ubuntu-bionic /bin/bash
+    root@7624b61bbf84:/thrift/src/lib/as3# ./gradlew -Prelease=true publishToMavenLocal
+
+You will find your `~/.m2` directory is now populated with a release build `swc`.
diff --git a/lib/as3/build.gradle b/lib/as3/build.gradle
new file mode 100644
index 0000000..7853499
--- /dev/null
+++ b/lib/as3/build.gradle
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+buildscript {
+    repositories {
+        mavenLocal()
+        mavenCentral()
+    }
+    dependencies {
+        classpath group: 'org.gradlefx', name: 'gradlefx', version: '1.5.0'
+    }
+}
+
+plugins {
+    id 'maven-publish'
+    id 'signing'
+}
+
+apply plugin: 'gradlefx'
+
+description = 'Apache Thrift ActionScript Library'
+frameworkLinkage = 'none'
+group = property('thrift.groupid')
+srcDirs = ['src']
+type = 'swc'
+
+// We use the SNAPSHOT suffix for non-release versions
+if (Boolean.parseBoolean(project.release)) {
+    additionalCompilerOptions = ['-compiler.debug=false', '-compiler.strict=true']
+    version = property('thrift.version')
+} else {
+    additionalCompilerOptions = ['-compiler.debug=true', '-compiler.strict=true']
+    version = property('thrift.version') + '-SNAPSHOT'
+}
+
+defaultTasks 'compile'
+
+// Keeping the rest of the build logic in functional named scripts for clarity
+apply from: 'gradle/publishing.gradle'
+
diff --git a/lib/as3/build.properties b/lib/as3/build.properties
deleted file mode 100644
index 8463668..0000000
--- a/lib/as3/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-# Maven Ant tasks Jar details
-mvn.ant.task.version=2.1.3
-mvn.repo=http://repo1.maven.org/maven2
-mvn.ant.task.url=${mvn.repo}/org/apache/maven/maven-ant-tasks/${mvn.ant.task.version}
-mvn.ant.task.jar=maven-ant-tasks-${mvn.ant.task.version}.jar
diff --git a/lib/as3/build.xml b/lib/as3/build.xml
deleted file mode 100755
index b0c4c85..0000000
--- a/lib/as3/build.xml
+++ /dev/null
@@ -1,182 +0,0 @@
-<?xml version="1.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.
- -->
-<project name="libthrift-as3" default="compile" basedir="."
-  xmlns:artifact="antlib:org.apache.maven.artifact.ant">
-
-  <property name="as3.artifactid" value="${ant.project.name}"/>
-
-  <property name="thrift.root" location="${basedir}/../../"/>
-  <property name="thrift.java.dir" location="${thrift.root}/lib/java"/>
-  <property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/>
-  <property name="thrift_compiler" value="${thrift.root}/compiler/cpp/thrift"/>
-  <property file="${basedir}/build.properties"/>
-
-  <!-- inherit from the java build file for version and other properties -->
-  <property file="${thrift.java.dir}/gradle.properties" />
-
-  <property environment="env"/>
-
-  <condition property="version" value="${thrift.version}">
-    <isset property="release"/>
-  </condition>
-  <property name="version" value="${thrift.version}-SNAPSHOT"/>
-
-  <property name="as3.final.name" value="${as3.artifactid}-${version}"/>
-
-  <property name="src" value="${basedir}/src"/>
-  <property name="build.dir" value="${basedir}/build"/>
-
-  <property name="as3.swc.file" location="${build.dir}/${as3.final.name}.swc"/>
-  <property name="as3.pom.xml" location="${build.dir}/${as3.final.name}.pom"/>
-
-  <target name="init" depends="setup.init,flex.init" unless="init.finished">
-    <property name="init.finished" value="true"/>
-  </target>
-
-  <target name="setup.init">
-    <tstamp/>
-    <mkdir dir="${build.dir}"/>
-    <mkdir dir="${build.tools.dir}"/>
-  </target>
-
-  <target name="flex.check" unless="FLEX_HOME">
-    <fail message='You must set the FLEX_HOME property pointing to your flex SDK, eg. ant -DFLEX_HOME="/Applications/Adobe Flex Builder 3/sdks/3.2.0"'/>
-  </target>
-
-  <target name="flex.init" depends="flex.check" unless="flex.finished">
-    <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
-    <property name="flex.finished" value="true"/>
-  </target>
-
-  <target name="compile" depends="init">
-    <path id="as.src.files">
-      <fileset dir="${src}/">
-        <include name="**/*.as"/>
-      </fileset>
-    </path>
-    <pathconvert
-      property="as.src.classes"
-      pathsep=" "
-      dirsep="."
-      refid="as.src.files"
-    >
-      <map from="${src}/" to=""/>
-      <mapper type="glob" from="*.as" to="*"/>
-    </pathconvert>
-
-    <compc output="${as3.swc.file}" include-classes="${as.src.classes}">
-      <source-path path-element="${src}"/>
-    </compc>
-  </target>
-
-  <target name="clean">
-    <delete dir="${build.dir}" />
-  </target>
-
-  <target name="mvn.ant.tasks.download" depends="setup.init,mvn.ant.tasks.check" unless="mvn.ant.tasks.found">
-    <get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/>
-  </target>
-
-  <target name="mvn.ant.tasks.check">
-    <condition property="mvn.ant.tasks.found">
-      <typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
-    </condition>
-  </target>
-
-  <target name="mvn.init" depends="mvn.ant.tasks.download" unless="mvn.finished">
-    <echo message="${mvn.ant.task.jar}"/>
-    <!-- Download mvn ant tasks, download dependencies, and setup pom file -->
-    <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${build.tools.dir}/${mvn.ant.task.jar}"/>
-
-    <!-- remote repositories used to download dependencies from -->
-    <artifact:remoteRepository id="central" url="${mvn.repo}"/>
-    <artifact:remoteRepository id="apache" url="${apache.repo}"/>
-
-    <!-- Pom file information -->
-    <artifact:pom id="pom"
-      groupId="${thrift.groupid}"
-      artifactId="${as3.artifactid}"
-      version="${version}"
-      url="http://thrift.apache.org"
-      name="Apache Thrift"
-      description="Thrift is a software framework for scalable cross-language services development."
-      packaging="swc"
-    >
-      <remoteRepository refid="central"/>
-      <remoteRepository refid="apache"/>
-      <license name="The Apache Software License, Version 2.0" url="${license}"/>
-      <scm connection="scm:git:https://github.com/apache/thrift.git"
-      developerConnection="scm:git:https://github.com/apache/thrift.git"
-      url="https://github.com/apache/thrift"
-      />
-      <!-- Thrift Developers -->
-      <developer id="mcslee" name="Mark Slee"/>
-      <developer id="dreiss" name="David Reiss"/>
-      <developer id="aditya" name="Aditya Agarwal"/>
-      <developer id="marck" name="Marc Kwiatkowski"/>
-      <developer id="jwang" name="James Wang"/>
-      <developer id="cpiro" name="Chris Piro"/>
-      <developer id="bmaurer" name="Ben Maurer"/>
-      <developer id="kclark" name="Kevin Clark"/>
-      <developer id="jake" name="Jake Luciani"/>
-      <developer id="bryanduxbury" name="Bryan Duxbury"/>
-      <developer id="esteve" name="Esteve Fernandez"/>
-      <developer id="todd" name="Todd Lipcon"/>
-      <developer id="geechorama" name="Andrew McGeachie"/>
-      <developer id="molinaro" name="Anthony Molinaro"/>
-      <developer id="roger" name="Roger Meier"/>
-      <developer id="jfarrell" name="Jake Farrell"/>
-      <developer id="jensg" name="Jens Geyer"/>
-      <developer id="carl" name="Carl Yeksigian"/>
-    </artifact:pom>
-
-    <!-- Generate the pom file -->
-    <artifact:writepom pomRefId="pom" file="${as3.pom.xml}"/>
-
-    <property name="mvn.finished" value="true"/>
-  </target>
-
-  <macrodef name="signAndDeploy">
-    <!-- Sign and deploy jars to apache repo -->
-    <attribute name="file"/>
-    <attribute name="classifier" default=""/>
-    <attribute name="packaging" default="jar"/>
-    <attribute name="pom" default=""/>
-    <sequential>
-      <artifact:mvn fork="true">
-        <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file"/>
-        <arg value="-DrepositoryId=${maven-repository-id}"/>
-        <arg value="-Durl=${maven-repository-url}"/>
-        <arg value="-DpomFile=@{pom}"/>
-        <arg value="-Dfile=@{file}"/>
-        <arg value="-Dclassifier=@{classifier}"/>
-        <arg value="-Dpackaging=@{packaging}"/>
-        <arg value="-Pgpg"/>
-      </artifact:mvn>
-    </sequential>
-  </macrodef>
-
-  <target name="publish" depends="clean,compile,mvn.init">
-    <!-- Compile, packages and then send release to apache maven repo -->
-    <!-- run with: ant -Drelease=true publish -->
-    <signAndDeploy file="${as3.pom.xml}" packaging="pom" classifier="" pom="${as3.pom.xml}"/>
-    <signAndDeploy file="${as3.swc.file}" packaging="swc" classifier="" pom="${as3.pom.xml}"/>
-  </target>
-</project>
diff --git a/lib/as3/gradle.properties b/lib/as3/gradle.properties
new file mode 100644
index 0000000..8c8755e
--- /dev/null
+++ b/lib/as3/gradle.properties
@@ -0,0 +1,23 @@
+# This file is shared currently between this Gradle build and the
+# Ant builds for fd303 and JavaScript. Keep the dotted notation for
+# the properties to minimize the changes in the dependencies.
+thrift.version=1.0.0
+thrift.groupid=org.apache.thrift
+release=false
+sign=false
+
+# Local Install paths
+install.path=/usr/local/lib
+install.javadoc.path=/usr/local/lib
+
+# Test execution properties
+testPort=9090
+
+# Maven dependency download locations
+mvn.repo=http://repo1.maven.org/maven2
+apache.repo=https://repository.apache.org/content/repositories/releases
+
+# Apache Maven publish
+license=http://www.apache.org/licenses/LICENSE-2.0.txt
+maven-repository-url=https://repository.apache.org/service/local/staging/deploy/maven2
+maven-repository-id=apache.releases.https
diff --git a/lib/as3/gradle/publishing.gradle b/lib/as3/gradle/publishing.gradle
new file mode 100644
index 0000000..3e0ecf3
--- /dev/null
+++ b/lib/as3/gradle/publishing.gradle
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+// Following Gradle best practices to keep build logic organized
+
+model {
+    tasks.signMavenPublication {
+        dependsOn compileFlex
+    }
+}
+
+publishing {
+    publications {
+        maven(MavenPublication) {
+
+            groupId = "$group"
+            artifactId = "${project.name}"
+            version = "$version"
+
+            def swcFile = file("$buildDir/libthrift-as3.swc")
+            artifact(swcFile)
+
+            pom {
+                description = 'Thrift is a software framework for scalable cross-language services development.'
+                packaging = 'swc'
+
+                // older gradle doesn't recognize all the properties, so we inject them..
+                withXml {
+                    asNode().with {
+                        appendNode('name', 'Apache Thrift')
+                        appendNode('url', 'http://thrift.apache.org/')
+                        appendNode('scm').with {
+                            appendNode('url', 'https://github.com/apache/thrift/')
+                            appendNode('connection', 'scm:git:https://github.com/apache/thrift.git')
+                            appendNode('developerConnection', 'scm:git:git@github.com:apache/thrift.git')
+                        }
+                        appendNode('issueManagement').with {
+                            appendNode('url', 'https://issues.apache.org/jira/projects/THRIFT/')
+                            appendNode('system', 'Jira')
+                        }
+                        appendNode('licenses').with {
+                            appendNode('license').with {
+                                appendNode('name', 'The Apache Software License, Version 2.0')
+                                appendNode('url', "${project.license}")
+                            }
+                        }
+                        appendNode('organization').with {
+                            appendNode('name', 'The Apache Software Foundation')
+                            appendNode('url', 'http://www.apache.org/')
+                        }
+                        appendNode('developers').with {
+                            appendNode('developer').with {
+                                appendNode('id', 'dev')
+                                appendNode('name', 'Apache Thrift Developers')
+                                appendNode('email', 'dev@thrift.apache.org')
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    repositories {
+        maven {
+            url = property('maven-repository-url')
+
+            if (project.hasProperty('mavenUser') && project.hasProperty('mavenPassword')) {
+                credentials {
+                    username = property('mavenUser')
+                    password = property('mavenPassword')
+                }
+            }
+        }
+    }
+}
+
+signing {
+    required { property('sign') }
+    sign publishing.publications.maven
+}
diff --git a/lib/as3/gradle/wrapper/gradle-wrapper.jar b/lib/as3/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..87b738c
--- /dev/null
+++ b/lib/as3/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/lib/as3/gradle/wrapper/gradle-wrapper.properties b/lib/as3/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..558870d
--- /dev/null
+++ b/lib/as3/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/lib/as3/gradlew b/lib/as3/gradlew
new file mode 100755
index 0000000..af6708f
--- /dev/null
+++ b/lib/as3/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/lib/as3/gradlew.bat b/lib/as3/gradlew.bat
new file mode 100644
index 0000000..6d57edc
--- /dev/null
+++ b/lib/as3/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/lib/as3/settings.gradle b/lib/as3/settings.gradle
new file mode 100644
index 0000000..4932346
--- /dev/null
+++ b/lib/as3/settings.gradle
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+rootProject.name = 'libthrift-as3'