| <project name="Node.js utils" xmlns:if="ant:if" xmlns:unless="ant:unless"> |
| <import file="common.xml" optional="false"/> |
| |
| <!-- Expected that these properties will be overridden by system properties --> |
| <property name="kotlin.deploy.version" value="0.0.0"/> |
| <property name="kotlin.deploy.tag" value="dev"/> |
| <property name="kotlin.npmjs.auth.token" value="AUTH"/> |
| |
| <property name="node.version" value="v6.3.1"/> |
| |
| |
| <property name="node.dir" value="${dependencies}/node"/> |
| <property name="node.executable" value="${node.dir}/bin/node"/> |
| |
| |
| <target name="download-nodejs-and-npm" depends="make-dependency-dirs"> |
| <property name="linux-x86" value="linux-x86"/> |
| |
| <property name="platform" value="win-x86" if:set="isWindows"/> |
| <property name="platform" value="darwin-x64" if:set="isMac"/> |
| <property name="platform" value="${linux-x86}" if:set="isLinux"/> |
| |
| <property name="node.tar.gz" value="${dependencies}/download/node.tar.gz"/> |
| |
| <property name="node.exe" value="${node.executable}.exe"/> |
| |
| <property name="node.name.prefix" value="${platform}" unless:set="isWindows"/> |
| <property name="node.name.prefix" value="${linux-x86}" if:set="isWindows"/> |
| |
| <property name="node.full.name" value="node-${node.version}-${node.name.prefix}"/> |
| |
| <property name="url.node.tar.gz" value="https://nodejs.org/dist/${node.version}/${node.full.name}.tar.gz"/> |
| <property name="url.node.exe" value="https://nodejs.org/dist/${node.version}/${platform}/node.exe"/> |
| |
| |
| <get src="${url.node.tar.gz}" dest="${node.tar.gz}" usetimestamp="true"/> |
| <exec executable="tar" unless:set="isWindows"> |
| <arg value="-zxf"/> |
| <arg path="${node.tar.gz}"/> |
| <arg value="-C"/> |
| <arg path="${dependencies}"/> |
| </exec> |
| <untar src="${node.tar.gz}" dest="${dependencies}" compression="gzip" if:set="isWindows"/> |
| |
| <move file="${dependencies}/${node.full.name}" tofile="${dependencies}/node"/> |
| <delete dir="${dependencies}/${node.full.name}"/> |
| <delete file="${node.tar.gz}"/> |
| |
| <sequential if:set="isWindows"> |
| <get src="${url.node.exe}" dest="${node.exe}" usetimestamp="true"/> |
| <delete file="${node.executable}"/> |
| </sequential> |
| </target> |
| |
| <macrodef name="node"> |
| <attribute name="dir" default="."/> |
| <attribute name="failonerror" default="true"/> |
| <element name="args" implicit="true"/> |
| |
| <sequential> |
| <exec executable="${node.executable}" dir="@{dir}" failonerror="@{failonerror}"> |
| <args/> |
| </exec> |
| </sequential> |
| </macrodef> |
| |
| <macrodef name="npm"> |
| <attribute name="command"/> |
| <attribute name="dir" default="."/> |
| <attribute name="failonerror" default="true"/> |
| <element name="args" optional="true" implicit="true"/> |
| |
| <sequential> |
| <node dir="@{dir}" failonerror="@{failonerror}"> |
| <arg file="${node.dir}/lib/node_modules/npm/bin/npm-cli.js"/> |
| <arg value="@{command}"/> |
| <args/> |
| </node> |
| </sequential> |
| </macrodef> |
| |
| <macrodef name="publish-to-npm"> |
| <attribute name="template"/> |
| <attribute name="version"/> |
| <attribute name="tag"/> |
| <element name="actions" optional="true" implicit="true"/> |
| <sequential> |
| <property name="deploy_to_npm_dir" value="${output}/deploy_to_npm"/> |
| <property name="package_deploy_dir" value="${deploy_to_npm_dir}/@{template}"/> |
| |
| <delete dir="${deploy_to_npm_dir}"/> |
| |
| <mkdir dir="${deploy_to_npm_dir}"/> |
| <copy todir="${package_deploy_dir}"> |
| <fileset dir="js/npm.templates/@{template}"/> |
| </copy> |
| |
| <actions/> |
| |
| <npm command="version" dir="${package_deploy_dir}"> |
| <arg value="@{version}"/> |
| </npm> |
| <npm command="publish" dir="${package_deploy_dir}"> |
| <arg value="--//registry.npmjs.org/:_authToken=${kotlin.npmjs.auth.token}"/> |
| <arg value="--tag"/> |
| <arg value="@{tag}"/> |
| </npm> |
| </sequential> |
| </macrodef> |
| |
| <target name="publish-kotlin-js-to-npm"> |
| <publish-to-npm template="kotlin" version="${kotlin.deploy.version}" tag="${kotlin.deploy.tag}"> |
| <copy file="${js.stdlib.output.dir}/kotlin.js" todir="${package_deploy_dir}" failonerror="true" /> |
| <copy file="${js.stdlib.output.dir}/kotlin.meta.js" todir="${package_deploy_dir}" failonerror="true" /> |
| </publish-to-npm> |
| </target> |
| |
| <target name="publish-kotlin-compiler-to-npm"> |
| <publish-to-npm template="kotlin-compiler" version="${kotlin.deploy.version}" tag="${kotlin.deploy.tag}"> |
| <copy todir="${package_deploy_dir}" failonerror="true" > |
| <fileset dir="${output}/kotlinc" /> |
| </copy> |
| <chmod perm="ugo+rx" dir="dist/deploy_to_npm/kotlin-compiler/bin" includes="*" /> |
| </publish-to-npm> |
| </target> |
| |
| <!-- Used on TeamCity--> |
| <target name="unzip-jslib.jar"> |
| <unzip src="${output}/kotlinc/lib/kotlin-stdlib-js.jar" dest="${js.stdlib.output.dir}"/> |
| </target> |
| |
| <target name="run-nodejs-tests" description="Run JS backend tests in node.js" depends="download-nodejs-and-npm"> |
| <npm command="install" dir="js/js.translator/testData" /> |
| <npm command="run" dir="js/js.translator/testData" failonerror="false"> |
| <arg value="test"/> |
| </npm> |
| </target> |
| </project> |