Skip to content

Commit

Permalink
Add automatic installation option
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Aug 25, 2023
1 parent c634cb2 commit 5eba34a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 12 deletions.
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ Simplify development and distribution and embrace a more streamlined process.
The plugin is not available in Maven central yet, required to be installed locally

<details>
<summary>Manual installation</summary>

---
<summary>Install locally OIS core library</summary>

Install locally OIS core library
1. Clone the [core library](https://github.com/attiasas/open-interactive-simulation-core)
```bash
git clone https://github.com/attiasas/open-interactive-simulation-core.git
Expand All @@ -55,15 +54,8 @@ The plugin is not available in Maven central yet, required to be installed local
```bash
./gradlew publishToMavenLocal
```

---
</details>

<details>

---
<summary>Install locally the plugin</summary>

Install locally the plugin
1. Clone this repository
```bash
git clone https://github.com/attiasas/open-interactive-simulation-deployer.git
Expand All @@ -73,9 +65,14 @@ The plugin is not available in Maven central yet, required to be installed local
./gradlew publishToMavenLocal
```

---
</details>

Download the installation bash [script](src/main/resources/installOIS.sh) and run it:
```bash
./installOIS.sh
```

---
1. Add at the top of your `settings.gradle` the following snippet
```groovy
pluginManagement {
Expand Down
71 changes: 71 additions & 0 deletions src/main/resources/installOIS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

# Determine the operating system
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="mac"
elif [[ "$OSTYPE" == "cygwin" ]]; then
OS="windows"
elif [[ "$OSTYPE" == "msys" ]]; then
OS="windows"
elif [[ "$OSTYPE" == "win32" ]]; then
OS="windows"
else
OS="unknown"
fi

# Set the base directory for cloning
base_dir="$HOME/.ois"
mkdir -p "$base_dir"

# Define the tags for cloning
CORE_TAG="master"
DEPLOYER_TAG="master"

# Function to check if directory exists and is not empty
directory_exists_and_not_empty() {
dir_path=$1

if [ -d "$dir_path" ] && [ -n "$(ls -A "$dir_path")" ]; then
return 0 # Directory exists and is not empty
else
return 1 # Directory doesn't exist or is empty
fi
}

# Function to clone and publish a repository to Maven Local
clone_and_publish() {
repo_url=$1
tag=$2
repo_name=$(basename $repo_url .git)
clone_dir="$base_dir/$repo_name"

# Check if the directory exist and not empty
if directory_exists_and_not_empty "$clone_dir"; then
echo "$clone_dir exists and is not empty. Skipping cloning."
else
mkdir -p "$clone_dir"
echo "cloning $repo_url ${tag}."
# Clone the repository with the specified tag or master if not specified
git clone --branch ${tag} $repo_url "$clone_dir"
fi

cd "$clone_dir"

# Publish the repository to Maven Local
echo "publishing to mavenLocal $repo_url."
if [[ "$OS" == "windows" ]]; then
./gradlew.bat publishToMavenLocal
else
./gradlew publishToMavenLocal
fi

cd ..
}

# Clone and publish the core library
clone_and_publish https://github.com/attiasas/open-interactive-simulation-core.git $CORE_TAG

# Clone and publish the deployer repository
clone_and_publish https://github.com/attiasas/open-interactive-simulation-deployer.git $DEPLOYER_TAG

0 comments on commit 5eba34a

Please sign in to comment.