Skip to content

Commit

Permalink
#45: intellij setup works on macos (#72)
Browse files Browse the repository at this point in the history
* #55: fix for git
* #73: rename function load_properties to doLoadProperties in functions, fixed bat call to label
* #73: #63: avoid quotes that cause issues on windows
* #45: fixed template for idea.properties
  • Loading branch information
hohwille authored Apr 2, 2019
1 parent 0fbd328 commit 3e9e0a5
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 126 deletions.
12 changes: 7 additions & 5 deletions scripts/src/main/resources/scripts/command/eclipse
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ function doSetup() {
local mirror="https://ftp.osuosl.org"
local software_version=`doGetVariable ECLIPSE_VERSION 2018-12`
local eclipse_edition=java
local extract_folder=
#eclipse_edition=jee
local download_url="${mirror}/pub/eclipse/technology/epp/downloads/release/${software_version}/R/eclipse-${eclipse_edition}-${software_version}-R"
local archive_folder=
if doIsMacOs
then
download_url="${download_url}-macosx-cocoa-x86_64.dmg"
archive_folder='volume'
extract_folder="eclipse"
elif doIsWindows
then
download_url="${download_url}-win32-x86_64.zip"
else
download_url="${download_url}-linux-gtk-x86_64.tar.gz"
fi
doInstall "${ECLIPSE_HOME}" "${download_url}" "${archive_folder}"
doInstall "${ECLIPSE_HOME}" "${download_url}" "" "${extract_folder}"
if doIsMacOs
then
echo "Doing workarounds for MacOS quirks..."
Expand Down Expand Up @@ -95,11 +95,13 @@ function doConfigureEclipse() {
fi
if [ ! -d "${WORKSPACE_PATH}/.metadata" ]
then
if [ "${mode}" = "-i" ] || [ "${mode}" = "-x" ]
if [ -z "${mode}" ]
then
mode="-u"
elif [ "${mode}" != "-u" ]
then
doFail "Workspace ${WORKSPACE} is not initialized.\nReverse merge is not possible."
fi
mode="-u"
fi
if [ -n "${mode}" ]
then
Expand Down
190 changes: 89 additions & 101 deletions scripts/src/main/resources/scripts/command/intellij
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,74 @@ cd `dirname $0`
cd ../..
source scripts/functions

function doSetup() {
if [ -d "${IDEA_HOME}" ]
then
if [ -n "${1}" ]
then
echo "IntelliJ is already installed at ${IDEA_HOME}"
fi
else
#mirror="https://mirror.math.princeton.edu"
mirror="https://ftp.osuosl.org"
software_version=`doGetVariable INTELLIJ_VERSION 2018.3.5`
eclipse_edition=java
#eclipse_edition=jee
if doIsMacOs
then
software_type="dmg"
elif doIsWindows
then
software_type="win.zip"
else
software_type="tar.gz"
fi
download_url="https://download-cf.jetbrains.com/idea/ideaIC-${software_version}.${software_type}"
doInstall "${IDEA_HOME}" "${download_url}" "" "intellij"
if doIsMacOs
then
echo "Doing workarounds for MacOS quirks..."
mv "${DEVON_IDE_HOME}/software/intellij/IntelliJ IDEA CE.app" "${DEVON_IDE_HOME}/software/intellij/IntelliJ.app"
echo -e "#!/bin/bash\n'${DEVON_IDE_HOME}/software/intellij/IntelliJ.app/Contents/MacOS/idea' \$@" > "${IDEA_HOME}/idea"
chmod a+x "${IDEA_HOME}/idea"
fi
fi
if [ -n "${1}" ]
then
doRunCommand "which idea" "verify installation of IntelliJ"
if [ -e "${IDEA_HOME}/product-info.json" ]
then
doRunCommand "cat '${IDEA_HOME}/product-info.json'"
else
doRunCommand "cat '${IDEA_HOME}/IntelliJ.app/Contents/Resources/product-info.json'"
fi
fi
}

function doConfigureIntellij() {
local mode="${1}"
if [ ! -d "${WORKSPACE_PATH}/.idea" ]
then
if [ -z "${mode}" ]
then
mode="-u"
elif [ "${mode}" != "-u" ]
then
doFail "Workspace ${WORKSPACE} is not initialized.\nReverse merge is not possible."
fi
fi
if [ -n "${mode}" ]
then
doConfigureWorkspace "${SETTINGS_PATH}/intellij/workspace" "${WORKSPACE_PATH}" ${mode}
fi
}

function doStartIntellij() {
doConfigureIntellij
echo "launching IntelliJ..."
"${IDEA_HOME}/idea" &
}

# CLI
if [ "${1}" = "-h" ] || [ "${1}" = "help" ]
then
Expand All @@ -17,115 +85,35 @@ then
echo " create-script create intellij-${WORKSPACE} script if not already exists"
exit
fi
run=
IDEA_HOME="${DEVON_IDE_HOME}/software/intellij"
if [ -z "${1}" ]
then
doSetup
doStartIntellij
fi
while [ -n "${1}" ]
do
run=
if [ "${1}" = "run" ] || [ "${1}" = "start" ]
then
run=true
else
if [ "${run}" != "true" ]
then
run=false
fi

if [ "${1}" = "ws-up" ] || [ "${1}" = "ws-update" ]
then
CONFIGURATOR_MODE="-u"
CONFIGURATOR_ACTION="updated"
elif [ "${1}" = "ws-re" ] || [ "${1}" = "ws-reverse" ]
then
CONFIGURATOR_MODE="-i"
CONFIGURATOR_ACTION="merged back to settings"
elif [ "${1}" = "ws-reverse-add" ]
then
CONFIGURATOR_MODE="-x"
CONFIGURATOR_ACTION="merged back to settings (including new properties)"
elif [ "${1}" = "setup" ]
then
setup=true
elif [ "${1}" = "create-script" ]
then
CREATE_SCRIPT=true
else
doFail "Unknown argument: ${1}"
fi
fi
shift
done

IDEA_HOME="${DEVON_IDE_HOME}/software/intellij"
if [ -d "${IDEA_HOME}" ]
then
if [ "${setup}" = "true" ]
doStartIntellij
elif [ "${1}" = "ws-up" ] || [ "${1}" = "ws-update" ]
then
echo "IntelliJ is already installed at ${IDEA_HOME}"
fi
else
#mirror="https://mirror.math.princeton.edu"
mirror="https://ftp.osuosl.org"
software_version=`doGetVariable INTELLIJ_VERSION 2018.3.5`
eclipse_edition=java
#eclipse_edition=jee
archive_folder=
if doIsMacOs
doConfigureEclipse -u
elif [ "${1}" = "ws-re" ] || [ "${1}" = "ws-reverse" ]
then
software_type="dmg"
archive_folder='volume'
elif doIsWindows
doConfigureEclipse -i
elif [ "${1}" = "ws-reverse-add" ]
then
software_type="win.zip"
else
software_type="tar.gz"
fi
download_url="https://download-cf.jetbrains.com/idea/ideaIC-${software_version}.${software_type}"
doInstall "${IDEA_HOME}" "${download_url}" "${archive_folder}"
if doIsMacOs
doConfigureEclipse -x
elif [ "${1}" = "setup" ]
then
echo "Doing workarounds for MacOS quirks..."
echo -e "#!/bin/bash\n'${DEVON_IDE_HOME}/software/intellij/IntelliJ IDEA CE.app/Contents/MacOS/idea' \$@" > "${IDEA_HOME}/idea"
chmod a+x "${IDEA_HOME}/intellij"
fi
fi
if [ "${setup}" = "true" ]
then
doRunCommand "which intellij" "verify installation of IntelliJ"
if [ -e "${IDEA_HOME}/product-info.json" ]
doSetup setup
doCreateIdeScript intellij
elif [ "${1}" = "create-script" ]
then
doRunCommand "cat '${IDEA_HOME}/product-info.json'"
doCreateIdeScript intellij
else
doRunCommand "cat '${IDEA_HOME}/IntelliJ\ IDEA\ CE.app/Contents/Resources/product-info.json'"
fi
fi

IDEA_CONF="${WORKSPACE_PATH}/.idea"
IDEA_PROPERTIES="${IDEA_CONF}/idea.properties"
if [ ! -d "${WORKSPACE_PATH}/.idea" ]
then
mkdir -p "${DEVON_IDE_HOME}/conf/.idea/plugins"
if [ "${CONFIGURATOR_MODE}" = "-i" ] || [ "${CONFIGURATOR_MODE}" = "-x" ]
then
doFail "Workspace ${WORKSPACE} is not initialized.\nReverse merge is not possible."
doFail "Unknown argument: ${1}"
fi
CONFIGURATOR_MODE="-u"
CONFIGURATOR_ACTION="created"
fi

if [ -n "${CONFIGURATOR_MODE}" ]
then
doConfigureWorkspace "${SETTINGS_PATH}/intellij/workspace" "${WORKSPACE_PATH}" ${CONFIGURATOR_MODE}
fi

if [ "${CREATE_SCRIPT}" = "true" ]
then
echo -e "#!/bin/bash\ncd \`dirname \${0}\`\ncd workspaces/${WORKSPACE}\nsource ${DEVON_IDE_HOME}/scripts/devon intellij" > intellij-$WORKSPACE
chmod a+x intellij-$WORKSPACE
echo "Created script intellij-$WORKSPACE"
fi

if [ "${run}" != "false" ]
then
echo "launching IntelliJ..."
"${IDEA_HOME}/idea" &
fi
shift
done
4 changes: 2 additions & 2 deletions scripts/src/main/resources/scripts/devon.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export JAVA_HOME=${DEVON_IDE_HOME}/software/java
#export M2_REPO=~/.m2/repository
export M2_REPO=${DEVON_IDE_HOME}/conf/.m2/repository
export MAVEN_HOME=${DEVON_IDE_HOME}/software/maven
export MAVEN_OPTS="-Xmx512m -Duser.home=${DEVON_IDE_HOME}/conf"
export MAVEN_OPTS=-Xmx512m -Duser.home=${DEVON_IDE_HOME}/conf

# Eclipse
ECLIPSE_VMARGS="-Xms128M -Xmx768M"
ECLIPSE_VMARGS=-Xms128M -Xmx768M
8 changes: 4 additions & 4 deletions scripts/src/main/resources/scripts/environment-project.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ rem This batch is not supposed to be called manually
@echo off

set DEVON_IDE_HOME=%CD%
call load_properties "%DEVON_IDE_HOME%\scripts\devon.properties"
call :load_properties "%DEVON_IDE_HOME%\scripts\devon.properties"
if exist "%DEVON_IDE_HOME%\variables.bat" (
call load_properties "%DEVON_IDE_HOME%\devon.properties"
call :load_properties "%DEVON_IDE_HOME%\devon.properties"
)
rem copy defaults
if not exist "%DEVON_IDE_HOME%\conf" (
md "%DEVON_IDE_HOME%\conf"
)
if exist "%SETTINGS_PATH%" (
if exist "%SETTINGS_PATH%\devon\devon.properties" (
call load_properties "%SETTINGS_PATH%\devon\devon.properties"
call :load_properties "%SETTINGS_PATH%\devon\devon.properties"
) else (
echo:
echo *** ATTENTION ***
Expand Down Expand Up @@ -94,7 +94,7 @@ if exist "%SOFTWARE_PATH%\nodejs" (
:variables
rem load user settings late so variables like M2_REPO can be overriden
if exist "%DEVON_IDE_HOME%\conf\devon.properties" (
call load_properties "%DEVON_IDE_HOME%\conf\devon.properties"
call :load_properties "%DEVON_IDE_HOME%\conf\devon.properties"
)
goto :eof

Expand Down
32 changes: 21 additions & 11 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ function doExtract() {
local mount_dir="${DEVON_IDE_HOME}/updates/volume"
mkdir -p "${mount_dir}"
doRunCommand "hdiutil attach -quiet -nobrowse -mountpoint '${mount_dir}' '${1}'"
doRunCommand "cp -a '${mount_dir}' '${target_dir}'"
doRunCommand "hdiutil detach '${mount_dir}'"
doRunCommand "cp -a '${mount_dir}'/*.app '${target_dir}'"
doRunCommand "hdiutil detach -force '${mount_dir}'"
if [ -e "${target_dir}/Applications" ]
then
rm "${target_dir}/Applications"
Expand Down Expand Up @@ -335,7 +335,7 @@ function doUpgradeMavenArtifact() {
if [ -d "${1}/.git" ]
then
echo "Found git repository ${1} - updating via git"
doRunCommand "git pull" "" "${1}"
doGitPullOrClone "${1}"
return
fi
local download_url="${2}"
Expand Down Expand Up @@ -402,12 +402,22 @@ function doMoveGlobSafe() {
# $1: absolute target path
# $2: URL
function doGitPullOrClone() {
doRequestCommand git
if [ -d "${1}/.git" ]
then
doRunCommand "git pull" "" "${1}"
local remotes=$(cd "${1}";git remote)
if [ -n "${remotes}" ]
then
doRunCommand "git pull" "" "${1}"
else
echo "Can not update local git repository: ${1}"
fi
else
doRunCommand "git pull '${2}' '${1}'"
if [ -z "${2}" ]
then
doFail "Not a git repository: ${1}"
else
doRunCommand "git clone '${2}' '${1}'"
fi
fi
}

Expand Down Expand Up @@ -565,7 +575,7 @@ function doIsWindows() {
return -1
}

function load_properties() {
function doLoadProperties() {
if ! [ -f "${1}" ]
then
return
Expand Down Expand Up @@ -607,8 +617,8 @@ then
DEVON_IDE_HOME="`dirname ${BASH_SOURCE:-$0}`/.."
echo "DEVON_IDE_HOME variable set to ${DEVON_IDE_HOME}"
fi
load_properties "${DEVON_IDE_HOME}/scripts/devon.properties"
load_properties "${DEVON_IDE_HOME}/devon.properties"
load_properties "${SETTINGS_PATH}/devon/devon.properties"
load_properties "${DEVON_IDE_HOME}/conf/devon.properties"
doLoadProperties "${DEVON_IDE_HOME}/scripts/devon.properties"
doLoadProperties "${DEVON_IDE_HOME}/devon.properties"
doLoadProperties "${SETTINGS_PATH}/devon/devon.properties"
doLoadProperties "${DEVON_IDE_HOME}/conf/devon.properties"

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
idea.config.path=${WORKSPACE_FOLDER}/.idea/config
idea.system.path=${WORKSPACE_FOLDER}/.idea/system
idea.config.path=${WORKSPACE_PATH}/.idea/config
idea.system.path=${WORKSPACE_PATH}/.idea/system
idea.plugins.path=${DEVON_IDE_HOME}/conf/.idea/plugins
idea.log.path=${WORKSPACE_FOLDER}/.idea/system/log
idea.log.path=${WORKSPACE_PATH}/.idea/system/log

0 comments on commit 3e9e0a5

Please sign in to comment.