You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developer-guide/creating-a-custom-project.md
+22-17Lines changed: 22 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,14 @@ sidebar_position: 8
5
5
# Creating a custom project
6
6
7
7
## Quickstart
8
+
8
9
We have a repo which can be used as a template for a custom project; simply clone the [custom-project](https://github.com/openremote/custom-project) repo and start adding your custom code; see the [Endpoints and file paths](../architecture/manager-endpoints-and-file-paths.md) documentation to understand how to override the various parts of the system.
9
10
10
11
## What is a custom project
12
+
11
13
A custom project is a way of extending OpenRemote to provide custom functionality without modifying the main OpenRemote code, thus the custom code can be separately version controlled possibly in a private repo. Possible use cases:
12
14
13
-
* Custom protocols (to interface with some service/device in a customised way)
15
+
* Custom protocols (to interface with some service/device in a customized way)
14
16
* Custom setup code (to automatically provision realms, users, assets, rules, etc. during a clean install)
15
17
* Custom asset types
16
18
* Custom Docker Compose profiles
@@ -27,50 +29,53 @@ The guide consists of the following sections and you will need to have a working
27
29
28
30
It is recommended to put custom project code in directory/module called `deployment` this can then be built as a Docker image and used as a Docker volume to map into our `manager` and `keycloak` containers to override/enhance their behaviour; if there is a large amount of code then multiple directories/modules might be desired to logically separate the code, in this case it is advised to follow the same naming convention as the main OpenRemote repo and to ensure the `gradle` build `installDist` task is configured in order to copy the compiled code into the `deployment``build` directory in preparation for building the `deployment` Docker image.
29
31
30
-
31
-
32
32
## OpenRemote Dependencies
33
-
Depending on what parts of the OpenRemote system are being customised will determine the code dependencies on the main OpenRemote code base; as the main OpenRemote code base is a monolith repo it is possible to add a `git submodule` to the main OpenRemote repo and directly reference the `gradle` projects within, this gives a very tight development process which is particularly useful if making code changes within the OpenRemote code base at the same time, to do this use the standard `git submodule` command (refer to Git documentation for working with submodules):
An alternative is to reference release artefacts of our various modules:
34
+
Depending on what parts of the OpenRemote system are being customized will determine the code dependencies on the main OpenRemote code base.
35
+
36
+
A custom project always depends on the following released OpenRemote artefacts:
39
37
40
-
* java modules - see maven repo (TODO)
41
-
* UI components - see [npm](https://www.npmjs.com/~openremotedeveloper)
38
+
* Docker images - see [Docker Hub](https://hub.docker.com/u/openremote)
39
+
* Java modules - see [Maven Central](https://search.maven.org/search?q=g:io.openremote)
40
+
* UI components - see [npmjs](https://www.npmjs.com/~openremotedeveloper)
42
41
42
+
The [Release Management](../user-guide/deploying/release-management) documentation describes how to update the OpenRemote version of these artefacts.
43
43
44
44
## Custom Project Template
45
-
The [custom-project](https://github.com/openremote/custom-project) repo acts as a template for a custom project that references the OpenRemote dependencies using a `submodule`; you can clone this repo as a starting point for a new custom project, the layout of this repo is as follows:
45
+
46
+
The [custom-project](https://github.com/openremote/custom-project) repo acts as a template for a custom project that uses the OpenRemote dependencies; you can clone this repo as a starting point for a new custom project, the layout of this repo is as follows:
46
47
47
48
*`/deployment` - Directory/module for custom code/files
48
49
*`/gradle` - Gradle files
49
-
*`/openremote` - OpenRemote repo submodule
50
50
*`.gitignore` - Typical `.gitignore` file to exclude common build related files/directories (also excluded `*.mbtiles` as these can be very large binary files not suitable for a git repo)
*`settings.gradle` - Gradle multi project config (loads OpenRemote submodule projects)
54
+
*`settings.gradle` - Gradle multi project config
55
55
*`LICENSE.txt` - Copy of `LICENSE.txt` from main OpenRemote repo
56
56
57
57
### Deployment directory/module
58
-
This module is used to generate a `deployment` Docker image which can be volume mapped into the manager and/or Keycloak containers to customise their behaviour. The `installDist` gradle task of this module will generate output in the `/deployment/build` directory in particular:
58
+
59
+
This module is used to generate a `deployment` Docker image which can be volume mapped into the manager and/or Keycloak containers to customize their behaviour. The `installDist` Gradle task of this module will generate output in the `/deployment/build` directory in particular:
59
60
60
61
*`/deployment/build/image` - Content to be added to the deployment Docker image at `/deployment`
61
62
*`/deployment/build/Dockerfile` - Docker build file used to build `deployment` Docker image (copied from `/deployment` during `installDist`)
62
63
63
64
### Adding new modules
64
-
Create directory with appropriate name and copy `/deployment/build.gradle` into it, customise this new `build.gradle` as required and start adding your code/files, ensuring that the `installDist` gradle task copies any output into the appropriate location within the deployment Docker image build directory (see the [Manager endpoints and file paths](../architecture/manager-endpoints-and-file-paths.md)).
65
+
66
+
Create directory with appropriate name and copy `/deployment/build.gradle` into it, customize this new `build.gradle` as required and start adding your code/files, ensuring that the `installDist` Gradle task copies any output into the appropriate location within the deployment Docker image build directory (see the [Manager endpoints and file paths](../architecture/manager-endpoints-and-file-paths.md)).
65
67
66
68
### Adding UI apps/components
67
-
It is recommended to use the same directory layout as found in the `openremote` submodule, and put all UI code in a directory called `ui`; as our UI code uses `yarn workspaces` you will need to copy the `/openremote/package.json` into the root of the custom project and then modify the workspace paths within this new file (adding `openremote/` in front of existing paths and also adding new paths for any components or apps created in the custom project).
69
+
70
+
It is recommended to use the same directory layout as found in the `openremote` repository, and add additional UI code in the `ui` directory.
71
+
Our UI code uses `yarn workspaces` so you can add any additional workspace paths to the `package.json` file in the root directory of the custom project.
68
72
69
73
### Custom Keycloak themes
70
-
It's possible to provide custom Keycloak themes see [custom-project](https://github.com/openremote/custom-project/blob/main/deployment/keycloak/themes/README.md) for details.
71
74
75
+
It's possible to provide custom Keycloak themes see [custom-project](https://github.com/openremote/custom-project/blob/main/deployment/keycloak/themes/README.md) for details.
72
76
73
77
## Setup code
78
+
74
79
Custom setup code allows for programmatic configuration of a clean installation including the provisioning of `Agents`, `Assets`, `users`, `rules`, etc. This means that the system loads in a pre-configured state that can easily be reproduced after a clean install. Setup code is executed via the `SetupService` and is only executed if the `OR_SETUP_RUN_ON_RESTART` environment variable is set to `true` or if the database that the instance uses is empty.
75
80
76
81
To write custom setup code then you need to create implementations of `SetupTasks` these are then discovered using the standard java `ServiceLoader` mechanism and must therefore be registered via `META-INF/services` mechanism, generally implementations should extend the `EmptySetupTasks` which will do basic configuration of `keycloak` which is essential, see [custom-project](https://github.com/openremote/custom-project/blob/main/setup/src/main/java/org/openremote/manager/setup/custom/CustomSetupTasks.java) for details.
Copy file name to clipboardExpand all lines: docs/developer-guide/setting-up-an-ide.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,7 @@ This is not necessary if you prefer [Working on the UI](working-on-ui-and-apps.m
10
10
11
11
## Download custom-project
12
12
13
-
1. Using Git, clone the [custom-project](https://github.com/openremote/custom-project) repo
14
-
2.`cd` into the custom-project directory, and add the [openremote](https://github.com/openremote/openremote) submodule, using the `git submodule init` and `git submodule update` commands
13
+
Using Git, clone the [custom-project](https://github.com/openremote/custom-project) repository.
15
14
16
15
## Run Docker container
17
16
@@ -109,7 +108,7 @@ For custom working directory or launch settings, you may need to configure `.vsc
109
108
110
109
All Docker and Gradle commands **must be executed in the project root directory**. If you are working on the main OpenRemote repository, this means the root of the repository. If you are [Creating a custom project](creating-a-custom-project.md), this means the root of your project's repository.
111
110
112
-
The working directory in your IDE however must always be set to the **OpenRemote project directory**. All configuration settings in source code default to this location. This means if you are [Creating a custom project](creating-a-custom-project.md), your IDE will work in the `openremote` submodule directory.
111
+
The working directory in your IDE must also always be set to your project root directory.
113
112
114
113
We recommend you set this as the default directory in your IDE for all *Run Configurations*. To improve creation and execution of ad-hoc tests in the IDE you should set the default working directory for JUnit Run Configurations:
Copy file name to clipboardExpand all lines: docs/user-guide/deploying/custom-deployment.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ In this guide we will go through the first time setting up your [custom project]
13
13
## Follow these steps to run your custom project
14
14
1. Prepare your [environment](../../developer-guide/preparing-the-environment.md)
15
15
2. Clone your repository from the [custom-project template](https://github.com/openremote/custom-project).\
16
-
Then initialize and update the openremote submodule with `git submodule init` and `git submodule update --rebase --remote` from your custom project directory after cloning the repo. This is easiest if you have an [SSH-key in your Github account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
16
+
This is easiest if you have an [SSH-key in your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
17
17
3.[Set up your IDE](../../developer-guide/setting-up-an-ide.md). Note that Application run configurations are already prepared when using this template. \
18
18
Use `docker-compose -f profile\dev-testing.yml up --build -d` and run the 'Custom Deployment' configuration. You should have two containers running in Docker, and the manager through your IDE.
19
19
4. Run the modelWatch gradle task to build the typescript model `./gradlew modelWatch`
0 commit comments