Created
April 24, 2019 13:34
-
-
Save axelitus/15186e4da4a39cced9d59dc885964db8 to your computer and use it in GitHub Desktop.
Nord Jetbrains plugin build script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function main() { | |
echo "Creating plugin package..." | |
local root=$(clean_folder $(dirname $(realpath "$0"))) | |
local path=$(prepare_package "$root") | |
local output="$root/nord-jetbrains.jar" | |
local jar=$(which jar) | |
if [ ! -z "$jar" ]; then | |
local output=$(pack_with_jar "$path" "$output") | |
terminate "$output" | |
fi | |
local zip=$(which zip) | |
if [ ! -z "$zip" ]; then | |
local output=$(pack_with_zip "$path" "$output") | |
terminate "$output" | |
fi | |
echo "Could not package plugin. Either zip or jar must be available, none found." | |
exit 1 | |
} | |
# signature: clean($root) | |
function clean_folder() { | |
local root="$1" | |
rm $root/nord-jetbrains.jar 2>/dev/null | |
rm -rf $root/out 2>/dev/null | |
echo $root | |
} | |
# signature: prepare_package($root) | |
function prepare_package() { | |
local root="$1" | |
local path="$root/out/production/nord-jetbrains" | |
mkdir -p "$path" | |
cp -r $root/resources/* $path | |
cp -r $root/src/* $path | |
echo $path | |
} | |
# signature: pack_with_jar($path, $output) | |
function pack_with_jar() { | |
local path="$1" | |
local output="$2" | |
jar cMf $output -C $path . > /dev/null 2>&1 | |
echo $output | |
} | |
# signature: pack_with_zip($path, $output) | |
function pack_with_zip() { | |
local path="$1" | |
local output="$2" | |
local current=$(pwd) | |
cd $path | |
zip -r $output . > /dev/null 2>&1 | |
cd $current | |
echo $output | |
} | |
# signature terminate($path) | |
function terminate() { | |
local path="$1" | |
echo "Plugin package created: $path" | |
exit 0 | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment