| <project name="Kotlin" default="dist"> |
| |
| <!-- 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 javadoc generation. Speeds up the build --> |
| <property name="generate.javadoc" value="true"/> |
| |
| <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="output.name" value="kotlin-${build.number}"/> |
| <property name="idea.sdk" value="${basedir}/ideaSDK"/> |
| |
| <path id="classpath"> |
| <fileset dir="${idea.sdk}" includes="core/*.jar"/> |
| |
| <!-- |
| Work around this problem: https://gist.github.com/1c4a7d51b61ec81d581b |
| Somebody please fix it properly or delete this comment if this is OK |
| --> |
| <pathelement path="${idea.sdk}/lib/resources_en.jar"/> |
| |
| <fileset dir="${basedir}/lib" includes="**/*.jar"/> |
| <fileset dir="${basedir}/dependencies" includes="jline.jar"/> |
| <fileset dir="${basedir}/dependencies" includes="jansi.jar"/> |
| <fileset dir="${basedir}/dependencies" includes="jetbrains-asm-util-4.0.jar"/> |
| <fileset dir="${basedir}/js/js.translator/lib" includes="*.jar"/> |
| </path> |
| |
| <dirset id="compilerSources.dirset" dir="${basedir}/"> |
| <include name="compiler/frontend/src"/> |
| <include name="compiler/frontend.java/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="j2k/src"/> |
| <include name="compiler/jet.as.java.psi/src"/> |
| |
| <include name="runtime/src"/> |
| |
| <include name="js/js.translator/src"/> |
| </dirset> |
| |
| <path id="compilerSources.path"> |
| <dirset refid="compilerSources.dirset"/> |
| </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" depends="clean"> |
| <mkdir dir="${kotlin-home}"/> |
| <mkdir dir="${kotlin-home}/lib"/> |
| <mkdir dir="${kotlin-home}/lib/alt"/> |
| </target> |
| |
| <target name="prepareDist"> |
| <copy todir="${kotlin-home}/bin"> |
| <fileset dir="${basedir}/compiler/cli/bin"/> |
| </copy> |
| |
| <copy todir="${kotlin-home}/license"> |
| <fileset dir="${basedir}/license"/> |
| </copy> |
| |
| <echo file="${kotlin-home}/build.txt" message="${build.number}"/> |
| |
| <chmod dir="${kotlin-home}/bin" includes="*" perm="755"/> |
| </target> |
| |
| <target name="injectorsGenerator"> |
| <cleandir dir="${output}/classes/injectorsGenerator"/> |
| <javac destdir="${output}/classes/injectorsGenerator" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"> |
| <src path="injector-generator/src"/> |
| <src path="generators/org/jetbrains/jet/generators/injectors"/> |
| <src refid="compilerSources.path"/> |
| <classpath refid="classpath"/> |
| </javac> |
| </target> |
| |
| <target name="generateInjectors" depends="injectorsGenerator"> |
| <java classname="org.jetbrains.jet.generators.injectors.GenerateInjectors" failonerror="true"> |
| <classpath refid="classpath"/> |
| <classpath path="${output}/classes/injectorsGenerator"/> |
| </java> |
| </target> |
| |
| <target name="compilerSources"> |
| <if> |
| <istrue value="${generate.javadoc}"/> |
| |
| <then> |
| <jar jarfile="${output}/kotlin-compiler-sources.jar"> |
| <!-- TODO How to convert it from pathset or dirset ? --> |
| <fileset dir="compiler/frontend/src"/> |
| <fileset dir="compiler/frontend.java/src"/> |
| <fileset dir="compiler/backend/src"/> |
| <fileset dir="compiler/cli/src"/> |
| <fileset dir="j2k/src"/> |
| <fileset dir="compiler/util/src"/> |
| <fileset dir="compiler/jet.as.java.psi/src"/> |
| <fileset dir="runtime/src"/> |
| <fileset dir="js/js.translator/src"/> |
| <zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/> |
| |
| <manifest> |
| <attribute name="Built-By" value="JetBrains"/> |
| |
| <attribute name="Implementation-Vendor" value="JetBrains"/> |
| <attribute name="Implementation-Title" value="Kotlin Compiler Sources"/> |
| <attribute name="Implementation-Version" value="${build.number}"/> |
| </manifest> |
| </jar> |
| |
| <delete dir="${output}/kotlin-compiler-javadoc" failonerror="false" /> |
| <javadoc destdir="${output}/kotlin-compiler-javadoc" |
| sourcepathref="compilerSources.path" |
| classpathref="classpath" |
| linksource="yes" |
| windowtitle="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="JetBrains"/> |
| |
| <attribute name="Implementation-Vendor" value="JetBrains"/> |
| <attribute name="Implementation-Title" value="Kotlin Compiler Javadoc"/> |
| <attribute name="Implementation-Version" value="${build.number}"/> |
| </manifest> |
| </jar> |
| </then> |
| </if> |
| </target> |
| |
| <target name="jslib"> |
| <jar jarfile="${kotlin-home}/lib/kotlin-jslib.jar"> |
| <fileset dir="${basedir}/js/js.libraries/src"> |
| <include name="core/**"/> |
| <include name="jquery/**"/> |
| <include name="dom/**"/> |
| <include name="html5/**"/> |
| <include name="stdlib/TuplesCode.kt"/> |
| </fileset> |
| <zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/> |
| </jar> |
| <java classname="com.google.javascript.jscomp.CommandLineRunner" failonerror="true"> |
| <classpath> |
| <pathelement location="${basedir}\js\js.tests\testLib\closure-compiler.jar"/> |
| </classpath> |
| <arg value="--formatting"/> |
| <arg value="PRETTY_PRINT"/> |
| <arg value="--language_in"/> |
| <arg value="ECMASCRIPT5_STRICT"/> |
| <arg value="--compilation_level"/> |
| <arg value="SIMPLE_OPTIMIZATIONS"/> |
| <arg value="--js"/> |
| <arg value="${basedir}/js/js.translator/testFiles/kotlin_lib_ecma5.js"/> |
| <arg value="--js"/> |
| <arg value="${basedir}/js/js.translator/testFiles/kotlin_lib.js"/> |
| <arg value="--js"/> |
| <arg value="${basedir}/js/js.translator/testFiles/maps.js"/> |
| <arg value="--js_output_file"/> |
| <arg value="${kotlin-home}/lib/kotlinEcma5.js"/> |
| </java> |
| <java classname="com.google.javascript.jscomp.CommandLineRunner" failonerror="true"> |
| <classpath> |
| <pathelement location="${basedir}/js/js.tests/testLib/closure-compiler.jar"/> |
| </classpath> |
| <arg value="--formatting"/> |
| <arg value="PRETTY_PRINT"/> |
| <arg value="--language_in"/> |
| <arg value="ECMASCRIPT3"/> |
| <arg value="--compilation_level"/> |
| <arg value="SIMPLE_OPTIMIZATIONS"/> |
| <arg value="--js"/> |
| <arg value="${basedir}/js/js.translator/testFiles/kotlin_lib_ecma3.js"/> |
| <arg value="--js"/> |
| <arg value="${basedir}/js/js.translator/testFiles/kotlin_lib.js"/> |
| <arg value="--js"/> |
| <arg value="${basedir}/js/js.translator/testFiles/maps.js"/> |
| <arg value="--js_output_file"/> |
| <arg value="${kotlin-home}/lib/kotlinEcma3.js"/> |
| </java> |
| </target> |
| |
| <target name="compiler"> |
| <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${basedir}/dependencies/jarjar.jar"/> |
| <taskdef resource="proguard/ant/task.properties" classpath="${basedir}/dependencies/proguard.jar"/> |
| <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${basedir}/dependencies/ant-contrib.jar"/> |
| |
| <cleandir dir="${output}/classes/compiler"/> |
| <javac destdir="${output}/classes/compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"> |
| <src refid="compilerSources.path"/> |
| <classpath refid="classpath"/> |
| </javac> |
| |
| <!-- JarJar Kotlin compiler & dependencies --> |
| <jarjar jarfile="${output}/kotlin-compiler-jarjar.jar"> |
| <fileset dir="${output}/classes/compiler"/> |
| <fileset dir="${basedir}/compiler/frontend/src" includes="jet/**"/> |
| |
| <zipgroupfileset dir="${basedir}/lib" includes="*.jar"/> |
| <zipgroupfileset dir="${basedir}/ideaSDK/core" includes="*.jar"/> |
| <zipgroupfileset dir="${basedir}/ideaSDK/lib" includes="jna-utils.jar"/> |
| <zipgroupfileset dir="${basedir}/ideaSDK/lib" includes="oromatcher.jar"/> |
| <zipgroupfileset dir="${basedir}/js/js.translator/lib" includes="*.jar"/> |
| <zipgroupfileset dir="${basedir}/dependencies" includes="jline.jar"/> |
| <zipgroupfileset dir="${basedir}/dependencies" includes="jansi.jar"/> |
| <zipgroupfileset dir="${basedir}/dependencies" includes="jetbrains-asm-util-4.0.jar"/> |
| <zipgroupfileset dir="${basedir}/dependencies" includes="jetbrains-asm-analysis-4.0.jar"/> |
| |
| <zap pattern="com.thoughtworks.xstream.converters.extended.ISO8601*"/> |
| <zap pattern="com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter*"/> |
| <zap pattern="com.thoughtworks.xstream.io.xml.Dom4J*"/> |
| <zap pattern="com.thoughtworks.xstream.io.xml.Xom*"/> |
| <zap pattern="com.thoughtworks.xstream.mapper.CGLIBMapper*"/> |
| |
| <zap pattern="org.apache.log4j.jmx.Agent"/> |
| <zap pattern="org.apache.log4j.net.JMS*"/> |
| <zap pattern="org.apache.log4j.net.SMTP*"/> |
| <zap pattern="org.apache.log4j.or.jms.MessageRenderer"/> |
| |
| <zap pattern="org.jdom.xpath.Jaxen*"/> |
| |
| <zap pattern="org.mozilla.javascript.xml.impl.xmlbeans.**"/> |
| |
| <rule pattern="com.intellij.**" result="org.jetbrains.jet.internal.com.intellij.@1"/> |
| <rule pattern="com.sun.jna.**" result="org.jetbrains.jet.internal.com.sun.jna.@1"/> |
| <rule pattern="org.apache.log4j.**" result="org.jetbrains.jet.internal.org.apache.log4j.@1"/> |
| <rule pattern="org.jdom.**" result="org.jetbrains.jet.internal.org.jdom.@1"/> |
| <rule pattern="JDOMAbout**" result="org.jetbrains.jet.internal.org.jdom.JDOMAbout@1"/> |
| <rule pattern="org.intellij.lang.annotations.**" result="org.jetbrains.jet.internal.org.intellij.lang.annotations.@1"/> |
| <rule pattern="com.google.**" result="org.jetbrains.jet.internal.com.google.@1"/> |
| <rule pattern="org.objectweb.asm.**" result="org.jetbrains.jet.internal.org.objectweb.asm.@1"/> |
| <rule pattern="com.sampullara.cli.**" result="org.jetbrains.jet.internal.com.sampullara.cli.@1"/> |
| <rule pattern="org.picocontainer.**" result="org.jetbrains.jet.internal.org.picocontainer.@1"/> |
| <rule pattern="gnu.trove.**" result="org.jetbrains.jet.internal.gnu.trove.@1"/> |
| <rule pattern="javax.inject.**" result="org.jetbrains.jet.internal.javax.inject.@1"/> |
| <rule pattern="com.thoughtworks.xstream.**" result="org.jetbrains.jet.internal.com.thoughtworks.xstream.@1"/> |
| <rule pattern="org.json.**" result="org.jetbrains.jet.internal.org.json.@1"/> |
| <rule pattern="org.mozilla.**" result="org.jetbrains.jet.internal.org.mozilla.@1"/> |
| <rule pattern="org.xmlpull.**" result="org.jetbrains.jet.internal.org.xmlpull.@1"/> |
| <rule pattern="org.kohsuke.args4j.**" result="org.jetbrains.jet.internal.org.kohsuke.args4j.@1"/> |
| |
| <manifest> |
| <attribute name="Built-By" value="JetBrains"/> |
| |
| <attribute name="Implementation-Vendor" value="JetBrains"/> |
| <attribute name="Implementation-Title" value="Kotlin Compiler"/> |
| <attribute name="Implementation-Version" value="${build.number}"/> |
| |
| <attribute name="Main-Class" value="org.jetbrains.jet.cli.jvm.K2JVMCompiler"/> |
| </manifest> |
| </jarjar> |
| |
| <delete file="${kotlin-home}/lib/kotlin-compiler.jar" failonerror="false"/> |
| |
| <if> |
| <isfalse value="${shrink}"/> |
| |
| <then> |
| <copy file="${output}/kotlin-compiler-jarjar.jar" |
| tofile="${kotlin-home}/lib/kotlin-compiler.jar"/> |
| </then> |
| |
| <else> |
| <cleandir dir="${output}/kotlin-compiler.exploded"/> |
| <unzip src="${output}/kotlin-compiler-jarjar.jar" dest="${output}/kotlin-compiler.exploded"/> |
| |
| <!-- Clean JarJar result --> |
| <jar jarfile="${output}/kotlin-compiler-before-proguard.jar" |
| manifest="${output}/kotlin-compiler.exploded/META-INF/MANIFEST.MF"> |
| |
| <fileset dir="${output}/kotlin-compiler.exploded"> |
| <include name="**/*.class"/> |
| <include name="**/*.jet"/> |
| <include name="**/*.kt"/> |
| <include name="META-INF/services/**"/> |
| <include name="messages/**"/> |
| </fileset> |
| <zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/> |
| </jar> |
| <delete dir="${output}/kotlin-compiler.exploded"/> |
| |
| <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"/> |
| |
| <proguard><![CDATA[ |
| -injars '${output}/kotlin-compiler-before-proguard.jar' |
| -outjars '${kotlin-home}/lib/kotlin-compiler.jar' |
| |
| -dontwarn org.jetbrains.jet.internal.com.intellij.util.** |
| -dontwarn org.jetbrains.jet.internal.com.intellij.codeInsight.** |
| -dontwarn org.jetbrains.jet.internal.com.thoughtworks.xstream.** |
| |
| -libraryjars '${rtjar}' |
| |
| -target 1.6 |
| -dontoptimize |
| -dontobfuscate |
| |
| -keepclasseswithmembers public class * { |
| public static void main(java.lang.String[]); |
| } |
| |
| -keep class org.jetbrains.annotations.** { |
| public protected *; |
| } |
| |
| -keep class org.jetbrains.k2js.** { |
| public protected *; |
| } |
| |
| -keep class org.jetbrains.jet.** { |
| public protected *; |
| } |
| |
| -keep class jet.** { |
| public protected *; |
| } |
| |
| -keepclasseswithmembers class * { void start(); } |
| |
| -keepclasseswithmembers class * { void stop(); } |
| -keepclasseswithmembers class * { void dispose(); } |
| |
| -keepclasseswithmembers class * { ** getFileSystem(); } |
| -keepclasseswithmembers class * { ** isVarArgs(); } |
| -keepclasseswithmembers class * { ** getApplication(); } |
| -keepclasseswithmembers class * { ** finalizeReferent(); } |
| -keepclasseswithmembers class * { ** newBuilder(); } |
| -keepclasseswithmembers class * { ** startFinalizer(java.lang.Class,java.lang.Object); } |
| -keepclasseswithmembers class * { ** executeOnPooledThread(java.lang.Runnable); } |
| -keepclasseswithmembers class * { ** getUserData(java.lang.String); } |
| -keepclasseswithmembers class * { int getBooleanAttributes(java.io.File); } |
| |
| -keepclasseswithmembers class * { ** project(); } |
| |
| -keepclasseswithmembers class * { ** TYPE; } |
| -keepclasseswithmembers class * { ** ourInstance; } |
| |
| -keepclasseswithmembers class * { <init>(kotlinc.internal.com.intellij.lang.ASTNode); } |
| |
| -keepclassmembers enum * { |
| public static **[] values(); |
| public static ** valueOf(java.lang.String); |
| } |
| |
| -keepclassmembers class * { |
| ** toString(); |
| ** hashCode(); |
| } |
| ]]></proguard> |
| </else> |
| </if> |
| </target> |
| |
| <target name="antTools"> |
| <cleandir dir="${output}/classes/buildTools"/> |
| <javac destdir="${output}/classes/buildTools" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"> |
| <src> |
| <dirset dir="${basedir}/build-tools"> |
| <include name="core/src"/> |
| <include name="ant/src"/> |
| </dirset> |
| </src> |
| <compilerarg value="-Xlint:all"/> |
| <classpath> |
| <fileset dir="${kotlin-home}/lib" includes="kotlin-compiler.jar"/> |
| <fileset dir="${basedir}/dependencies" includes="ant.jar"/> |
| </classpath> |
| </javac> |
| |
| <jar destfile="${kotlin-home}/lib/kotlin-ant.jar"> |
| <fileset dir="${output}/classes/buildTools"/> |
| <fileset dir="${basedir}/build-tools/ant/src" includes="**/*.xml"/> |
| <zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/> |
| |
| <manifest> |
| <attribute name="Built-By" value="JetBrains"/> |
| |
| <attribute name="Implementation-Vendor" value="JetBrains"/> |
| <attribute name="Implementation-Title" value="Kotlin Compiler Ant Tasks"/> |
| <attribute name="Implementation-Version" value="${build.number}"/> |
| |
| <attribute name="Class-Path" value="kotlin-compiler.jar"/> |
| </manifest> |
| </jar> |
| </target> |
| |
| <target name="jdkAnnotations"> |
| <cleandir dir="${output}/classes/stdlib"/> |
| |
| <jar destfile="${kotlin-home}/lib/kotlin-jdk-annotations.jar"> |
| <fileset dir="${basedir}/jdk-annotations"/> |
| <zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/> |
| |
| <manifest> |
| <attribute name="Built-By" value="JetBrains"/> |
| |
| <attribute name="Implementation-Vendor" value="JetBrains"/> |
| <attribute name="Implementation-Title" value="Kotlin Compiler JDK Annotations"/> |
| <attribute name="Implementation-Version" value="${build.number}"/> |
| </manifest> |
| </jar> |
| </target> |
| |
| <target name="runtime"> |
| <cleandir dir="${output}/classes/runtime"/> |
| <javac destdir="${output}/classes/runtime" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"> |
| <src path="${basedir}/runtime/src"/> |
| </javac> |
| |
| <cleandir dir="${output}/classes/stdlib"/> |
| <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> |
| <arg value="-src"/> |
| <arg value="${basedir}/libraries/stdlib/src"/> |
| <arg value="-output"/> |
| <arg value="${output}/classes/stdlib"/> |
| <arg value="-noStdlib"/> |
| <arg value="-classpath"/> |
| <arg value="${output}/classes/runtime"/> |
| </java> |
| |
| <jar destfile="${kotlin-home}/lib/kotlin-runtime.jar"> |
| <fileset dir="${output}/classes/runtime"/> |
| <fileset dir="${output}/classes/stdlib"/> |
| <fileset dir="${basedir}/runtime" includes="src/**/*"/> |
| <fileset dir="${basedir}/libraries/stdlib" includes="src/**/*"/> |
| <zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/> |
| |
| <manifest> |
| <attribute name="Built-By" value="JetBrains"/> |
| |
| <attribute name="Implementation-Vendor" value="JetBrains"/> |
| <attribute name="Implementation-Title" value="Kotlin Compiler Runtime + StdLib"/> |
| <attribute name="Implementation-Version" value="${build.number}"/> |
| </manifest> |
| </jar> |
| </target> |
| |
| <target name="lang"> |
| <cleandir dir="${output}/classes/lang"/> |
| <java classname="org.jetbrains.jet.cli.jvm.K2JVMCompiler" failonerror="true"> |
| <classpath> |
| <pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/> |
| </classpath> |
| <arg value="-src"/> |
| <arg value="${basedir}/compiler/frontend/src"/> |
| <arg value="-output"/> |
| <arg value="${output}/classes/lang"/> |
| <arg value="-noStdlib"/> |
| <arg value="-builtins"/> |
| </java> |
| |
| <!-- Not used yet --> |
| <!-- |
| <jar destfile="${kotlin-home}/lib/lang.jar"> |
| <fileset dir="${output}/classes/lang"/> |
| </jar> |
| --> |
| </target> |
| |
| <target name="dist" |
| depends="init,prepareDist,injectorsGenerator,generateInjectors,compiler,compilerSources,antTools,jdkAnnotations,runtime,lang,jslib"/> |
| |
| <target name="zip" depends="dist"> |
| <zip destfile="${output}/${output.name}.zip"> |
| <zipfileset prefix="kotlinc" dir="${kotlin-home}"/> |
| </zip> |
| <echo message="##teamcity[publishArtifacts '${output.relative}/${output.name}.zip']"/> |
| </target> |
| </project> |
| |
| <!-- vim: set ts=4 sw=4 et nowrap: --> |