From 981e41788f8a745c322ef523625caaf10bb0b74f Mon Sep 17 00:00:00 2001 From: Lucas de Almeida <105776775+propilideno@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:04:18 -0300 Subject: [PATCH] Allowing easy-install plugin with bash script (#146) * Updating installation from FrameWeb to OntoUML * Refactoring * using mvnw instead of maven * fix: open was not recognized on windows, replaced by start * fix: install_jdk was displaying info about maven * style: inline conditional * feat: preventing empty plugin folder * style: adopted snake case standard for functions * chore: removing junk of (tabs, spaces) * feat: added graphical support to folder traversal in Windows * fix: on prompts and forgotten variable replace * style: adopted camel case for variables * chore: changed script author reference * style: adopted camel case for variables * docs: update the download link for the official provider * chore: removing unrequired code * fix: raw file reference to the OntoUML repository * feat: added option to create plugin folder if doesn't exist * fix: forgotten currentPath * windows: setting default search folder as AppData/Roaming for plugin --- README.md | 37 +++++++- install.sh | 261 +++++++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 2 + 3 files changed, 295 insertions(+), 5 deletions(-) create mode 100755 install.sh diff --git a/README.md b/README.md index 63959302..7c2399d9 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,14 @@ ___ ## User Instructions +### Automatic: +- **Windows**, open `Git Bash` ; +- **Linux / MacOS**, open `Terminal` and type: +``` +bash <(curl -sL https://raw.githubusercontent.com/OntoUML/ontouml-vp-plugin/master/install.sh) +``` +### Manual: + To **install** or **update** the **OntoUML Plugin for Visual Paradigm**, please go to our [releases page](https://github.com/OntoUML/ontouml-vp-plugin/releases) and download the ZIP file `ontouml-vp-plugin` in the latest release. Then go to `Help > Install Plugin` in the top of your window and, after clicking `Install from a zip of plugin` and `Next`, select the download release. ![Install plugin window](./docs/toolbar-help-install.png) @@ -228,11 +236,30 @@ ___ ## FAQ -* [Why do I get the error message "The ID [...] is already in use"?](#why-do-i-get-the-error-message-"the-id-[...]-is-already-in-use") - -* [Why Protégé gives me an error message when I try to open my ontology exported to gUFO?](#why-protégé-gives-me-an-error-message-when-i-try-to-open-my-ontology-exported-to-gufo) - -* [I had an error while updating the plugin through the "Update Plugin" button and now it does not work](#I-had-an-error-while-updating-the-plugin-through-the-"Update-Plugin"-button-and-now-it-does-not-work) +- [OntoUML Plugin for Visual Paradigm](#ontouml-plugin-for-visual-paradigm) + - [Contents](#contents) + - [Overview](#overview) + - [Features](#features) + - [OntoUML Enhanced Modeling](#ontouml-enhanced-modeling) + - [Smart Paint](#smart-paint) + - [Smart Modeling](#smart-modeling) + - [Model Verification and Diagram Verification](#model-verification-and-diagram-verification) + - [Model Transformation to OWL with gUFO](#model-transformation-to-owl-with-gufo) + - [Automatic Diagram Generation](#automatic-diagram-generation) + - [Continuous Updates](#continuous-updates) + - [User Instructions](#user-instructions) + - [Automatic:](#automatic) + - [Manual:](#manual) + - [Developer Instructions](#developer-instructions) + - [Requirements](#requirements) + - [Build instructions](#build-instructions) + - [Setting up](#setting-up) + - [Maven Commands](#maven-commands) + - [Report Errors](#report-errors) + - [FAQ](#faq) + - [Why do I get the error message "The ID \[...\] is already in use"?](#why-do-i-get-the-error-message-the-id--is-already-in-use) + - [Why Protégé gives me an error message when I try to open my ontology exported to gUFO?](#why-protégé-gives-me-an-error-message-when-i-try-to-open-my-ontology-exported-to-gufo) + - [I had an error while updating the plugin through the "Update Plugin" button and now it does not work](#i-had-an-error-while-updating-the-plugin-through-the-update-plugin-button-and-now-it-does-not-work) ### Why do I get the error message "The ID [...] is already in use"? diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..b0ab3bd7 --- /dev/null +++ b/install.sh @@ -0,0 +1,261 @@ +#!/bin/bash + +# =================================================== +# Author: Lucas Rodrigues de Almeida, @propilideno | +# Description: OntoUML installation with bash script | +# =================================================== + +# OS Defaults +OS=$(uname -s) # Gather OS Name +USER=$(whoami) # Gather USER Name + +#OntoUML-Vp-Plugin Defaults +repoName="ontouml-vp-plugin" +repoUrl="https://github.com/propilideno/ontouml-vp-plugin/archive/refs/heads/master.zip" +ontoumlPluginPath="ontouml-vp-plugin-0.5.3" + +# =========== Visual Paradigm Defaults =========== +#App Default Path +VISUAL_PARADIGM_APP_DIR_WINDOWS="C:\\Program Files\\Visual Paradigm CE 17.0\\" #Windows +VISUAL_PARADIGM_APP_DIR_MAC="/Applications/Visual Paradigm.app/Contents/Resources/app/" #MacOS +VISUAL_PARADIGM_APP_DIR_LINUX="/home/$USER/Visual_Paradigm_17.0/" #Linux +#Plugin Default Path +VISUAL_PARADIGM_PLUGIN_DIR_WINDOWS="C:\\Users\\$USER\\AppData\\Roaming\\VisualParadigm\\plugins\\" #Windows +VISUAL_PARADIGM_PLUGIN_DIR_MAC="/Users/$USER/Library/Application Support/VisualParadigm/plugins/" #MacOS +VISUAL_PARADIGM_PLUGIN_DIR_LINUX="/home/$USER/.config/VisualParadigm/plugins/" #Linux + +read_app_path(){ + local currentPath="$1" + while true; do + echo "Visual Paradigm Path: $currentPath" + read -p "Confirm (y/n)?: " choice + case "$choice" in + y|Y ) [[ -d "$currentPath" ]] && break || printf " Type a valid path!\n";; + n|N ) + case "$OS" in + MINGW64*) currentPath=$(powershell -Command "(New-Object -ComObject Shell.Application).BrowseForFolder(0, 'Select the Visual Paradigm (APP FOLDER)', 0, 0).Self.Path");; + *) read -p "The path to your Visual Paradigm (APP FOLDER) is: " currentPath;; + esac + ;; + * ) printf "Invalid input\n";; + esac + done + appDir="$currentPath" +} + +read_plugin_path(){ + local currentPath="$1" + while true; do + echo "Visual Paradigm Plugin Path: $currentPath" + read -p "Confirm (y/n)?: " choice + case "$choice" in + y|Y ) + if [ -d "$currentPath" ]; then + break + else + read -p " Do you want to create this folder (y/n)?: " choice + case "$choice" in + y|Y ) mkdir -p $currentPath && break;; + n|N ) ;; + * ) printf "Invalid input\n";; + esac + fi + ;; + n|N ) + case "$OS" in + MINGW64*) currentPath=$(powershell -Command "(New-Object -ComObject Shell.Application).BrowseForFolder(0, 'Select the Visual Paradigm (PLUGIN FOLDER)', 0, [System.Environment]::GetFolderPath('ApplicationData')).Self.Path");; + *) read -p "The path to your Visual Paradigm (PLUGIN FOLDER) is: " currentPath;; + esac + ;; + * ) printf "Invalid input\n";; + esac + done + pluginDir="$currentPath" +} + +get_vp_app_path(){ + case "$OS" in + Linux*) + read_app_path "$VISUAL_PARADIGM_APP_DIR_LINUX" + ;; + Darwin*) + read_app_path "$VISUAL_PARADIGM_APP_DIR_MAC" + ;; + MINGW64*) + read_app_path "$VISUAL_PARADIGM_APP_DIR_WINDOWS" + appDir=$(echo "$appDir" | sed 's/\\/\\\\/g') + ;; + *) + echo "Operating System not Supported" + exit 1 + esac +} + +get_vp_plugin_path(){ + case "$OS" in + Linux*) + read_plugin_path "$VISUAL_PARADIGM_PLUGIN_DIR_LINUX" + ;; + Darwin*) + read_plugin_path "$VISUAL_PARADIGM_PLUGIN_DIR_MAC" + ;; + MINGW64*) + read_plugin_path "$VISUAL_PARADIGM_PLUGIN_DIR_WINDOWS" + pluginDir=$(echo "$pluginDir" | sed 's/\\/\\\\/g') + ;; + *) + echo "Operating System not Supported" + exit 1 + esac +} + +download_plugin(){ + echo "Downloading OntoUML VP Plugin Repository ..." + case "$(basename $(pwd))" in + $repoName*) # Case ontouml-vp-plugin or ontouml-vp-plugin-master + echo "OntoUML Repository already downloaded, running the script ..." + ;; + *) + echo "Downloading the OntoUML Repository ..." + rm -rf $repoName-master + curl -sL $repoUrl -o master-ontouml-temp.zip + unzip master-ontouml-temp.zip + rm -rf master-ontouml-temp.zip + cd $repoName-master + esac +} + +# If the install fails, then print an error and exit. +install_fail() { + echo " Installation failed" + exit 1 +} + +# This is the help fuction. It helps users withe the options +help(){ + echo "Usage: ./install.sh" + echo "Make sure u have permission to execute install.sh" + echo "If u had problems try it: "chmod +x install.sh" or allow execution in properties" +} + +install_jdk(){ + if command -v javac &> /dev/null; then + echo " JDK already installed." + else + echo " You're missing JDK" + case "$OS" in + Linux*) + sudo apt-get install default-jdk + ;; + Darwin*) + brew install java + ;; + MINGW64*) + local LINK="https://www.oracle.com/java/technologies/downloads/" + echo "JDK automatic installion is not supported by Windows yet." + echo "Install JDK, restart your Git Bash and try it again ..." + start $LINK + exit 1 + ;; + *) + echo " Operating System not Supported" + exit 1 + esac + fi +} + +install_ontouml_vp_plugin(){ + # Get the paths to write on pom.xml + get_vp_app_path + get_vp_plugin_path + if [ -d "$pluginDir$ontoumlPluginPath" ]; then + echo " ONTOUML PLUGIN INSTALLED!" + while true; do + read -p "Do you want proceed installation (y/n)?: " choice + case "$choice" in + y|Y ) break;; + n|N ) greetings ;; + * ) printf "Invalid input\n";; + esac + done + fi + # Config pom.xml with gathered paths + case "$OS" in + Darwin*) + sed -i '' "s||$appDir|g" pom.xml # '' Before the regex is to prevent ISSUE on MacOS. + sed -i '' "s||$pluginDir|g" pom.xml # '' Before the regex is to prevent ISSUE on MacOS + ;; + *) + sed -i "s||$appDir|g" pom.xml + sed -i "s||$pluginDir|g" pom.xml + esac + # Install plugin with Maven Wrapper + ./mvnw install +} + +install_visual_paradigm(){ #Development + echo "Opening Visual Paradigm WebSite" + open https://www.visual-paradigm.com/download/ + # https://www.visual-paradigm.com/download/?platform=linux&arch=64bit #Linux -> Visual_Paradigm_17_0_20230401_Linux64.sh +} + +# to install for debian based distrOS (and ubuntu) +install_shell_deps(){ + case "$OS" in + Linux*) + if ! command -v unzip &> /dev/null; then + sudo apt-get install unzip + fi + ;; + *) + echo "No shell requirements for your OS" + esac +} + +clean_installation(){ + while true; do + printf "\nDo you want to clean installation files?\n" + read -p "Confirm (y/n)?: " choice + case "$choice" in + y|Y ) + case "$(basename $(pwd))" in + $repoName*) # Case ontouml-vp-plugin or ontouml-vp-plugin-master + echo "Cleaning temporary files, downloads, zips and ontouml-vp-plugin installation ..." + cd .. + rm -rf $repoName-master + break; + ;; + esac + ;; + n|N ) break;; + * ) printf "Invalid input\n" + esac + done +} + +greetings(){ + printf "\n\n==> OntoUML was installed with SUCCESS !!!\n" + echo "==> Contribute with us giving this repo a Star ⭐" + exit 1 +} + +# Main function +install_main(){ + echo "=== OntoUML-vp-plugin Installer ===" + echo "Installing shell dependencies ..." + install_shell_deps || install_fail + echo "Installing plugin dependencies ..." + install_jdk || install_fail + #install_visual_paradigm || install_fail + # Download the ontouml-vp-plugin repository + download_plugin || install_fail + echo "Installing ontouml-vp-plugin..." + install_ontouml_vp_plugin || install_fail + # Cleaning installation + clean_installation + # Run the greetings by using OntoUML + greetings +} + +# Run the main function +install_main diff --git a/pom.xml b/pom.xml index 74a0a8fc..c2c6621a 100644 --- a/pom.xml +++ b/pom.xml @@ -38,8 +38,10 @@ UTF-8 + +