blob: 0a544820f3bc91da4ff1a32c86877d2ec4762daa [file] [log] [blame]
Raphael Mollcba8e112013-02-04 15:21:35 -08001#!/bin/bash
2# Copyright 2011, The Android Open Source Project
Raphael Moll08537a52013-01-04 15:17:44 -08003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# Set up prog to be the path of this script, including following symlinks,
17# and set up progdir to be the fully-qualified pathname of its directory.
Raphael Moll08537a52013-01-04 15:17:44 -080018prog="$0"
19while [ -h "${prog}" ]; do
20 newProg=`/bin/ls -ld "${prog}"`
21 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
22 if expr "x${newProg}" : 'x/' >/dev/null; then
23 prog="${newProg}"
24 else
25 progdir=`dirname "${prog}"`
26 prog="${progdir}/${newProg}"
27 fi
28done
29oldwd=`pwd`
30progdir=`dirname "${prog}"`
31cd "${progdir}"
32progdir=`pwd`
33prog="${progdir}"/`basename "${prog}"`
34cd "${oldwd}"
35
Raphael Mollcba8e112013-02-04 15:21:35 -080036jarfile=lint.jar
Raphael Moll08537a52013-01-04 15:17:44 -080037frameworkdir="$progdir"
38libdir="$progdir"
39if [ ! -r "$frameworkdir/$jarfile" ]
40then
41 frameworkdir=`dirname "$progdir"`/tools/lib
42 libdir=`dirname "$progdir"`/tools/lib
43fi
44if [ ! -r "$frameworkdir/$jarfile" ]
45then
46 frameworkdir=`dirname "$progdir"`/framework
47 libdir=`dirname "$progdir"`/lib
48fi
49if [ ! -r "$frameworkdir/$jarfile" ]
50then
51 echo `basename "$prog"`": can't find $jarfile"
52 exit 1
53fi
54
Raphael Mollcba8e112013-02-04 15:21:35 -080055# Check args.
56if [ debug = "$1" ]; then
57 # add this in for debugging
58 java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
59 shift 1
60else
61 java_debug=
Raphael Moll08537a52013-01-04 15:17:44 -080062fi
63
Raphael Mollcba8e112013-02-04 15:21:35 -080064javaCmd="java"
65
66jarpath="$frameworkdir/$jarfile"
Raphael Moll08537a52013-01-04 15:17:44 -080067
Tobias Thierer07a8c192017-11-30 23:30:21 +000068is_java_version_9=$(java -version 2>&1| grep 'version [ "]9.*[ "]')
69if [ "${is_java_version_9}" = "" ]; then
70 modules_arg=""
71else
72 modules_arg="--add-modules=java.xml.bind"
73fi
74
Raphael Moll08537a52013-01-04 15:17:44 -080075exec "$javaCmd" \
Raphael Mollcba8e112013-02-04 15:21:35 -080076 -Xmx512m $os_opts $java_debug \
77 -Dcom.android.tools.lint.bindir="$progdir" \
Siva Velusamy707bded2013-07-29 09:28:27 -070078 -Djava.awt.headless=true \
Raphael Moll08537a52013-01-04 15:17:44 -080079 -classpath "$jarpath" \
Tobias Thierer07a8c192017-11-30 23:30:21 +000080 ${modules_arg} \
Raphael Mollcba8e112013-02-04 15:21:35 -080081 com.android.tools.lint.Main "$@"