8210226: Add support for multiple project folders to idea.sh
Overhaul templating logic for idea.sh; add support for -o option Reviewed-by: erikj, ihse
This commit is contained in:
parent
3a37a5d219
commit
4871d9935e
130
bin/idea.sh
130
bin/idea.sh
@ -49,7 +49,7 @@ do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
-o | --output )
|
-o | --output )
|
||||||
IDEA_OUTPUT=$2
|
IDEA_OUTPUT=$2/.idea
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -64,28 +64,25 @@ do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
mkdir $IDEA_OUTPUT || exit 1
|
mkdir -p $IDEA_OUTPUT || exit 1
|
||||||
cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd`
|
cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd`
|
||||||
|
|
||||||
|
if [ "x$TOPLEVEL_DIR" = "x" ] ; then
|
||||||
|
cd $SCRIPT_DIR/..
|
||||||
|
TOPLEVEL_DIR=`pwd`
|
||||||
|
cd $IDEA_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
MAKE_DIR="$SCRIPT_DIR/../make"
|
MAKE_DIR="$SCRIPT_DIR/../make"
|
||||||
IDEA_MAKE="$MAKE_DIR/idea"
|
IDEA_MAKE="$MAKE_DIR/idea"
|
||||||
IDEA_TEMPLATE="$IDEA_MAKE/template"
|
IDEA_TEMPLATE="$IDEA_MAKE/template"
|
||||||
|
|
||||||
cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT"
|
cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT"
|
||||||
|
|
||||||
#init template variables
|
#override template
|
||||||
for file in `ls -p $IDEA_TEMPLATE | grep -v /`; do
|
|
||||||
VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]`
|
|
||||||
eval "$VAR_SUFFIX"_TEMPLATE="$IDEA_TEMPLATE"/$file
|
|
||||||
eval IDEA_"$VAR_SUFFIX"="$IDEA_OUTPUT"/$file
|
|
||||||
done
|
|
||||||
|
|
||||||
#override template variables
|
|
||||||
if [ -d "$TEMPLATES_OVERRIDE" ] ; then
|
if [ -d "$TEMPLATES_OVERRIDE" ] ; then
|
||||||
for file in `ls -p "$TEMPLATES_OVERRIDE" | grep -v /`; do
|
for file in `ls -p "$TEMPLATES_OVERRIDE" | grep -v /`; do
|
||||||
cp "$TEMPLATES_OVERRIDE"/$file "$IDEA_OUTPUT"/
|
cp "$TEMPLATES_OVERRIDE"/$file "$IDEA_OUTPUT"/
|
||||||
VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]`
|
|
||||||
eval "$VAR_SUFFIX"_TEMPLATE="$TEMPLATES_OVERRIDE"/$file
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -94,14 +91,6 @@ if [ "$VERBOSE" = "true" ] ; then
|
|||||||
echo "idea template dir: $IDEA_TEMPLATE"
|
echo "idea template dir: $IDEA_TEMPLATE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$JDK_TEMPLATE" ] ; then
|
|
||||||
echo "FATAL: cannot find $JDK_TEMPLATE" >&2; exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "$ANT_TEMPLATE" ] ; then
|
|
||||||
echo "FATAL: cannot find $ANT_TEMPLATE" >&2; exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I $MAKE_DIR/.. idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1
|
cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I $MAKE_DIR/.. idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1
|
||||||
cd $SCRIPT_DIR
|
cd $SCRIPT_DIR
|
||||||
|
|
||||||
@ -124,8 +113,6 @@ if [ "x$SPEC" = "x" ] ; then
|
|||||||
echo "FATAL: SPEC is empty" >&2; exit 1
|
echo "FATAL: SPEC is empty" >&2; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SOURCE_FOLDER=" <sourceFolder url=\"file://\$MODULE_DIR\$/####\" isTestSource=\"false\" />"
|
|
||||||
SOURCE_FOLDERS_DONE="false"
|
|
||||||
|
|
||||||
addSourceFolder() {
|
addSourceFolder() {
|
||||||
root=$@
|
root=$@
|
||||||
@ -134,84 +121,45 @@ addSourceFolder() {
|
|||||||
printf "%s\n" "$folder" >> $IDEA_JDK
|
printf "%s\n" "$folder" >> $IDEA_JDK
|
||||||
}
|
}
|
||||||
|
|
||||||
### Generate project iml
|
### Replace template variables
|
||||||
|
|
||||||
rm -f $IDEA_JDK
|
NUM_REPLACEMENTS=0
|
||||||
while IFS= read -r line
|
|
||||||
do
|
replace_template_file() {
|
||||||
if echo "$line" | egrep "^ .* <sourceFolder.*####" > /dev/null ; then
|
for i in $(seq 1 $NUM_REPLACEMENTS); do
|
||||||
if [ "$SOURCE_FOLDERS_DONE" = "false" ] ; then
|
eval "sed -i \"s|\${FROM${i}}|\${TO${i}}|g\" $1"
|
||||||
SOURCE_FOLDERS_DONE="true"
|
|
||||||
for root in $MODULE_ROOTS; do
|
|
||||||
addSourceFolder $root
|
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
else
|
|
||||||
printf "%s\n" "$line" >> $IDEA_JDK
|
|
||||||
fi
|
|
||||||
done < "$JDK_TEMPLATE"
|
|
||||||
|
|
||||||
|
|
||||||
MODULE_NAME=" <property name=\"module.name\" value=\"####\" />"
|
|
||||||
|
|
||||||
addModuleName() {
|
|
||||||
mn="`echo "$MODULE_NAME" | sed -e s@"\(.*\)####\(.*\)"@"\1$MODULE_NAMES\2"@`"
|
|
||||||
printf "%s\n" "$mn" >> $IDEA_ANT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BUILD_DIR=" <property name=\"build.target.dir\" value=\"####\" />"
|
replace_template_dir() {
|
||||||
|
for f in `find $1 -type f` ; do
|
||||||
addBuildDir() {
|
replace_template_file $f
|
||||||
DIR=`dirname $SPEC`
|
done
|
||||||
mn="`echo "$BUILD_DIR" | sed -e s@"\(.*\)####\(.*\)"@"\1$DIR\2"@`"
|
|
||||||
printf "%s\n" "$mn" >> $IDEA_ANT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
### Generate ant.xml
|
add_replacement() {
|
||||||
|
NUM_REPLACEMENTS=`expr $NUM_REPLACEMENTS + 1`
|
||||||
rm -f $IDEA_ANT
|
eval FROM$NUM_REPLACEMENTS='$1'
|
||||||
while IFS= read -r line
|
eval TO$NUM_REPLACEMENTS='$2'
|
||||||
do
|
|
||||||
if echo "$line" | egrep "^ .* <property name=\"module.name\"" > /dev/null ; then
|
|
||||||
addModuleName
|
|
||||||
elif echo "$line" | egrep "^ .* <property name=\"build.target.dir\"" > /dev/null ; then
|
|
||||||
addBuildDir
|
|
||||||
else
|
|
||||||
printf "%s\n" "$line" >> $IDEA_ANT
|
|
||||||
fi
|
|
||||||
done < "$ANT_TEMPLATE"
|
|
||||||
|
|
||||||
### Generate misc.xml
|
|
||||||
|
|
||||||
rm -f $IDEA_MISC
|
|
||||||
|
|
||||||
JTREG_HOME=" <path>####</path>"
|
|
||||||
|
|
||||||
IMAGES_DIR=" <jre alt=\"true\" value=\"####\" />"
|
|
||||||
|
|
||||||
addImagesDir() {
|
|
||||||
DIR=`dirname $SPEC`/images/jdk
|
|
||||||
mn="`echo "$IMAGES_DIR" | sed -e s@"\(.*\)####\(.*\)"@"\1$DIR\2"@`"
|
|
||||||
printf "%s\n" "$mn" >> $IDEA_MISC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addJtregHome() {
|
add_replacement "###BUILD_DIR###" "`dirname $SPEC`"
|
||||||
DIR=`dirname $SPEC`
|
add_replacement "###MODULE_NAMES###" "$MODULE_NAMES"
|
||||||
mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`"
|
add_replacement "###JTREG_HOME###" "$JT_HOME"
|
||||||
printf "%s\n" "$mn" >> $IDEA_MISC
|
add_replacement "###IMAGES_DIR###" "`dirname $SPEC`/images/jdk"
|
||||||
}
|
add_replacement "###ROOT_DIR###" "$TOPLEVEL_DIR"
|
||||||
|
add_replacement "###IDEA_DIR###" "$IDEA_OUTPUT"
|
||||||
|
|
||||||
rm -f $MISC_ANT
|
SOURCE_PREFIX="<sourceFolder url=\"file://"
|
||||||
while IFS= read -r line
|
SOURCE_POSTFIX="\" isTestSource=\"false\" />"
|
||||||
do
|
|
||||||
if echo "$line" | egrep "^ .*<path>jtreg_home</path>" > /dev/null ; then
|
for root in $MODULE_ROOTS; do
|
||||||
addJtregHome
|
SOURCES=$SOURCES"\n$SOURCE_PREFIX""$root""$SOURCE_POSTFIX"
|
||||||
elif echo "$line" | egrep "^ .*<jre alt=\"true\" value=\"images_jdk\"" > /dev/null ; then
|
done
|
||||||
addImagesDir
|
|
||||||
else
|
add_replacement "###SOURCE_ROOTS###" "$SOURCES"
|
||||||
printf "%s\n" "$line" >> $IDEA_MISC
|
|
||||||
fi
|
replace_template_dir "$IDEA_OUTPUT"
|
||||||
done < "$MISC_TEMPLATE"
|
|
||||||
|
|
||||||
### Compile the custom Logger
|
### Compile the custom Logger
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="AntConfiguration">
|
<component name="AntConfiguration">
|
||||||
<buildFile url="file://$PROJECT_DIR$/make/idea/build.xml">
|
<buildFile url="file://###ROOT_DIR###/make/idea/build.xml">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="intellij.ismake" value="$IsMake$" />
|
<property name="intellij.ismake" value="$IsMake$" />
|
||||||
<property name="build.target.dir" value="specDir" /> <!-- this will be replaced -->
|
<property name="build.target.dir" value="###BUILD_DIR###" />
|
||||||
<property name="module.name" value="java.base" /> <!-- this will be replaced -->
|
<property name="module.name" value="###MODULE_NAMES###" />
|
||||||
<property name="idea.dir" value="$ModuleFileDir$" />
|
<property name="idea.dir" value="###IDEA_DIR###" />
|
||||||
</properties>
|
</properties>
|
||||||
<executeOn event="afterCompilation" target="post-make" />
|
<executeOn event="afterCompilation" target="post-make" />
|
||||||
</buildFile>
|
</buildFile>
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||||
<excludeFromCompile>
|
<excludeFromCompile>
|
||||||
<directory url="file://$PROJECT_DIR$/src" includeSubdirectories="true" />
|
<directory url="file://###ROOT_DIR###/src" includeSubdirectories="true" />
|
||||||
<directory url="file://$PROJECT_DIR$/build" includeSubdirectories="true" />
|
<directory url="file://###ROOT_DIR###/build" includeSubdirectories="true" />
|
||||||
<directory url="file://$PROJECT_DIR$/make" includeSubdirectories="true" />
|
<directory url="file://###ROOT_DIR###/make" includeSubdirectories="true" />
|
||||||
<directory url="file://$PROJECT_DIR$/test" includeSubdirectories="true" />
|
<directory url="file://###ROOT_DIR###/test" includeSubdirectories="true" />
|
||||||
</excludeFromCompile>
|
</excludeFromCompile>
|
||||||
<resourceExtensions />
|
<resourceExtensions />
|
||||||
<wildcardResourcePatterns>
|
<wildcardResourcePatterns>
|
||||||
@ -26,3 +26,4 @@
|
|||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
<module type="JAVA_MODULE" version="4">
|
<module type="JAVA_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://###ROOT_DIR###">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/####" isTestSource="false" />
|
###SOURCE_ROOTS###
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://###ROOT_DIR###/build" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/make" />
|
<excludeFolder url="file://###ROOT_DIR###/make" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
<entry_points version="2.0" />
|
<entry_points version="2.0" />
|
||||||
</component>
|
</component>
|
||||||
<component name="JTRegService">
|
<component name="JTRegService">
|
||||||
<path>jtreg_home</path> <!-- this will be replaced -->
|
<path>###JTREG_HOME###</path>
|
||||||
<workDir>build</workDir>
|
<workDir>###BUILD_DIR###</workDir>
|
||||||
<jre alt="true" value="images_jdk" /> <!-- this will be replaced -->
|
<jre alt="true" value="###IMAGES_DIR###" />
|
||||||
<options></options>
|
<options></options>
|
||||||
<ant>
|
<ant>
|
||||||
<target file="file://$PROJECT_DIR$/make/idea/build.xml" name="images" />
|
<target file="file://###ROOT_DIR###/make/idea/build.xml" name="images" />
|
||||||
</ant>
|
</ant>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" assert-keyword="true" jdk-15="true">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" assert-keyword="true" jdk-15="true">
|
||||||
<output url="file://$PROJECT_DIR$/build/out" />
|
<output url="file://###BUILD_DIR###" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="hg4idea" />
|
<mapping directory="###ROOT_DIR###" vcs="hg4idea" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<ignored path="jdk.iws" />
|
<ignored path="jdk.iws" />
|
||||||
<ignored path="$PROJECT_DIR$/build/idea/out/" />
|
<ignored path="###ROOT_DIR###/build/idea/out/" />
|
||||||
<ignored path=".idea/" />
|
<ignored path=".idea/" />
|
||||||
</component>
|
</component>
|
||||||
<component name="StructureViewFactory">
|
<component name="StructureViewFactory">
|
||||||
@ -11,7 +11,7 @@
|
|||||||
<component name="antWorkspaceConfiguration">
|
<component name="antWorkspaceConfiguration">
|
||||||
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
|
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
|
||||||
<option name="FILTER_TARGETS" value="false" />
|
<option name="FILTER_TARGETS" value="false" />
|
||||||
<buildFile url="file://$PROJECT_DIR$/make/idea/build.xml">
|
<buildFile url="file://###ROOT_DIR###/make/idea/build.xml">
|
||||||
<runInBackground value="false" />
|
<runInBackground value="false" />
|
||||||
<targetFilters>
|
<targetFilters>
|
||||||
<filter targetName="clean" isVisible="true" />
|
<filter targetName="clean" isVisible="true" />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<!-- importing.xml -->
|
<!-- importing.xml -->
|
||||||
<project name="langtools" basedir = "../../..">
|
<project name="langtools" basedir = "../../..">
|
||||||
|
|
||||||
<script language="javascript" classpath="${idea.dir}/classes">
|
<script language="javascript" classpath=".idea/classes">
|
||||||
var LangtoolsLogger = Java.type("idea.LangtoolsIdeaAntLogger");
|
var LangtoolsLogger = Java.type("idea.LangtoolsIdeaAntLogger");
|
||||||
new LangtoolsLogger(project)
|
new LangtoolsLogger(project)
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="langtools.jdk.home" value="@IDEA_TARGET_JDK@" />
|
<property name="langtools.jdk.home" value="@IDEA_TARGET_JDK@" />
|
||||||
<property name="intellij.ismake" value="$IsMake$" />
|
<property name="intellij.ismake" value="$IsMake$" />
|
||||||
<property name="idea.dir" value="$ModuleFileDir$" />
|
|
||||||
</properties>
|
</properties>
|
||||||
<executeOn event="afterCompilation" target="post-make" />
|
<executeOn event="afterCompilation" target="post-make" />
|
||||||
</buildFile>
|
</buildFile>
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
</ant>
|
</ant>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/.idea-support/out" />
|
<output url="file://$PROJECT_DIR$/build" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
Loading…
Reference in New Issue
Block a user