Files
kotlin-fork/build.xml
T
Michael Nedzelsky a65b9800c2 JS backend: put kotlin.js into jslib archive, add specification-title
kotlin.js is now included in kotlin-jslib.jar, so closure-compiler outputs kotlin.js to dist folder instead of dist/kotlic/lib
2014-12-12 03:02:31 +03:00

855 lines
38 KiB
XML

<project name="Kotlin" default="dist">
<include file="jslib_files.xml" />
<property file="resources/manifest.properties"/>
<!-- Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -->
<property name="shrink" value="true"/>
<!-- Set to false to disable compiler's @NotNull assertions. Speeds up the build -->
<property name="generate.assertions" value="true"/>
<!-- Set to false to disable compiler's javadoc generation. Speeds up the build -->
<property name="generate.javadoc" value="true"/>
<property name="bootstrap.home" value="dependencies/bootstrap-compiler"/>
<property name="bootstrap.compiler.home" value="${bootstrap.home}/Kotlin/kotlinc"/>
<property name="bootstrap.runtime" value="${bootstrap.compiler.home}/lib/kotlin-runtime.jar"/>
<property name="output.relative" value="dist"/>
<property name="output" value="${basedir}/${output.relative}"/>
<property name="kotlin-home" value="${output}/kotlinc"/>
<property name="build.number" value="snapshot"/>
<property name="bootstrap.build.no.tests" value="false"/>
<property name="output.name" value="kotlin-compiler-${build.number}"/>
<property name="idea.sdk" value="${basedir}/ideaSDK"/>
<property name="java.target" value="1.6"/>
<property name="external.annotations.path" value="${basedir}/annotations"/>
<property name="dependencies.dir" value="${basedir}/dependencies"/>
<path id="classpath">
<file file="${bootstrap.runtime}"/>
<fileset dir="${idea.sdk}" includes="core/*.jar"/>
<fileset dir="${idea.sdk}" includes="lib/protobuf-2.5.0.jar"/>
<fileset dir="${basedir}/lib" includes="**/*.jar"/>
<fileset dir="${dependencies.dir}" includes="jline.jar"/>
<fileset dir="${dependencies.dir}" includes="jansi.jar"/>
<fileset dir="${dependencies.dir}" includes="cli-parser-1.1.1.jar"/>
<fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
</path>
<typedef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${bootstrap.compiler.home}/lib/kotlin-ant.jar"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${dependencies.dir}/ant-contrib.jar"/>
<taskdef name="javac2" classname="org.apache.tools.ant.taskdefs.Javac"/>
<if>
<istrue value="${generate.assertions}"/>
<then>
<path id="javac2.classpath">
<pathelement location="${idea.sdk}/lib/javac2.jar"/>
<pathelement location="${idea.sdk}/lib/asm-all.jar"/>
</path>
<taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>
<echo message="Use javac2 from Idea lib"/>
</then>
<else>
<echo message="Use default javac compiler"/>
</else>
</if>
<dirset id="compilerSources.dirset" dir="${basedir}/">
<include name="core/descriptors/src"/>
<include name="core/serialization/src"/>
<include name="core/descriptor.loader.java/src"/>
<include name="core/serialization.java/src"/>
<include name="core/util.runtime/src"/>
<include name="compiler/frontend/src"/>
<include name="compiler/frontend.java/src"/>
<include name="compiler/backend-common/src"/>
<include name="compiler/backend/src"/>
<include name="compiler/cli/src"/>
<include name="compiler/cli/cli-common/src"/>
<include name="compiler/util/src"/>
<include name="compiler/jet.as.java.psi/src"/>
<include name="compiler/builtins-serializer/src"/>
<include name="js/js.dart-ast/src"/>
<include name="js/js.translator/src"/>
<include name="js/js.frontend/src"/>
<include name="js/js.inliner/src"/>
</dirset>
<property name="idea.out" value="${basedir}/out/production"/>
<patternset id="compilerClassesFromIDEA.fileset">
<include name="frontend/**"/>
<include name="descriptors/**"/>
<include name="serialization/**"/>
<include name="descriptor.loader.java/**"/>
<include name="frontend.java/**"/>
<include name="serialization.java/**"/>
<include name="backend/**"/>
<include name="backend-common/**"/>
<include name="cli/**"/>
<include name="cli-common/**"/>
<include name="util/**"/>
<include name="util.runtime/**"/>
<include name="jet.as.java.psi/**"/>
<include name="builtins-serializer/**"/>
<include name="js.dart-ast/**"/>
<include name="js.translator/**"/>
<include name="js.frontend/**"/>
<include name="js.inliner/**"/>
</patternset>
<path id="compilerSources.path">
<dirset refid="compilerSources.dirset"/>
</path>
<path id="preloaderSources.path">
<dirset dir="compiler/preloader/src"/>
</path>
<macrodef name="cleandir">
<attribute name="dir"/>
<sequential>
<echo message="Cleaning @{dir}"/>
<delete dir="@{dir}" failonerror="false"/>
<mkdir dir="@{dir}"/>
</sequential>
</macrodef>
<target name="clean">
<delete dir="${output}"/>
</target>
<target name="init">
<mkdir dir="${kotlin-home}"/>
<mkdir dir="${kotlin-home}/lib"/>
</target>
<target name="prepare-dist">
<copy todir="${kotlin-home}/bin">
<fileset dir="${basedir}/compiler/cli/bin"/>
</copy>
<fixcrlf srcdir="${kotlin-home}/bin" excludes="**/*.bat" eol="unix"/>
<copy todir="${kotlin-home}/license">
<fileset dir="${basedir}/license"/>
</copy>
<echo file="${kotlin-home}/build.txt" message="${build.number}"/>
<chmod dir="${kotlin-home}/bin" excludes="**/*.bat" perm="755"/>
</target>
<target name="compiler-sources">
<jar jarfile="${output}/kotlin-compiler-sources.jar">
<!-- TODO How to convert it from pathset or dirset ? -->
<fileset dir="core/descriptors/src"/>
<fileset dir="core/descriptor.loader.java/src"/>
<fileset dir="core/serialization/src"/>
<fileset dir="core/serialization.java/src"/>
<fileset dir="core/util.runtime/src"/>
<fileset dir="compiler/frontend/src"/>
<fileset dir="compiler/frontend.java/src"/>
<fileset dir="compiler/backend-common/src"/>
<fileset dir="compiler/backend/src"/>
<fileset dir="compiler/cli/src"/>
<fileset dir="compiler/cli/cli-common/src"/>
<fileset dir="compiler/util/src"/>
<fileset dir="compiler/jet.as.java.psi/src"/>
<fileset dir="compiler/builtins-serializer"/>
<fileset dir="js/js.dart-ast/src"/>
<fileset dir="js/js.translator/src"/>
<fileset dir="js/js.frontend/src"/>
<fileset dir="js/js.inliner/src"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.sources}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
<if>
<istrue value="${generate.javadoc}"/>
<then>
<delete dir="${output}/kotlin-compiler-javadoc" failonerror="false"/>
<javadoc destdir="${output}/kotlin-compiler-javadoc"
sourcepathref="compilerSources.path"
classpathref="classpath"
linksource="yes"
windowtitle="${manifest.impl.title.kotlin.compiler}"/>
<jar jarfile="${output}/kotlin-compiler-javadoc.jar">
<fileset dir="${output}/kotlin-compiler-javadoc"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.javadoc}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</then>
<else>
<jar jarfile="${output}/kotlin-compiler-javadoc.jar">
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.javadoc}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</else>
</if>
</target>
<target name="jslib">
<typedef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin-home}/lib/kotlin-ant.jar"/>
<property name="compiled.builtins.js" value="builtins.js" />
<property name="compiled.stdlib.js" value="stdlib.js" />
<property name="stdlib.js.dir" value="${basedir}/js/js.translator/testData" />
<kotlin2js output="${output}/${compiled.builtins.js}" noStdlib="true" main="noCall">
<src>
<fileset refid="kotlin.builtin.files" />
</src>
</kotlin2js>
<kotlin2js output="${output}/${compiled.stdlib.js}" noStdlib="true" main="noCall">
<src>
<resources refid="js.lib.files" />
</src>
</kotlin2js>
<taskdef name="closure-compiler"
classname="com.google.javascript.jscomp.ant.CompileTask"
classpath="${dependencies.dir}/closure-compiler.jar"/>
<!-- value should be one of: whitespace, simple, advanced -->
<property name="compilationLevel" value="simple" />
<!-- value should be one of: default, quiet, verbose -->
<property name="warningLevel" value="default" />
<closure-compiler
compilationLevel="${compilationLevel}"
prettyprint="true"
languagein="ECMASCRIPT5_STRICT"
warning="${warningLevel}"
output="${output}/kotlin.js" >
<sources dir="${stdlib.js.dir}">
<file name="kotlin_lib_ecma5.js"/>
<file name="kotlin_lib.js"/>
<file name="maps.js"/>
<file name="long.js"/>
</sources>
<sources dir="${output}">
<file name="${compiled.builtins.js}"/>
</sources>
<sources dir="${output}">
<file name="${compiled.stdlib.js}"/>
</sources>
<sources dir="${stdlib.js.dir}">
<file name="export_Kotlin_if_possible.js"/>
</sources>
<externs dir="${stdlib.js.dir}">
<file name="externs.js"/>
</externs>
</closure-compiler>
<jar jarfile="${kotlin-home}/lib/kotlin-jslib.jar">
<resources refid="js.lib.files" />
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<zipfileset file="${output}/kotlin.js" prefix=""/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.javascript.stdlib}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Specification-Title" value="${manifest.spec.title.kotlin.javascript.lib}"/>
<attribute name="Kotlin-JS-Module-Name" value="stdlib"/>
</manifest>
</jar>
</target>
<target name="jslib_sources">
<jar destfile="${kotlin-home}/lib/kotlin-jslib-sources.jar">
<resources refid="js.lib.files" />
<fileset refid="kotlin.builtin.files" />
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.jvm.runtime.sources}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Specification-Title" value="${manifest.spec.title.kotlin.javascript.lib}"/>
<attribute name="Kotlin-JS-Module-Name" value="stdlib"/>
</manifest>
</jar>
</target>
<target name="preloader">
<cleandir dir="${output}/classes/preloader"/>
<javac2 destdir="${output}/classes/preloader" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<src refid="preloaderSources.path"/>
</javac2>
<jar jarfile="${kotlin-home}/lib/kotlin-preloader.jar">
<fileset dir="${output}/classes/preloader"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.preloader}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Main-Class" value="org.jetbrains.jet.preloading.Preloader"/>
</manifest>
</jar>
</target>
<target name="serialize-builtins">
<cleandir dir="${output}/builtins"/>
<java classname="org.jetbrains.jet.utils.builtinsSerializer.BuiltinsSerializerPackage"
classpath="${bootstrap.compiler.home}/lib/kotlin-compiler.jar"
failonerror="true"
fork="true">
<assertions>
<enable/>
</assertions>
<arg value="${output}/builtins"/>
<arg value="core/builtins/native"/>
<arg value="core/builtins/src"/>
</java>
</target>
<macrodef name="pack-compiler">
<attribute name="jarfile"/>
<attribute name="compress" default="true"/>
<sequential>
<!--
For "Compiler and Plugin - Bootstrap - No Tests" configuration the compiler will contain the runtime it was built against, and
will NOT contain the new runtime in its "Class-Path" attribute. This is done because the new compiler is guaranteed to work
against the OLD runtime (because the new compiler is just a Kotlin application, compiled by the old compiler with the old
runtime), but _will not necessarily_ work against the new one.
However we don't do this on the second run of our distribution, i.e. we do not include the new runtime in the NEWEST compiler.
This is because there are little to no differences between the new and the newest runtime, and so we assume that our newest
compiler will work with any of them. Also distributing two runtimes (inside the compiler and a separate one) could cause all
kinds of problems and confusion for users who include both our compiler and runtime in their classpath
-->
<if>
<istrue value="${bootstrap.build.no.tests}"/>
<then>
<property name="compiler.manifest.class.path" value="."/>
</then>
<else>
<property name="compiler.manifest.class.path" value="kotlin-runtime.jar"/>
</else>
</if>
<jar jarfile="@{jarfile}" compress="@{compress}" duplicate="preserve">
<zipfileset src="${bootstrap.runtime}">
<include name="**/*.class" if="${bootstrap.build.no.tests}"/>
</zipfileset>
<fileset dir="${output}/classes/compiler"/>
<fileset dir="${output}/builtins">
<include name="kotlin/**"/>
<exclude name="kotlin/internal/**"/>
</fileset>
<fileset dir="${basedir}/compiler/frontend.java/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/backend/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/resources" includes="manifest.properties"/>
<fileset dir="idea/src">
<include name="META-INF/extensions/common.xml"/>
<include name="META-INF/extensions/kotlin2jvm.xml"/>
<include name="META-INF/extensions/kotlin2js.xml"/>
</fileset>
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/core" includes="*.jar" excludes="util.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/lib" includes="jna-utils.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/lib" includes="oromatcher.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/lib" includes="protobuf-2.5.0.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
<zipgroupfileset dir="${dependencies.dir}" includes="jline.jar"/>
<zipgroupfileset dir="${dependencies.dir}" includes="cli-parser-1.1.1.jar"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Class-Path" value="${compiler.manifest.class.path}"/>
<attribute name="Main-Class" value="org.jetbrains.jet.cli.jvm.K2JVMCompiler"/>
</manifest>
</jar>
</sequential>
</macrodef>
<target name="compiler-quick">
<delete dir="${output}/classes/compiler"/>
<copy todir="${output}/classes/compiler">
<fileset dir="${idea.out}/">
<patternset refid="compilerClassesFromIDEA.fileset"/>
</fileset>
<!-- out/production contains classes under module directories, here we are merging them all into one root-->
<cutdirsmapper dirs="1"/>
</copy>
<delete file="${kotlin-home}/lib/kotlin-compiler.jar"/>
<pack-compiler jarfile="${kotlin-home}/lib/kotlin-compiler.jar" compress="false"/>
</target>
<target name="compiler">
<taskdef resource="proguard/ant/task.properties" classpath="${dependencies.dir}/proguard.jar"/>
<cleandir dir="${output}/classes/compiler"/>
<javac2 destdir="${output}/classes/compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin externalannotations="${external.annotations.path}"/>
<src refid="compilerSources.path"/>
<classpath refid="classpath"/>
</javac2>
<pack-compiler jarfile="${output}/kotlin-compiler-before-shrink.jar"/>
<delete file="${kotlin-home}/lib/kotlin-compiler.jar" failonerror="false"/>
<if>
<isfalse value="${shrink}"/>
<then>
<copy file="${output}/kotlin-compiler-before-shrink.jar"
tofile="${kotlin-home}/lib/kotlin-compiler.jar"/>
</then>
<else>
<available property="rtjar" value="${java.home}/lib/rt.jar" file="${java.home}/lib/rt.jar"/>
<available property="rtjar" value="${java.home}/../Classes/classes.jar" file="${java.home}/../Classes/classes.jar"/>
<available property="jssejar" value="${java.home}/lib/jsse.jar" file="${java.home}/lib/jsse.jar"/>
<available property="jssejar" value="${java.home}/../Classes/jsse.jar" file="${java.home}/../Classes/jsse.jar"/>
<proguard><![CDATA[
-injars '${output}/kotlin-compiler-before-shrink.jar'(
!com/thoughtworks/xstream/converters/extended/ISO8601**,
!com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter**,
!com/thoughtworks/xstream/io/xml/Dom4J**,
!com/thoughtworks/xstream/io/xml/Xom**,
!com/thoughtworks/xstream/io/xml/Wstx**,
!com/thoughtworks/xstream/io/xml/KXml2**,
!com/thoughtworks/xstream/io/xml/BEAStax**,
!com/thoughtworks/xstream/io/json/Jettison**,
!com/thoughtworks/xstream/mapper/CGLIBMapper**,
!org/apache/log4j/jmx/Agent*,
!org/apache/log4j/net/JMS*,
!org/apache/log4j/net/SMTP*,
!org/apache/log4j/or/jms/MessageRenderer*,
!org/jdom/xpath/Jaxen*,
!org/mozilla/javascript/xml/impl/xmlbeans/**,
!META-INF/maven**,
**.class,**.properties,**.kt,**.kotlin_*,
META-INF/services/**,META-INF/native/**,META-INF/extensions/**,META-INF/MANIFEST.MF,
messages/**)
-outjars '${kotlin-home}/lib/kotlin-compiler.jar'
-dontnote **
-dontwarn com.intellij.util.ui.IsRetina*
-dontwarn com.intellij.util.RetinaImage*
-dontwarn apple.awt.*
-dontwarn dk.brics.automaton.*
-dontwarn org.fusesource.**
-dontwarn org.xerial.snappy.SnappyBundleActivator
-dontwarn com.intellij.util.CompressionUtil
-dontwarn com.intellij.util.SnappyInitializer
-dontwarn net.sf.cglib.**
-dontwarn org.objectweb.asm.** # this is ASM3, the old version that we do not use
-libraryjars '${rtjar}'
-libraryjars '${jssejar}'
-libraryjars '${bootstrap.runtime}'
-target 1.6
-dontoptimize
-dontobfuscate
-keep class org.fusesource.** { *; }
-keep class org.jdom.input.JAXPParserFactory { *; }
-keep class org.jetbrains.annotations.** {
public protected *;
}
-keep class javax.inject.** {
public protected *;
}
-keep class org.jetbrains.k2js.** {
public protected *;
}
-keep class org.jetbrains.jet.** {
public protected *;
}
-keep class jet.** {
public protected *;
}
-keep class kotlin.** {
public protected *;
}
-keep class com.intellij.psi.** {
public protected *;
}
# for kdoc & dokka
-keep class com.intellij.openapi.util.TextRange { *; }
-keep class com.intellij.lang.impl.PsiBuilderImpl* {
public protected *;
}
-keep class com.intellij.openapi.util.text.StringHash { *; }
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * {
** toString();
** hashCode();
void start();
void stop();
void dispose();
}
-keepclassmembers class org.jetbrains.org.objectweb.asm.Opcodes {
*** ASM5;
}
-keepclassmembers class org.jetbrains.org.objectweb.asm.ClassReader {
*** SKIP_CODE;
*** SKIP_DEBUG;
*** SKIP_FRAMES;
}
]]></proguard>
</else>
</if>
<jar jarfile="${output}/kotlin-compiler-for-maven.jar">
<zipfileset src="${kotlin-home}/lib/kotlin-compiler.jar" includes="**"/>
<zipfileset src="${bootstrap.runtime}" includes="**" excludes="META-INF/**"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Main-Class" value="org.jetbrains.jet.cli.jvm.K2JVMCompiler"/>
</manifest>
</jar>
</target>
<target name="ant-tools">
<cleandir dir="${output}/classes/ant"/>
<javac2 destdir="${output}/classes/ant" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin externalannotations="${external.annotations.path}"/>
<src>
<dirset dir="${basedir}/ant">
<include name="src"/>
</dirset>
</src>
<compilerarg value="-Xlint:all"/>
<classpath>
<fileset dir="${kotlin-home}/lib" includes="kotlin-compiler.jar"/>
<file file="${bootstrap.runtime}"/>
<fileset dir="${dependencies.dir}/ant-1.7/lib" includes="ant.jar"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/kotlin-ant.jar">
<fileset dir="${output}/classes/ant"/>
<fileset dir="${basedir}/ant/src" includes="**/*.xml"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.ant.task}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Class-Path" value="kotlin-compiler.jar"/>
</manifest>
</jar>
</target>
<target name="jdk-annotations">
<copy file="dependencies/annotations/kotlin-jdk-annotations.jar" todir="${kotlin-home}/lib"/>
</target>
<target name="android-sdk-annotations">
<copy file="dependencies/annotations/kotlin-android-sdk-annotations.jar" todir="${kotlin-home}/lib"/>
</target>
<macrodef name="new-kotlinc">
<attribute name="output"/>
<attribute name="withJava" default="true"/>
<element name="src"/>
<!-- This element should have been named "classpath" but it conflicts with classpath elements present in java and javac tasks -->
<element name="class-path"/>
<sequential>
<cleandir dir="@{output}"/>
<!-- All properties declared in this macro should be local because otherwise their value won't change after the first run,
which effectively would make this macro non-reusable -->
<local name="src.paths"/>
<local name="src.line"/>
<local name="classpath.paths"/>
<dirset dir="${basedir}" id="src.dirset">
<src/>
</dirset>
<path id="classpath.path">
<class-path/>
</path>
<!-- Source paths separated by the system path separator -->
<pathconvert property="src.paths" refid="src.dirset"/>
<!-- Source paths separated by space (to pass to "arg line" below) -->
<pathconvert property="src.line" refid="src.dirset" pathsep=" "/>
<!-- Classpath separated by the system path separator -->
<pathconvert property="classpath.paths" refid="classpath.path"/>
<java classname="org.jetbrains.jet.cli.jvm.K2JVMCompiler" failonerror="true" fork="true">
<classpath>
<path refid="classpath"/>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
<assertions>
<enable/>
</assertions>
<arg line="${src.line}"/>
<arg value="-d"/>
<arg value="@{output}"/>
<arg value="-no-stdlib"/>
<arg value="-classpath"/>
<!-- Include source paths to classpath for Kotlin compiler to resolve symbols from Java sources -->
<arg value="${src.paths}${path.separator}${classpath.paths}"/>
</java>
<if>
<equals arg1="@{withJava}" arg2="true"/>
<then>
<javac2 srcdir="${src.paths}" destdir="@{output}" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<classpath>
<path refid="classpath.path"/>
<!-- Include @{output} here for Java compiler to resolve symbols from Kotlin sources -->
<pathelement location="@{output}"/>
</classpath>
</javac2>
</then>
</if>
</sequential>
</macrodef>
<target name="builtins">
<new-kotlinc output="${output}/classes/builtins">
<src>
<include name="core/builtins/src"/>
<include name="core/runtime.jvm/src"/>
<include name="core/reflection/src"/>
<include name="core/reflection.jvm/src"/>
</src>
<class-path/>
</new-kotlinc>
</target>
<target name="stdlib">
<new-kotlinc output="${output}/classes/stdlib" withJava="false">
<src>
<include name="libraries/stdlib/src"/>
</src>
<class-path>
<pathelement path="${output.relative}/classes/builtins"/>
</class-path>
</new-kotlinc>
</target>
<target name="pack-runtime">
<jar destfile="${kotlin-home}/lib/kotlin-runtime.jar">
<fileset dir="${output}/classes/builtins"/>
<fileset dir="${output}/classes/stdlib"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.jvm.runtime}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</target>
<target name="pack-runtime-sources">
<jar destfile="${kotlin-home}/lib/kotlin-runtime-sources.jar">
<fileset dir="${basedir}/core/builtins/native" includes="**/*"/>
<fileset dir="${basedir}/core/builtins/src" includes="**/*"/>
<fileset dir="${basedir}/core/runtime.jvm/src" includes="**/*"/>
<fileset dir="${basedir}/core/reflection/src" includes="**/*"/>
<fileset dir="${basedir}/core/reflection.jvm/src" includes="**/*"/>
<fileset dir="${basedir}/libraries/stdlib/src" includes="**/*"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.jvm.runtime.sources}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</target>
<target name="runtime" depends="builtins,stdlib,pack-runtime,pack-runtime-sources"/>
<target name="dist"
depends="clean,init,prepare-dist,preloader,serialize-builtins,compiler,compiler-sources,ant-tools,jdk-annotations,android-sdk-annotations,runtime,jslib,jslib_sources"
description="Builds redistributables from sources"/>
<!-- builds everything, but classes are reused from project out dir, doesn't run proguard and javadoc -->
<target name="dist-quick"
depends="clean,init,prepare-dist,preloader,serialize-builtins,compiler-quick,ant-tools,jdk-annotations,android-sdk-annotations,runtime,jslib,jslib_sources"/>
<target name="dist-quick-compiler-only"
depends="init,prepare-dist,preloader,serialize-builtins,compiler-quick"
description="Builds compiler jar from project out dir"/>
<target name="zip-compiler" depends="dist">
<zip destfile="${output}/${output.name}.zip">
<zipfileset prefix="kotlinc" dir="${kotlin-home}" excludes="bin/*"/>
<zipfileset prefix="kotlinc/bin" dir="${kotlin-home}/bin" includes="*.bat" filemode="644"/>
<zipfileset prefix="kotlinc/bin" dir="${kotlin-home}/bin" excludes="*.bat" filemode="755"/>
</zip>
</target>
<target name="kotlin-for-upsource" depends="dist">
<cleandir dir="${output}/classes/idea-analysis"/>
<javac2 destdir="${output}/classes/idea-analysis" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin externalannotations="${external.annotations.path}"/>
<src>
<dirset dir="${basedir}/idea/ide-common">
<include name="src"/>
</dirset>
<dirset dir="${basedir}/idea/idea-analysis">
<include name="src"/>
</dirset>
</src>
<classpath>
<fileset dir="${idea.sdk}" includes="core/*.jar"/>
<fileset dir="${idea.sdk}" includes="core-analysis/*.jar"/>
<fileset dir="${idea.sdk}" includes="lib/protobuf-2.5.0.jar"/>
<fileset dir="${basedir}/lib" includes="**/*.jar"/>
<fileset dir="${dependencies.dir}" includes="jline.jar"/>
<fileset dir="${dependencies.dir}" includes="jansi.jar"/>
<fileset dir="${dependencies.dir}" includes="cli-parser-1.1.1.jar"/>
<fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
<fileset dir="${kotlin-home}/lib" includes="kotlin-runtime.jar"/>
<pathelement location="${output}/classes/compiler"/>
</classpath>
</javac2>
<copy todir="${output}/classes/idea-analysis">
<fileset dir="${basedir}/idea/idea-analysis/src" excludes="**/*.java, **/*.kt"/>
</copy>
<jar jarfile="${output}/kotlin-for-upsource0.jar">
<fileset dir="${output}/classes/idea-analysis"/>
<fileset dir="${output}/classes/compiler"/>
<fileset dir="${output}/builtins">
<include name="kotlin/**"/>
<exclude name="kotlin/internal/**"/>
</fileset>
<fileset dir="${basedir}/compiler/frontend.java/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/backend/src" includes="META-INF/services/**"/>
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
<zipgroupfileset dir="${kotlin-home}/lib" includes="kotlin-runtime.jar"/>
<zipgroupfileset dir="${kotlin-home}/lib" includes="kotlin-runtime-sources.jar"/>
<!-- icons, etc. -->
<fileset dir="idea/resources"/>
<!-- plugin.xml and friends -->
<fileset dir="idea/src" includes="META-INF/**"/>
</jar>
<sleep seconds="1"/>
<jar jarfile="${output}/kotlin-for-upsource.jar">
<zipfileset src="${output}/kotlin-for-upsource0.jar">
<exclude name="javax/**/*.java"/>
</zipfileset>
</jar>
<delete file="${output}/kotlin-for-upsource0.jar"/>
<!-- sources -->
<jar jarfile="${output}/kotlin-for-upsource-sources.jar">
<zipfileset src="${output}/kotlin-compiler-sources.jar" includes="**/*"/>
<fileset dir="idea/idea-analysis/src"/>
<fileset dir="idea/ide-common/src"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</target>
<target name="zip-test-data">
<zip destfile="${output}/kotlin-test-data.zip">
<zipfileset dir="compiler/testData" prefix="compiler"/>
<zipfileset dir="idea/testData" prefix="ide"/>
</zip>
</target>
<target name="build-artifacts" depends="zip-compiler,kotlin-for-upsource,zip-test-data"/>
</project>