add missing script coming from unlinked artlog toolbox project

not mandatory but consistent to have all code

Signed-off-by: philippe lhardy <philippe.lhardy@astrolabe.coop>
This commit is contained in:
2025-11-02 08:41:53 +01:00
parent 1b0be89766
commit 3c4b44e837
6 changed files with 910 additions and 4 deletions

137
eclipse_env.sh Executable file
View File

@@ -0,0 +1,137 @@
#!/bin/bash
# for the story this comes from a JavaFX training i attended
usage()
{
cat <<EOF
Usage $0:
setup_dev_env: create file devenv_params with reference over jdk and eclipse path
any other argument is an error
no argument => launch eclipse
EOF
}
create_dev_params()
{
if [[ -e devenv_params ]]
then
echo " devenv_params already exists"
exit 1
# could update this way
# source devenv_params
else
if [[ -z $DEV_ENV ]]
then
echo "[ERROR] DEV_ENV $DEV_ENV not set, call setup_eclipse_dir from this '$0' script"
exit 1
fi
cat >devenv_params <<EOF
DEV_ENV=$DEV_ENV
JDK_PATH=$JDK_PATH
ECLIPSE_PATH=$ECLIPSE_PATH
EOF
fi
}
setup_eclipse_dir()
{
if [[ -e devenv_params ]]
then
source devenv_params
else
echo "[WARNING] Use some defaults for devenv_params"
echo "[INFO] please adapt them. Current setup should be compatible with 'sudo snap install eclipse --classic' setup"
DEV_ENV=~$(pwd)/devel_tools
JDK_PATH=/usr/lib/jvm/java-11-openjdk-amd64
ECLIPSE_PATH=$(dirname $(which eclipse))
fi
}
# Not tested written after install ...
setup_eclipse()
{
# current list of TGZ got from oracle (tm)
TGZ_LIST="eclipse-jee-mars-2-linux-gtk-x86_64.tar.gz javafx_scenebuilder-2_0-linux-x64.tar.gz jdk-8u74-linux-x64.tar.gz"
}
check_eclipse()
{
if [[ -z $JDK_PATH ]]
then
echo "[ERROR] Missing JDK_PATH, either devenv_params is wrong or missing" >&2
exit 1
fi
if [[ -z $ECLIPSE_PATH ]]
then
echo "[ERROR] Missing ECLIPSE_PATH, either devenv_params is wrong or missing" >&2
exit 1
fi
if [[ ! -d $JDK_PATH ]]
then
echo "[ERROR] Missing JDK_PATH '$JDK_PATH'" >&2
fi
if [[ ! -d $ECLIPSE_PATH ]]
then
ls -la ${DEV_ENV}
echo "[ERROR] Missing ECLIPSE_PATH '$ECLIPSE_PATH'" >&2
exit 1
fi
}
# not yet used ...
create_sandbox()
{
mkdir sandbox
}
check_java_version() {
local expected_version='1.8.0'
if java -version 2>&1 | grep "$expected_version"
then
if javac -version 2>&1 | grep "$expected_version"
then
$*
else
echo "[ERROR] Wrong javac version expected $expected_version" >&2
fi
else
echo "[ERROR] Wrong java version expected $expected_version" >&2
fi
}
# overrides PATH with JDK_PATH ECLIPSE_PATH
# and check java is the right one to launch eclipse
run_in_sandbox()
{
PATH=$JDK_PATH/bin/:$JDK_PATH/jre/bin/:$ECLIPSE_PATH:$PATH
export PATH
[[ -n $check_version ]] && check_java_version
}
while [[ $# > 0 ]]
do
case $1 in
setup_dev_env)
setup_eclipse_dir
create_dev_params
exit 0
;;
*)
echo "[ERROR] Unrecognized argument '$1'" >&2
usage
exit 1
;;
esac
shift 1
done
setup_eclipse_dir
check_eclipse
run_in_sandbox eclipse -data $(pwd)/workspace