diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2016-04-20 15:58:08 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2016-04-20 15:58:08 +0200 |
commit | 23159d2842fcc64f5d3fc962b292030627b3a1a1 (patch) | |
tree | 6fa57b3d511b5b1e6b4847e72330ab80309de1bc /src/eclipse/update-workspace.sh | |
parent | 1fcfdd8c8bca1adba6eff2381ac6e765141801f0 (diff) | |
download | scala-23159d2842fcc64f5d3fc962b292030627b3a1a1.tar.gz scala-23159d2842fcc64f5d3fc962b292030627b3a1a1.tar.bz2 scala-23159d2842fcc64f5d3fc962b292030627b3a1a1.zip |
Automate Eclipse settings and update project files: (#5091)
- remove `M2_REPO`. All dependencies are picked up from `build/deps`
- add script to update an existing workspace directory with the required path variables
- add the default Scala library to several projects for better out-of-the-box experience. This means
that changes in the scale-library project may not be visible in the other projects, but makes it
way easier to get a working config. If you really need that, you probably know what you’re doing
anyway.
Diffstat (limited to 'src/eclipse/update-workspace.sh')
-rwxr-xr-x | src/eclipse/update-workspace.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/eclipse/update-workspace.sh b/src/eclipse/update-workspace.sh new file mode 100755 index 0000000000..24382d1445 --- /dev/null +++ b/src/eclipse/update-workspace.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +function usage() { + echo "$0 scala_checkout_dir [workspace_dir]" + echo "\n Add necessary path variables to Eclipse workspace settings for Scalac to build" +} + +METADATA_DIR=`pwd`/.metadata + +if [ $# -lt 1 ]; then + echo "Need the Scala directory checkout as argument" + exit 1 +fi + +SCALA_DIR=$1 + +if [ ! -z $2 ]; then + METADATA_DIR=$2/.metadata +fi + +if [ ! -d $METADATA_DIR ]; then + echo "$METADATA_DIR is not a directory" + exit 1 +fi + +echo "Using metadata directory $METADATA_DIR and Scala checkout $SCALA_DIR" + +CORE_PREFS=$METADATA_DIR/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +if [ ! -f $CORE_PREFS ]; then + echo "Couldn't find $CORE_PREFS. Is $METADATA_DIR an Eclipse workspace?" + exit 1 +fi +echo -e "Workspace preferences:\t$CORE_PREFS" + +JDT_PREFS=$METADATA_DIR/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs +if [ ! -f $JDT_PREFS ]; then + echo "Couldn't find $JDT_PREFS. Creating fresh file." + touch $JDT_PREFS +fi +echo -e "JDT preferences:\t$JDT_PREFS" + +# $1 - preference file (will be backed-up before writing) +# $2 - preference key +# $3 - preference value +function updatePref() { + mv $1 ${1}_backup + + awk -v key=$2 -v value=$3 ' + BEGIN { + FS="="; + OFS="="; + prev="" + } + { + if ($1 == key) { + prev=$2 + $2=value + } + print + } + END { + if (prev) { + printf "Updated existing value from %s to %s\n", prev, value > "/dev/stderr" + } else { + print key,value + } + } + ' ${1}_backup >$1 +} + +updatePref $CORE_PREFS "pathvariable.SCALA_BASEDIR" $SCALA_DIR +updatePref $JDT_PREFS "org.eclipse.jdt.core.classpathVariable.SCALA_BASEDIR" $SCALA_DIR |