Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic installation option #3

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 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 Expand Up @@ -138,10 +135,7 @@ For instance:
"Green" : "org.example.GreenState"
},
"publish" : {
"platforms" : [ "Desktop" ],
"publishedName" : "optional-published-project-name",
"iconsDir" : "optional-path-to-your-icon-directory"
"platforms" : [ "Desktop" ]
}
}
```
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