diff --git a/tools/idegen/Android.mk b/tools/idegen/Android.mk index d424ab6be..8771160dd 100644 --- a/tools/idegen/Android.mk +++ b/tools/idegen/Android.mk @@ -2,8 +2,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_STATIC_JAVA_LIBRARIES := \ - guavalib \ +LOCAL_STATIC_JAVA_LIBRARIES := guavalib LOCAL_SRC_FILES := $(call all-subdir-java-files) diff --git a/tools/idegen/index-gen.sh b/tools/idegen/index-gen.sh index eadaa98e5..5b9e24bb1 100755 --- a/tools/idegen/index-gen.sh +++ b/tools/idegen/index-gen.sh @@ -14,12 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Generates a module index file by searching through android source tree for make files. The -# intellij-gen.sh script automatically calls this script the first time or if you delete the -# generated indexed file. The only time you need to run this manually is if modules are added or -# deleted. +# Generates a module index file by searching through android source +# tree for make files. The intellij-gen.sh script automatically calls +# this script the first time or if you delete the generated indexed +# file. The only time you need to run this manually is if modules are +# added or deleted. # -# To use: +# To use, run the following command from either your repo root or +# development/tools/idegen: # index-gen.sh # # Only tested on linux. Should work for macs but have not tried. @@ -27,7 +29,15 @@ set -e script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -root_dir=`readlink -f -n $script_dir/../../..` +#root_dir=`readlink -f -n $script_dir/../../..` +root_dir=$PWD +if [ ! -e $root_dir/.repo ]; then + root_dir=$PWD/../../.. + if [ ! -e $root_dir/.repo ]; then + echo "Repo root not found. Run this script from your repo root or the idegen directory." + exit 1 + fi +fi tmp_file=tmp.txt dest_file=module-index.txt diff --git a/tools/idegen/intellij-gen.sh b/tools/idegen/intellij-gen.sh index 7f00eba06..d67c1f867 100755 --- a/tools/idegen/intellij-gen.sh +++ b/tools/idegen/intellij-gen.sh @@ -14,7 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# To use: +# To use, run the following command from either your repo root or +# development/tools/idegen: # intellij-gen.sh # # where module name is the LOCAL_PACKAGE_NAME in Android.mk for the project. @@ -22,27 +23,38 @@ # 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. +# 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 " exit 1 fi - module_name=$1 +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +root_dir=$PWD +if [ ! -e $root_dir/.repo ]; then + root_dir=$PWD/../../.. + if [ ! -e $root_dir/.repo ]; then + echo "Repo root not found. Run this script from your repo root or the idegen directory." + exit 1 + fi +fi +index_file=$root_dir/module-index.txt +idegenjar=$script_dir/idegen.jar +if [ ! -e $idegenjar ]; then + # See if the jar is in the build directory. + idegenjar=$root_dir/out/host/linux-x86/framework/idegen.jar +fi + 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." diff --git a/tools/idegen/src/com/android/idegen/IntellijProject.java b/tools/idegen/src/com/android/idegen/IntellijProject.java index d5564d599..95bbe7676 100644 --- a/tools/idegen/src/com/android/idegen/IntellijProject.java +++ b/tools/idegen/src/com/android/idegen/IntellijProject.java @@ -55,6 +55,11 @@ public class IntellijProject { // First pass, find all dependencies and cache them. Module module = cache.getAndCache(moduleName); + if (module == null) { + logger.info("Module '" + moduleName + "' not found." + + " Module names are case senstive."); + return; + } projectIdeaDir = new File(module.getDir(), ".idea"); projectIdeaDir.mkdir(); copyTemplates();