8196081: Add support for customized intellij project templates
Override template used for project creation using env variable Reviewed-by: ihse
This commit is contained in:
parent
78de84bc1e
commit
dd61a0c90d
48
bin/idea.sh
48
bin/idea.sh
@ -30,9 +30,10 @@ usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_DIR=`dirname $0`
|
SCRIPT_DIR=`dirname $0`
|
||||||
PWD=`pwd`
|
#assume TOP is the dir from which the script has been called
|
||||||
|
TOP=`pwd`
|
||||||
cd $SCRIPT_DIR; SCRIPT_DIR=`pwd`
|
cd $SCRIPT_DIR; SCRIPT_DIR=`pwd`
|
||||||
cd ../; TOP=`pwd`; cd $PWD
|
cd $TOP;
|
||||||
|
|
||||||
IDEA_OUTPUT=$TOP/.idea
|
IDEA_OUTPUT=$TOP/.idea
|
||||||
VERBOSE="false"
|
VERBOSE="false"
|
||||||
@ -66,30 +67,42 @@ done
|
|||||||
mkdir $IDEA_OUTPUT || exit 1
|
mkdir $IDEA_OUTPUT || exit 1
|
||||||
cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd`
|
cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd`
|
||||||
|
|
||||||
IDEA_MAKE="$TOP/make/idea"
|
MAKE_DIR="$SCRIPT_DIR/../make"
|
||||||
|
IDEA_MAKE="$MAKE_DIR/idea"
|
||||||
IDEA_TEMPLATE="$IDEA_MAKE/template"
|
IDEA_TEMPLATE="$IDEA_MAKE/template"
|
||||||
IML_TEMPLATE="$IDEA_TEMPLATE/jdk.iml"
|
|
||||||
ANT_TEMPLATE="$IDEA_TEMPLATE/ant.xml"
|
cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT"
|
||||||
MISC_TEMPLATE="$IDEA_TEMPLATE/misc.xml"
|
|
||||||
IDEA_IML="$IDEA_OUTPUT/jdk.iml"
|
#init template variables
|
||||||
IDEA_ANT="$IDEA_OUTPUT/ant.xml"
|
for file in `ls -p $IDEA_TEMPLATE | grep -v /`; do
|
||||||
IDEA_MISC="$IDEA_OUTPUT/misc.xml"
|
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
|
||||||
|
for file in `ls -p "$TEMPLATES_OVERRIDE" | grep -v /`; do
|
||||||
|
cp "$TEMPLATES_OVERRIDE"/$file "$IDEA_OUTPUT"/
|
||||||
|
VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]`
|
||||||
|
eval "$VAR_SUFFIX"_TEMPLATE="$TEMPLATES_OVERRIDE"/$file
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$VERBOSE" = "true" ] ; then
|
if [ "$VERBOSE" = "true" ] ; then
|
||||||
echo "output dir: $IDEA_OUTPUT"
|
echo "output dir: $IDEA_OUTPUT"
|
||||||
echo "idea template dir: $IDEA_TEMPLATE"
|
echo "idea template dir: $IDEA_TEMPLATE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$IML_TEMPLATE" ] ; then
|
if [ ! -f "$JDK_TEMPLATE" ] ; then
|
||||||
echo "FATAL: cannot find $IML_TEMPLATE" >&2; exit 1
|
echo "FATAL: cannot find $JDK_TEMPLATE" >&2; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$ANT_TEMPLATE" ] ; then
|
if [ ! -f "$ANT_TEMPLATE" ] ; then
|
||||||
echo "FATAL: cannot find $ANT_TEMPLATE" >&2; exit 1
|
echo "FATAL: cannot find $ANT_TEMPLATE" >&2; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT"
|
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/common idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1
|
|
||||||
cd $SCRIPT_DIR
|
cd $SCRIPT_DIR
|
||||||
|
|
||||||
. $IDEA_OUTPUT/env.cfg
|
. $IDEA_OUTPUT/env.cfg
|
||||||
@ -118,11 +131,12 @@ addSourceFolder() {
|
|||||||
root=$@
|
root=$@
|
||||||
relativePath="`echo "$root" | sed -e s@"$TOP/\(.*$\)"@"\1"@`"
|
relativePath="`echo "$root" | sed -e s@"$TOP/\(.*$\)"@"\1"@`"
|
||||||
folder="`echo "$SOURCE_FOLDER" | sed -e s@"\(.*/\)####\(.*\)"@"\1$relativePath\2"@`"
|
folder="`echo "$SOURCE_FOLDER" | sed -e s@"\(.*/\)####\(.*\)"@"\1$relativePath\2"@`"
|
||||||
printf "%s\n" "$folder" >> $IDEA_IML
|
printf "%s\n" "$folder" >> $IDEA_JDK
|
||||||
}
|
}
|
||||||
|
|
||||||
### Generate project iml
|
### Generate project iml
|
||||||
rm -f $IDEA_IML
|
|
||||||
|
rm -f $IDEA_JDK
|
||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do
|
do
|
||||||
if echo "$line" | egrep "^ .* <sourceFolder.*####" > /dev/null ; then
|
if echo "$line" | egrep "^ .* <sourceFolder.*####" > /dev/null ; then
|
||||||
@ -133,9 +147,9 @@ do
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf "%s\n" "$line" >> $IDEA_IML
|
printf "%s\n" "$line" >> $IDEA_JDK
|
||||||
fi
|
fi
|
||||||
done < "$IML_TEMPLATE"
|
done < "$JDK_TEMPLATE"
|
||||||
|
|
||||||
|
|
||||||
MODULE_NAME=" <property name=\"module.name\" value=\"####\" />"
|
MODULE_NAME=" <property name=\"module.name\" value=\"####\" />"
|
||||||
|
@ -20,16 +20,9 @@ else #with SPEC
|
|||||||
SEL_MODULES := $(MODULES)
|
SEL_MODULES := $(MODULES)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Find all source dirs for a particular module
|
|
||||||
# $1 - Module to find source dirs for
|
|
||||||
FindIdeaModuleSrcDirs = \
|
|
||||||
$(strip $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
|
|
||||||
$(wildcard $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
|
|
||||||
|
|
||||||
|
|
||||||
idea:
|
idea:
|
||||||
$(ECHO) "SUPPORT=$(SUPPORT_OUTPUTDIR)" >> $(OUT)
|
$(ECHO) "SUPPORT=$(SUPPORT_OUTPUTDIR)" >> $(OUT)
|
||||||
$(ECHO) "MODULE_ROOTS=\"$(foreach mod, $(SEL_MODULES), $(call FindIdeaModuleSrcDirs,$(mod)))\"" >> $(OUT)
|
$(ECHO) "MODULE_ROOTS=\"$(foreach mod, $(SEL_MODULES), $(call FindModuleSrcDirs,$(mod)))\"" >> $(OUT)
|
||||||
$(ECHO) "MODULE_NAMES=\"$(strip $(foreach mod, $(SEL_MODULES), $(mod)))\"" >> $(OUT)
|
$(ECHO) "MODULE_NAMES=\"$(strip $(foreach mod, $(SEL_MODULES), $(mod)))\"" >> $(OUT)
|
||||||
$(ECHO) "SEL_MODULES=\"$(SEL_MODULES)\"" >> $(OUT)
|
$(ECHO) "SEL_MODULES=\"$(SEL_MODULES)\"" >> $(OUT)
|
||||||
$(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT)
|
$(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
<component name="AntConfiguration">
|
<component name="AntConfiguration">
|
||||||
<buildFile url="file://$PROJECT_DIR$/.idea/build.xml">
|
<buildFile url="file://$PROJECT_DIR$/.idea/build.xml">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="boot.java.home" value="$JDKPath$" />
|
|
||||||
<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="specDir" /> <!-- this will be replaced -->
|
||||||
<property name="module.name" value="java.base" /> <!-- this will be replaced -->
|
<property name="module.name" value="java.base" /> <!-- this will be replaced -->
|
||||||
|
@ -6,32 +6,16 @@
|
|||||||
new JdkLogger(project)
|
new JdkLogger(project)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- java.marker is set to a marker file to check for within a Java install dir.
|
|
||||||
The best file to check for across Solaris/Linux/Windows/MacOS is one of the
|
|
||||||
executables; regrettably, that is OS-specific. -->
|
|
||||||
<condition property="java.marker" value="bin/java">
|
|
||||||
<os family="unix"/>
|
|
||||||
</condition>
|
|
||||||
<condition property="java.marker" value="bin/java.exe">
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<target name="-check-jtreg.home" depends="-def-check">
|
|
||||||
<check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<property name="test.dir" value="${basedir}/jdk/test"/>
|
|
||||||
|
|
||||||
<macrodef name="call-make">
|
<macrodef name="call-make">
|
||||||
<attribute name="dir"/>
|
<attribute name="dir"/>
|
||||||
<attribute name="args"/>
|
<attribute name="args"/>
|
||||||
<sequential>
|
<sequential>
|
||||||
<exec executable="make" dir="@{dir}" failonerror="true">
|
<exec executable="make" dir="@{dir}" failonerror="true">
|
||||||
<arg line="@{args}"/>
|
<arg line="@{args}"/>
|
||||||
<env key="CLASSPATH" value = ""/>
|
<env key="CLASSPATH" value = ""/>
|
||||||
</exec>
|
</exec>
|
||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</macrodef>
|
||||||
|
|
||||||
<target name="cond-clean" unless="${intellij.ismake}">
|
<target name="cond-clean" unless="${intellij.ismake}">
|
||||||
<antcall target="clean"/>
|
<antcall target="clean"/>
|
||||||
@ -43,71 +27,17 @@
|
|||||||
**** Global JDK Build Targets
|
**** Global JDK Build Targets
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<target name="clean" depends="-do-configure">
|
<target name="clean">
|
||||||
<echo message="base = ${basedir}"/>
|
<echo message="base = ${basedir}"/>
|
||||||
|
<call-make dir = "${build.target.dir}" args = "reconfigure"/>
|
||||||
<call-make dir = "${build.target.dir}" args = "clean"/>
|
<call-make dir = "${build.target.dir}" args = "clean"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="-do-configure">
|
|
||||||
<echo message="base = ${basedir}"/>
|
|
||||||
<fail message="Not part of a full JDK forest">
|
|
||||||
<condition>
|
|
||||||
<not>
|
|
||||||
<available file="${basedir}/configure" />
|
|
||||||
</not>
|
|
||||||
</condition>
|
|
||||||
</fail>
|
|
||||||
<exec executable="sh" dir="${basedir}" failonerror="true">
|
|
||||||
<arg line="configure --with-boot-jdk=${boot.java.home}"/>
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="images">
|
<target name="images">
|
||||||
<call-make dir = "${build.target.dir}" args = "images"/>
|
<call-make dir = "${build.target.dir}" args = "images"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="jimages">
|
|
||||||
<call-make dir = "${build.target.dir}" args = "jimages"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="check-env">
|
|
||||||
<exec executable="env" dir="${basedir}"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="build-module">
|
<target name="build-module">
|
||||||
<call-make dir = "${build.target.dir}" args = "${module.name}"/>
|
<call-make dir = "${build.target.dir}" args = "${module.name}"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="-check-boot.java.home" depends="-def-check">
|
|
||||||
<check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="-def-check">
|
|
||||||
<macrodef name="check">
|
|
||||||
<attribute name="name"/>
|
|
||||||
<attribute name="property"/>
|
|
||||||
<attribute name="marker" default=""/>
|
|
||||||
<sequential>
|
|
||||||
<fail message="Cannot locate @{name}: please set @{property} to its location">
|
|
||||||
<condition>
|
|
||||||
<not>
|
|
||||||
<isset property="@{property}"/>
|
|
||||||
</not>
|
|
||||||
</condition>
|
|
||||||
</fail>
|
|
||||||
<fail message="@{name} is not installed in ${@{property}}">
|
|
||||||
<condition>
|
|
||||||
<and>
|
|
||||||
<not>
|
|
||||||
<equals arg1="@{marker}" arg2=""/>
|
|
||||||
</not>
|
|
||||||
<not>
|
|
||||||
<available file="${@{property}}/@{marker}"/>
|
|
||||||
</not>
|
|
||||||
</and>
|
|
||||||
</condition>
|
|
||||||
</fail>
|
|
||||||
</sequential>
|
|
||||||
</macrodef>
|
|
||||||
</target>
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/####" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/####" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/src" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/make" />
|
<excludeFolder url="file://$MODULE_DIR$/make" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
</component>
|
</component>
|
||||||
|
Loading…
Reference in New Issue
Block a user