blob: 7f00eba067bf610a232668283b5f061c51ad4a4e [file] [log] [blame]
#!/bin/bash
#
# Copyright (C) 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# To use:
# intellij-gen.sh <module name>
#
# where module name is the LOCAL_PACKAGE_NAME in Android.mk for the project.
#
# For example, to generate a project for Contacts, use:
# intellij-gen.sh Contacts
#
# The project directory (.idea) will be put in the root directory of the module. Sharable iml
# files will be put into each respective module directory.
#
# Only tested on linux. Should work for macs but have not tried.
#
set -e
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
root_dir=`readlink -f -n $script_dir/../../..`
index_file=$script_dir/module-index.txt
idegenjar=$root_dir/out/host/common/obj/JAVA_LIBRARIES/idegen_intermediates/javalib.jar
progname=`basename $0`
if [ $# -ne 1 ]
then
echo "Usage: $progname <module_name>"
exit 1
fi
module_name=$1
if [ ! -e "$index_file" ]; then
echo "Module index file missing; generating this is only done the first time."
echo "If any dependencies change, you should generate a new index file by running index-gen.sh."
$script_dir/index-gen.sh
fi
echo "Checking for $idegenjar"
if [ -e "$idegenjar" ]; then
echo "Generating project files for $module_name"
cmd="java -cp $idegenjar com.android.idegen.IntellijProject $index_file $module_name"
echo $cmd
$cmd
else
echo "Couldn't find idegen.jar. Please run make first."
fi