From 02b9c03ec51cea632db0400c486451eba29d2173 Mon Sep 17 00:00:00 2001 From: Assaf Attias Date: Sun, 20 Aug 2023 21:59:52 +0300 Subject: [PATCH] refactor const and docs --- README.md | 27 +++++++++------- .../simulation/deployer/Constant.java | 32 +++++++++++++++++++ 2 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 src/main/java/org/attias/open/interactive/simulation/deployer/Constant.java diff --git a/README.md b/README.md index 7741b82..6d7f23f 100644 --- a/README.md +++ b/README.md @@ -114,10 +114,8 @@ This file defines all your project information that is needed in order to run an Example: ```json { - // The title of your project - "name" : "OIS simulation", - // The state that will be activated when running the simulation - "initialState" : "Green", + "name" : "OIS simulation", // The title of your project + "initialState" : "Green", // The state that will be activated when running the simulation // Map of all the implemented IState classes in your project and their keys. "states" : { "Blue" : "org.example.BlueState", @@ -126,20 +124,25 @@ Example: }, // The deployer configurations "runner" : { - // OIS runner version - "version" : "1.0-SNAPSHOT", - // The platforms that the simulation will run on, must define at least one - // Options: 'Desktop' - "types" : [ "Desktop" ], - "assetsDirectories" : [ ] + "version" : "0.1", // OIS runner version + // The platforms that the simulation will run on, must define at least one + "types" : [ "Desktop" ] } } ``` -Optionally - You can also control where to read the `simulation.ois` file by adding the plugin Extension to your `build.gradle`: +### Plugin Extension +To allow smooth development, you can optionally override some project `simulation.ois` or plugin configurations by specific the `oisDeployer` extension in your `build.gradle`: ```groovy oisDeployer { + // Instead of resolving the runner base on its version in simulation.ois, + // Run the runner project from this directory. + runnerPath = 'path-to-dir-of-specific-runner' + // Instead of getting the project configurations from the `simulation.ois` file in the project root directory, + // Get project configurations from this file. configPath = 'path-to-your-simulation-config-file' + // Instead of resolving the assets directory from your project resources, resolve from this path. + assetsPath = 'path-to-your-resources-dir' } ``` @@ -151,7 +154,7 @@ All the task exposed by the plugin are grouped under the group `ois`. ### 🌱 Develop your project -Read the [user guide](https://github.com/attiasas/open-interactive-simulation-core/USER_GUIDE.md) in the core library. +Read the [user guide](https://github.com/attiasas/open-interactive-simulation-core/blob/master/USER_GUIDE.md) in the core library. ### 👀 Run your project diff --git a/src/main/java/org/attias/open/interactive/simulation/deployer/Constant.java b/src/main/java/org/attias/open/interactive/simulation/deployer/Constant.java new file mode 100644 index 0000000..0fde7e2 --- /dev/null +++ b/src/main/java/org/attias/open/interactive/simulation/deployer/Constant.java @@ -0,0 +1,32 @@ +package org.attias.open.interactive.simulation.deployer; + +import org.attias.open.interactive.simulation.core.backend.engine.AppConfiguration; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class Constant { + public static final String OIS = "ois"; + public static final String GROUP_NAME = OIS; + public static final String FILE_SUFFIX = "." + OIS; + public static final String PROJECT_CONFIG_FILE_NAME = "simulation" + FILE_SUFFIX; + + public static final Path HOME_PATH = Paths.get(System.getProperty("user.home"), FILE_SUFFIX); + public static final Path RUNNERS_PATH = HOME_PATH.resolve("runners"); + public static final String DEFAULT_RUNNER_VERSION = "0.1"; + + public static final String DEFAULT_PROJECT_TITLE = "OIS Simulation"; + public static final Set APP_TYPES = new HashSet<>(List.of(AppConfiguration.AppType.Desktop)); + + public static final String OIS_RUNNER_GIT_REPO = "https://github.com/attiasas/open-interactive-simulation-runner.git"; + public static final String EXTENSION_NAME = "oisDeployer"; + + public static final String INIT_TASK_NAME = "initializeDeployer"; + public static final String INIT_TASK_DESCRIPTION = "Initialize the simulation deployer resources before running related tasks"; + + public static final String RUN_DESKTOP_TASK_NAME = "runDesktop"; + public static final String RUN_DESKTOP_TASK_DESCRIPTION = "Runs the simulation using desktop"; +}