about summary refs log tree commit diff stats
path: root/home-manager/packages/scripts/deprecated/java_compiler
diff options
context:
space:
mode:
authorene <ene@sils.li>2023-02-25 07:54:37 +0100
committerene <ene@sils.li>2023-02-25 07:54:37 +0100
commit06696ca201682f63ea50da3ab41d992ed6b61816 (patch)
tree93152237a2e968cd433d1ca21671dcba52e772b8 /home-manager/packages/scripts/deprecated/java_compiler
parentFix(hosts): Update UUIDs for mammun hosts (diff)
downloadnixos-config-06696ca201682f63ea50da3ab41d992ed6b61816.tar.gz
nixos-config-06696ca201682f63ea50da3ab41d992ed6b61816.zip
Feat(packages): Add my scripts
Diffstat (limited to '')
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/clpa15
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/fmt16
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/jc34
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/jj58
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/lib41
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/new37
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack22
-rwxr-xr-xhome-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack57
8 files changed, 280 insertions, 0 deletions
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/clpa b/home-manager/packages/scripts/deprecated/java_compiler/clpa
new file mode 100755
index 00000000..c33ed025
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/clpa
@@ -0,0 +1,15 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+pw=$(pwd)
+[ "$n" = "n" ] || cd ..
+noColor=yes . ./lib
+
+unset CLASSPATH
+
+while IFS= read -r i;do
+    export CLASSPATH=$CLASSPATH$i:
+done < "$(tmp cat "$(tmp "find $(pwd)/libs | sed 1d") $(tmp "find $(pwd)/scr | sed 1d")")"
+cd $pw
+
+if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/fmt b/home-manager/packages/scripts/deprecated/java_compiler/fmt
new file mode 100755
index 00000000..4dce0c02
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/fmt
@@ -0,0 +1,16 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. ~/.local/lib/shell/lib
+
+cd ..;
+pw=$(pwd);
+cd ..;
+
+while IFS= read -r i;do
+    java -jar google-java-format-1.15.0-all-deps.jar -i $i
+done < "$(tmp "find $pw/scr | sed 1d")"
+
+
+
+if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/jc b/home-manager/packages/scripts/deprecated/java_compiler/jc
new file mode 100755
index 00000000..8f95108c
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/jc
@@ -0,0 +1,34 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+
+cd ..
+noColor=yes . ./lib
+
+export CLASSPATH=
+scr=$(mktemp)
+
+while IFS= read -r a;do
+    export CLASSPATH=$CLASSPATH$a:
+done < "$(tmp "find libs/ | sed 1d")"
+
+while IFS= read -r a;do
+    echo "$a" >> $scr
+done < "$(tmp "find scr/ | sed 1d")"
+
+n=n . ./clpa 
+
+#while IFS= read -r a;do
+#    rm "$a"
+#done < "$(tmp "find target/ | sed 1d")"
+
+javac -d target/ $(cat $scr | tr '\n' ' ')
+if [ "$1" = "r" ];then
+    cd target || die "bug"
+    java Main
+    cd ..
+else
+    ./jj target/ libs/
+fi
+
+rm $scr
+if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/jj b/home-manager/packages/scripts/deprecated/java_compiler/jj
new file mode 100755
index 00000000..6d6a5aed
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/jj
@@ -0,0 +1,58 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+noColor=yes . ./lib
+
+help() {
+cat << EOF 
+Add all dirs with trailing /
+
+\$1 = java .class files dir
+\$2 = java .jar files dir
+
+if you want to update libs delete this:
+$wd/libs.cache
+
+EOF
+exit 0
+}
+
+
+class=$(mktemp)
+jar=$(mktemp)
+pwd=$(pwd)
+
+mkdir "$pwd"/out/cache 2> /dev/null
+wd="$pwd"/out/cache
+[ "$1" = "-h" ] && help 
+[ "$1" = "--help" ] && help 
+
+[ -z "$1" ] && error "no args" && help && exit 1
+[ -z "$2" ] && error "no args" && help && exit 1
+
+while IFS= read -r i;do
+    cp "$i" $wd/"$(basename $i)"
+done < "$(tmp "find $1 | sed 1d" )"
+
+while IFS= read -r i;do
+    if ! grep "^$i$" "$wd"/libs.cache;then
+        echo "$i" | sed "s|$2||" >> "$wd"/libs.cache
+        cd $wd
+        jar -xf "$pwd"/"$i"
+        cd $pwd
+    fi
+done < "$(tmp "find $2 | sed 1d" )"
+
+while IFS= read -r a;do
+    echo "$a" | sed "s|$wd/||" >> $jar
+done < "$(tmp "find $wd | sed 1d")"
+
+
+
+cd "$wd" || die "No $wd"
+jar -c -f myJar.jar -e Main $(cat $jar | tr '\n' ' ') 
+
+mv myJar.jar "$pwd"/out/myJar.jar
+
+rm $jar
+rm $class
+if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/lib b/home-manager/packages/scripts/deprecated/java_compiler/lib
new file mode 100755
index 00000000..8446d1ce
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/lib
@@ -0,0 +1,41 @@
+#!/bin/sh
+# shellcheck disable=SC2059,SC2066
+
+
+
+out() { printf "$1 $2\n" "$(out2 "$@")"; }
+out2() { shift 2; for i in "$*";do printf "$i";done; }
+
+
+if [ "$noColor" = "yes" ];then
+error() {  >&2 out "==> ERROR:" "$*"; } >&2
+warning() {  >&2 out "==> WARNING:" "$*"; } >&2
+msg() { out "==>" "$*"; }
+msg2() { out " ->" "$*"; }
+
+readp() { printf "..> $1"; read -r "$2"; }
+
+else
+error() {  >&2 out "\033[1;91m==> ERROR:\033[0m" "\033[1;93m$*\033[0m"; } >&2
+warning() {  >&2 out "\033[1;91m==> WARNING:\033[0m" "\033[1;93m$*\033[0m"; } >&2
+msg() { out "\033[1;96m==>\033[0m" "\033[1;93m$*\033[0m"; }
+msg2() { out "\033[1;96m ->\033[0m" "\033[1;93m$*\033[0m"; }
+
+readp() { printf "\033[1;96m..>\033[0m \033[1;93m$1\033[0m"; read -r "$2"; }
+fi
+
+
+
+
+
+dien() { error "$@" "failed"; exit 1; }
+die() { error "$@"; exit 1; }
+
+clean() { awk '{if (NF) {if (!/^#/) {if (!/^[[:blank:]]*#/) {print $0}}}}' "$1"; }
+# shellcheck disable=SC2294
+tmp() { 
+    [ -d /tmp/LIB_FILE_TEMP_DIR/ ] || mkdir /tmp/LIB_FILE_TEMP_DIR/
+    tmp=$(mktemp -p /tmp/LIB_FILE_TEMP_DIR/);
+    eval "$@" 1> "$tmp";
+    echo "$tmp"; 
+}
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/new b/home-manager/packages/scripts/deprecated/java_compiler/new
new file mode 100755
index 00000000..577558b0
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/new
@@ -0,0 +1,37 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. ./lib
+
+
+[ -z "$1" ] && die "Requires name"
+mkdir "$1"
+pw="$1"
+
+ln -sr jc ./$pw/jc
+ln -sr jj ./$pw/jj
+ln -sr clpa ./$pw/clpa
+ln -sr lib ./$pw/lib
+ln -sr fmt ./$pw/fmt
+
+cd $pw
+mkdir libs
+mkdir -p out/cache
+mkdir scr
+mkdir target
+
+cat > scr/Main.java << EOL 
+public class Main {
+    public static void main(String[] args) {
+        System.out.println("Hello, world!");
+    }
+}
+EOL
+cat > .gitignore << EOL
+/target
+.gitignore
+/out
+EOL
+git init > /dev/null
+[ -d /tmp/LIB_FILE_TEMP_DIR/ ] && rm -r /tmp/LIB_FILE_TEMP_DIR/
+exit 0
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack
new file mode 100755
index 00000000..bc9db9de
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack
@@ -0,0 +1,22 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+
+. ./lib
+cd ..
+
+export CLASSPATH=
+scr=$(mktemp)
+
+while IFS= read -r a;do
+    export CLASSPATH=$CLASSPATH$a:
+done < "$(tmp "find libs/ | sed 1d")"
+
+while IFS= read -r a;do
+    echo "$a" >> $scr
+done < "$(tmp "find scr/ | sed 1d")"
+
+javac -d target/ $(cat $scr | tr '\n' ' ')
+../jj target/ libs/
+[ "$1" = "r" ] && java -jar out/myJar.jar
+
+rm $scr
diff --git a/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack
new file mode 100755
index 00000000..90a9e74e
--- /dev/null
+++ b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack
@@ -0,0 +1,57 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+. ./lib
+
+help() {
+cat << EOF 
+Add all dirs with trailing /
+
+\$1 = java .class files dir
+\$2 = java .jar files dir
+
+if you want to update libs delete this:
+"$wd"/libs.cache
+
+EOF
+exit 0
+}
+
+
+class=$(mktemp)
+jar=$(mktemp)
+pwd=$(pwd)
+
+mkdir "$pwd"/out/cache 2> /dev/null
+wd="$pwd"/out/cache
+[ "$1" = "-h" ] && help 
+[ "$1" = "--help" ] && help 
+
+[ -z "$1" ] && echo "no args" && help && exit 1
+[ -z "$2" ] && echo "no args" && help && exit 1
+
+while IFS= read -r i;do
+    cp "$i" $wd/"$(basename $i)"
+done < "$(tmp "find $1 | sed 1d" )"
+
+while IFS= read -r i;do
+    if ! grep "^$i$" "$wd"/libs.cache;then
+        echo "$i" | sed "s|$2||" >> "$wd"/libs.cache
+        cd $wd
+        jar -xf "$pwd"/"$i"
+        cd $pwd
+    fi
+done < "$(tmp "find $2 | sed 1d" )"
+
+while IFS= read -r a;do
+    echo "$a" | sed "s|$wd/||" >> $jar
+done < "$(tmp "find $wd | sed 1d")"
+
+
+
+cd "$wd" || die "No $wd"
+jar -c -f myJar.jar -e Main $(cat $jar | tr '\n' ' ') 
+
+mv myJar.jar "$pwd"/out/myJar.jar
+
+rm $jar
+rm $class