|
6 | 6 | <!-- Set to false to disable compiler's javadoc generation. Speeds up the build -->
|
7 | 7 | <property name="generate.javadoc" value="true"/>
|
8 | 8 |
|
| 9 | + <!-- Set to false to prevent jarjar and metadata stripping on kotlin-reflect.jar and reflection sources. Use to debug reflection --> |
| 10 | + <property name="obfuscate.reflect" value="true"/> |
| 11 | + |
9 | 12 | <property name="max.heap.size.for.forked.jvm" value="1024m"/>
|
10 | 13 |
|
11 | 14 | <property name="bootstrap.home" value="${basedir}/dependencies/bootstrap-compiler"/>
|
|
908 | 911 | </jar>
|
909 | 912 |
|
910 | 913 | <delete file="${output}/kotlin-reflect-jarjar.jar" failonerror="false"/>
|
911 |
| - <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="dependencies/jarjar.jar"/> |
912 |
| - <jarjar jarfile="${output}/kotlin-reflect-jarjar.jar" filesonly="true" filesetmanifest="merge"> |
913 |
| - <zipfileset src="${output}/kotlin-reflect-before-jarjar.jar"/> |
914 |
| - <rule pattern="org.jetbrains.kotlin.**" result="kotlin.reflect.jvm.internal.impl.@1"/> |
915 |
| - <rule pattern="com.google.protobuf.**" result="kotlin.reflect.jvm.internal.impl.com.google.protobuf.@1"/> |
916 |
| - <rule pattern="javax.inject.**" result="kotlin.reflect.jvm.internal.impl.javax.inject.@1"/> |
917 |
| - </jarjar> |
918 |
| - |
919 |
| - <kotlinc src="${basedir}/generators/infrastructure/strip-kotlin-annotations.kts" output=""> |
920 |
| - <compilerarg value="-script"/> |
921 |
| - <compilerarg value="kotlin/jvm/internal/.*"/> <!-- Annotations to strip --> |
922 |
| - <compilerarg value="kotlin/reflect/jvm/internal/impl/.*"/> <!-- Classes to strip from --> |
923 |
| - <compilerarg value="${output}/kotlin-reflect-jarjar.jar"/> |
924 |
| - <compilerarg value="${kotlin-home}/lib/kotlin-reflect.jar"/> |
925 |
| - <classpath> |
926 |
| - <pathelement location="${idea.sdk}/lib/asm-all.jar"/> |
927 |
| - </classpath> |
928 |
| - </kotlinc> |
| 914 | + |
| 915 | + <sequential if:true="${obfuscate.reflect}"> |
| 916 | + <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="dependencies/jarjar.jar"/> |
| 917 | + <jarjar jarfile="${output}/kotlin-reflect-jarjar.jar" filesonly="true" filesetmanifest="merge"> |
| 918 | + <zipfileset src="${output}/kotlin-reflect-before-jarjar.jar"/> |
| 919 | + <rule pattern="org.jetbrains.kotlin.**" result="kotlin.reflect.jvm.internal.impl.@1"/> |
| 920 | + <rule pattern="com.google.protobuf.**" result="kotlin.reflect.jvm.internal.impl.com.google.protobuf.@1"/> |
| 921 | + <rule pattern="javax.inject.**" result="kotlin.reflect.jvm.internal.impl.javax.inject.@1"/> |
| 922 | + </jarjar> |
| 923 | + |
| 924 | + <kotlinc src="${basedir}/generators/infrastructure/strip-kotlin-annotations.kts" output=""> |
| 925 | + <compilerarg value="-script"/> |
| 926 | + <compilerarg value="kotlin/jvm/internal/.*"/> <!-- Annotations to strip --> |
| 927 | + <compilerarg value="kotlin/reflect/jvm/internal/impl/.*"/> <!-- Classes to strip from --> |
| 928 | + <compilerarg value="${output}/kotlin-reflect-jarjar.jar"/> |
| 929 | + <compilerarg value="${kotlin-home}/lib/kotlin-reflect.jar"/> |
| 930 | + <classpath> |
| 931 | + <pathelement location="${idea.sdk}/lib/asm-all.jar"/> |
| 932 | + </classpath> |
| 933 | + </kotlinc> |
| 934 | + </sequential> |
| 935 | + |
| 936 | + <sequential unless:true="${obfuscate.reflect}"> |
| 937 | + <echo message="Obfuscation of kotlin-reflect is disabled"/> |
| 938 | + <copy file="${output}/kotlin-reflect-before-jarjar.jar" tofile="${output}/kotlin-reflect-jarjar.jar" overwrite="true"/> |
| 939 | + <copy file="${output}/kotlin-reflect-before-jarjar.jar" tofile="${kotlin-home}/lib/kotlin-reflect.jar" overwrite="true"/> |
| 940 | + </sequential> |
929 | 941 | </target>
|
930 | 942 |
|
931 | 943 | <target name="pack-runtime-sources">
|
932 |
| - |
933 |
| - <!-- Rename packages in the sources of reflection impl (core) --> |
934 | 944 | <delete dir="${output}/core.src" failonerror="false"/>
|
935 |
| - <copy todir="${output}/core.src/kotlin/reflect/jvm/internal/impl"> |
| 945 | + |
| 946 | + <local name="runtime.sources.base.dir"/> |
| 947 | + <condition property="runtime.sources.base.dir" |
| 948 | + value="${output}/core.src/kotlin/reflect/jvm/internal/impl" |
| 949 | + else="${output}/core.src/org/jetbrains/kotlin"> |
| 950 | + <istrue value="${obfuscate.reflect}"/> |
| 951 | + </condition> |
| 952 | + |
| 953 | + <copy todir="${runtime.sources.base.dir}"> |
936 | 954 | <fileset dir="core">
|
937 | 955 | <include name="descriptor.loader.java/src/**"/>
|
938 | 956 | <include name="descriptors/src/**"/>
|
|
942 | 960 | </fileset>
|
943 | 961 | <cutdirsmapper dirs="5"/> <!-- module/src/org/jetbrains/kotlin -->
|
944 | 962 | </copy>
|
945 |
| - <replaceregexp match="org\.jetbrains\.kotlin" replace="kotlin.reflect.jvm.internal.impl" flags="g"> |
946 |
| - <fileset dir="${output}/core.src"/> |
947 |
| - </replaceregexp> |
| 963 | + |
| 964 | + <sequential if:true="${obfuscate.reflect}"> |
| 965 | + <!-- Rename packages in the sources of reflection impl (core) --> |
| 966 | + <replaceregexp match="org\.jetbrains\.kotlin" replace="kotlin.reflect.jvm.internal.impl" flags="g"> |
| 967 | + <fileset dir="${output}/core.src"/> |
| 968 | + </replaceregexp> |
| 969 | + </sequential> |
948 | 970 |
|
949 | 971 | <pack-runtime-jar jar-name="kotlin-runtime-sources.jar" implementation-title="${manifest.impl.title.kotlin.jvm.runtime.sources}">
|
950 | 972 | <jar-content>
|
|
0 commit comments