David Ghandehari | 9e5b587 | 2016-07-28 09:50:04 -0700 | [diff] [blame] | 1 | <!-- |
| 2 | Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 | Use of this source code is governed by a BSD-style license that can be |
| 4 | found in the LICENSE file. |
| 5 | --> |
| 6 | <project name="chromium-jars" default="dist"> |
| 7 | <!-- |
| 8 | Common ant build file for for chromium_*.jars. |
| 9 | For creating a new chromium_*.jar : |
| 10 | 1. Use build/java.gypi action. |
| 11 | The jar will be created as chromium_${PACKAGE_NAME} in |
| 12 | ${PRODUCT_DIR}/lib.java. |
| 13 | --> |
| 14 | <description> |
| 15 | Building ${PROJECT_NAME}/ java source code with ant. |
| 16 | </description> |
| 17 | |
| 18 | <import file="common.xml"/> |
| 19 | |
| 20 | <path id="javac.custom.classpath"> |
| 21 | <filelist files="${INPUT_JARS_PATHS}"/> |
| 22 | <pathelement location="${ANDROID_SDK}/android.jar"/> |
| 23 | </path> |
| 24 | |
| 25 | <path id="javac.srcdirs.additional"> |
| 26 | <filelist files="${ADDITIONAL_SRC_DIRS}"/> |
| 27 | <filelist files="${GENERATED_SRC_DIRS}"/> |
| 28 | </path> |
| 29 | |
| 30 | <property-value |
| 31 | name="javac.srcdir" |
| 32 | value="src:${toString:javac.srcdirs.additional}" |
| 33 | /> |
| 34 | |
| 35 | <property-location |
| 36 | name="dest.dir" |
| 37 | location="${PRODUCT_DIR}/java/${PACKAGE_NAME}" |
| 38 | check-exists="false" |
| 39 | /> |
| 40 | |
| 41 | <condition property="javac_includes_message" |
| 42 | value="" |
| 43 | else="Include filter: ${JAVAC_INCLUDES}"> |
| 44 | <equals arg1="${JAVAC_INCLUDES}" arg2=""/> |
| 45 | </condition> |
| 46 | |
| 47 | <target name="init"> |
| 48 | <!-- Create the time stamp --> |
| 49 | <tstamp/> |
| 50 | <!-- Create the build directory structure used by compile --> |
| 51 | <mkdir dir="${dest.dir}"/> |
| 52 | |
| 53 | <!-- Remove all .class files from dest.dir. This prevents inclusion of |
| 54 | incorrect .class files in the final .jar. For example, if a .java file |
| 55 | was deleted, the .jar should not contain the .class files for that |
| 56 | .java from previous builds. |
| 57 | --> |
| 58 | <delete> |
| 59 | <fileset dir="${dest.dir}" includes="**/*.class"/> |
| 60 | </delete> |
| 61 | </target> |
| 62 | |
| 63 | <target name="compile" depends="init" description="Compiles source."> |
| 64 | <fail message="Error: javac.custom.classpath is not set. Please set it to |
| 65 | classpath for javac."> |
| 66 | <condition> |
| 67 | <not><isreference refid="javac.custom.classpath"/></not> |
| 68 | </condition> |
| 69 | </fail> |
| 70 | |
| 71 | <echo> |
| 72 | Compiling ${javac.srcdir}, classpath: ${toString:javac.custom.classpath} |
| 73 | ${javac_includes_message} |
| 74 | </echo> |
| 75 | |
| 76 | <!-- __LB_SHELL__ |
| 77 | Android SDK build toolchain doesn't support Java 1.7 so we force |
| 78 | the source and target versions to 1.6. Failure to do will result |
| 79 | in .class files that can't be parsed by the dexer. |
| 80 | --> |
| 81 | <javac |
| 82 | source="1.6" |
| 83 | target="1.6" |
| 84 | srcdir="${javac.srcdir}" |
| 85 | destdir="${dest.dir}" |
| 86 | classpathref="javac.custom.classpath" |
| 87 | debug="true" |
| 88 | includeantruntime="false" |
| 89 | includes="${JAVAC_INCLUDES}"> |
| 90 | <compilerarg value="-Xlint:unchecked"/> |
| 91 | </javac> |
| 92 | </target> |
| 93 | |
| 94 | <target name="dist" depends="compile" |
| 95 | description="Generate chromium_${PACKAGE_NAME}.jar."> |
| 96 | <!-- Create the distribution directory. We exclude R.class and R$*.class |
| 97 | files since new versions of these files with the correct resource -> ID |
| 98 | mapping will be provided when we build each individual apk. --> |
| 99 | <jar |
| 100 | jarfile="${lib.java.dir}/chromium_${PACKAGE_NAME}.jar" |
| 101 | excludes="**/R.class **/R$*.class" |
| 102 | basedir="${dest.dir}" |
| 103 | /> |
| 104 | |
| 105 | <!-- If Gyp thinks this output is stale but Ant doesn't, the modification |
| 106 | time should still be updated. Otherwise, this target will continue to |
| 107 | be rebuilt in future builds. |
| 108 | --> |
| 109 | <touch file="${lib.java.dir}/chromium_${PACKAGE_NAME}.jar"/> |
| 110 | </target> |
| 111 | |
| 112 | <target name="clean" description="clean up"> |
| 113 | <!-- Delete the appropriate directory trees --> |
| 114 | <delete dir="${dest.dir}"/> |
| 115 | </target> |
| 116 | </project> |