Commit 1d1ebf48 authored by cjhopman@chromium.org's avatar cjhopman@chromium.org

Make jars build from a single ant .xml template

The ant build files for each of the jars that we create consisted of
only fairly straightforward boilerplate. With the recent changes to
java.gypi and java_aidl.gypi we can now build these correctly from a
single .xml with GYP passing in defines for the minor differences.

BUG=136756


Review URL: https://chromiumcodereview.appspot.com/10831227

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151334 0039d316-1c4b-4281-b951-d872f2087c98
parent d6fb791f
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<project name="Base" default="dist" basedir=".">
<description>
building base java source code with ant
</description>
<import file="../../../build/android/ant/chromium-jars.xml" />
<path id="javac.custom.classpath">
<pathelement location="${ANDROID_SDK}/android.jar" />
</path>
</project>
<project name="BaseJavaTests" default="dist" basedir=".">
<description>
building base java tests source code with ant
</description>
<!-- Set global properties for this build -->
<property name="src" location="src"/>
<property name="dist" location="dist"/>
<property name="out.dir" location="${PRODUCT_DIR}/lib.java"/>
<!-- TODO(jrg): establish a standard for the intermediate java
directories. Settle on a standard once ant/jar build files
like this are androidified -->
<property name="dest.dir" location="${PRODUCT_DIR}/java/base_javatests"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${out.dir}"/>
<mkdir dir="${dest.dir}"/>
</target>
<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<!-- TODO(jrg): adapting this to a proper android antfile will
remove warnings like this:
base.xml:23: warning: 'includeantruntime' was not set,
defaulting to build.sysclasspath=last;
set to false for repeatable builds
-->
<javac srcdir="${src}" destdir="${dest.dir}" debug="true" includeantruntime="false">
<classpath>
<path location="${ANDROID_SDK}/android.jar"/>
</classpath>
</javac>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${out.dir}"/>
<jar jarfile="${out.dir}/chromium_base_javatests.jar" basedir="${dest.dir}"/>
</target>
<target name="clean"
description="clean up" >
<!-- Delete the appropriate directory trees -->
<delete dir="${dest.dir}"/>
<delete dir="${dist}"/>
</target>
</project>
......@@ -7,15 +7,27 @@
<!--
Common ant build file for for chromium_*.jars.
For creating a new chromium_*.jar :
1. Use build/java.gyp action. This action will set PACKAGE_NAME.
1. Use build/java.gypi action.
The jar will be created as chromium_${PACKAGE_NAME} in
${PRODUCT_DIR}/lib.java.
2. Set javac.custom.classpath to classpath to use for javac.
3. Override javac.srcdir for providing custom source directory for javac.
-->
<description>
Building ${PROJECT_NAME}/ java source code with ant.
</description>
<import file="common.xml"/>
<property-location name="src" location="src"/>
<path id="javac.custom.classpath">
<filelist dir="/" files="${INPUT_JARS_PATHS}"/>
<pathelement location="${ANDROID_SDK}/android.jar" />
</path>
<path id="javac.srcdirs.additional">
<filelist dir="/" files="${ADDITIONAL_SRC_DIRS}" />
</path>
<property-value name="javac.srcdir" value="src:${toString:javac.srcdirs.additional}"/>
<property-location name="lib.dir" location="${PRODUCT_DIR}/lib.java"
check-exists="false"/>
<property-location name="dest.dir" location="${PRODUCT_DIR}/java/${PACKAGE_NAME}"
......@@ -29,11 +41,6 @@
<mkdir dir="${dest.dir}"/>
</target>
<!--
Compile target for jars. Requires javac.custom.classpath to be set.
Optionally javac.srcdir can be overridden to custom path for src
directories.
-->
<target name="compile" depends="init" description="Compiles source." >
<fail message="Error: javac.custom.classpath is not set. Please set it to
classpath for javac.">
......@@ -41,13 +48,16 @@
<not><isreference refid="javac.custom.classpath"/></not>
</condition>
</fail>
<property-value name="javac.srcdir" value ="${src}"/>
<echo>Compiling ${javac.srcdir}, classpath: ${toString:javac.custom.classpath}</echo>
<javac srcdir="${javac.srcdir}" destdir="${dest.dir}" debug="true" includeantruntime="false">
<classpath>
<path refid="javac.custom.classpath" />
</classpath>
</javac>
<javac
srcdir="${javac.srcdir}"
destdir="${dest.dir}"
classpathref="javac.custom.classpath"
debug="true"
includeantruntime="false"
/>
</target>
<target name="dist" depends="compile"
......
......@@ -44,7 +44,6 @@
'inputs': [
'android/ant/common.xml',
'android/ant/chromium-jars.xml',
'<(java_in_dir)/<(package_name).xml',
'<!@(find <(java_in_dir) -name "*.java")',
'>@(input_jars_paths)',
],
......@@ -55,14 +54,16 @@
'ant',
'-DPRODUCT_DIR=<(ant_build_out)',
'-DPACKAGE_NAME=<(package_name)',
'-DINPUT_JARS_PATHS=>(input_jars_paths)',
'-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)',
'-DANDROID_SDK=<(android_sdk)',
'-DANDROID_SDK_ROOT=<(android_sdk_root)',
'-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
'-DANDROID_SDK_VERSION=<(android_sdk_version)',
'-DANDROID_TOOLCHAIN=<(android_toolchain)',
'-Dbasedir=<(java_in_dir)',
'-buildfile',
'<(java_in_dir)/<(package_name).xml',
'<(DEPTH)/build/android/ant/chromium-jars.xml'
]
},
],
......
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<project name="Chrome" default="dist" basedir=".">
<description>
Building chrome.jar from java source code.
</description>
<import file="../../../build/android/ant/chromium-jars.xml" />
<path id="javac.custom.classpath">
<pathelement location="${ANDROID_SDK}/android.jar" />
<pathelement location="${lib.dir}/chromium_content.jar" />
<pathelement location="${lib.dir}/chromium_base.jar" />
<pathelement location="${lib.dir}/chromium_net.jar" />
</path>
<!-- Override javac path to include jars in lib.java directory -->
<property-value name="javac.srcdir" value="${src}" />
</project>
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<project name="Content" default="dist" basedir=".">
<description>
building content java source code with ant
</description>
<import file="../../../../build/android/ant/chromium-jars.xml" />
<path id="javac.custom.classpath">
<pathelement location="${ANDROID_SDK}/android.jar" />
<pathelement location="${lib.dir}/chromium_base.jar" />
<pathelement location="${lib.dir}/chromium_net.jar" />
</path>
<path id="javac.srcdirs.additional">
<filelist dir="/" files="${ADDITIONAL_SRC_DIRS}" />
</path>
<!-- Override javac path to include jars in lib.java directory -->
<property-value name="javac.srcdir" value="${src}:${toString:javac.srcdirs.additional}" />
</project>
<!-- Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<project name="ContentJavaTests" default="dist" basedir=".">
<description>
building content-only instrumentation tests with ant
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="out.dir" location="${PRODUCT_DIR}/lib.java"/>
<property name="classes.dir" location="${PRODUCT_DIR}/java/${PACKAGE_NAME}"/>
<property name="jar.dir" location="${out.dir}"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${out.dir}"/>
</target>
<target name="compile" depends="init"
description="compile the source " >
<!-- Create the classes output directory -->
<mkdir dir="${classes.dir}"/>
<!-- Compile the java code from ${src} into ${classes.dir} -->
<!-- Gyp target should have compiled aidl files into java source files in
lib.jar (see content.gyp:common_aidl). -->
<javac srcdir="${src}" destdir="${classes.dir}" debug="true" includeantruntime="false">
<classpath>
<pathelement path="${ANDROID_SDK}/android.jar" />
<pathelement path="${jar.dir}/chromium_base.jar" />
<pathelement path="${jar.dir}/chromium_base_javatests.jar" />
<pathelement path="${jar.dir}/chromium_content.jar" />
</classpath>
</javac>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${jar.dir}"/>
<!-- Put everything in ${classes.dir} into the chromium_content_tests.jar file -->
<jar jarfile="${jar.dir}/chromium_${PACKAGE_NAME}.jar" basedir="${classes.dir}"/>
</target>
<target name="clean" description="clean up" >
<!-- Delete the generated content -->
<delete dir="${classes.dir}"/>
<delete file="${jar.dir}/chromium_${PACKAGE_NAME}.jar"/>
</target>
</project>
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<project name="Media" default="dist" basedir=".">
<description>
building media java source code with ant
</description>
<import file="../../../../build/android/ant/chromium-jars.xml"/>
<path id="javac.custom.classpath">
<pathelement location="${ANDROID_SDK}/android.jar"/>
<pathelement location="${lib.dir}/chromium_base.jar"/>
</path>
</project>
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<project name="net" default="dist" basedir=".">
<description>
Building net/ java source code with ant.
</description>
<import file="../../../build/android/ant/chromium-jars.xml"/>
<path id="javac.custom.classpath">
<pathelement location="${ANDROID_SDK}/android.jar"/>
<pathelement location="${lib.dir}/chromium_base.jar"/>
</path>
</project>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment