• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2012 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# To use, run the following command from either your repo root or
18# development/tools/idegen:
19#   intellij-gen.sh <module name>
20#
21# where module name is the LOCAL_PACKAGE_NAME in Android.mk for the project.
22#
23# For example, to generate a project for Contacts, use:
24#   intellij-gen.sh Contacts
25#
26# The project directory (.idea) will be put in the root directory of
27# the module.  Sharable iml files will be put into each respective
28# module directory.
29#
30# Only tested on linux.  Should work for macs but have not tried.
31#
32set -e
33
34progname=`basename $0`
35if [ $# -ne 1 ]
36then
37    echo "Usage: $progname <module_name>"
38    exit 1
39fi
40module_name=$1
41
42script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
43root_dir=$PWD
44if [ ! -e $root_dir/.repo ]; then
45  root_dir=$PWD/../../..
46  if [ ! -e $root_dir/.repo ]; then
47    echo "Repo root not found. Run this script from your repo root or the idegen directory."
48    exit 1
49  fi
50fi
51index_file=$root_dir/module-index.txt
52idegenjar=$script_dir/idegen.jar
53if [ ! -e $idegenjar ]; then
54  # See if the jar is in the build directory.
55  idegenjar=$root_dir/out/host/linux-x86/framework/idegen.jar
56fi
57
58if [ ! -e "$index_file" ]; then
59  echo "Module index file missing; generating this is only done the first time."
60  echo "If any dependencies change, you should generate a new index file by running index-gen.sh."
61  $script_dir/index-gen.sh
62fi
63
64echo "Checking for $idegenjar"
65if [ -e "$idegenjar" ]; then
66  echo "Generating project files for $module_name"
67  cmd="java -cp $idegenjar com.android.idegen.IntellijProject $index_file $module_name"
68  echo $cmd
69  $cmd
70else
71  echo "Couldn't find idegen.jar. Please run make first."
72fi
73