Skip to content

Commit 2b10afa

Browse files
authored
Update submodule references (#46)
1 parent 309e475 commit 2b10afa

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

docs/developer-guide/creating-a-custom-project.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ sidebar_position: 8
55
# Creating a custom project
66

77
## Quickstart
8+
89
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.
910

1011
## What is a custom project
12+
1113
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:
1214

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)
1416
* Custom setup code (to automatically provision realms, users, assets, rules, etc. during a clean install)
1517
* Custom asset types
1618
* Custom Docker Compose profiles
@@ -27,50 +29,53 @@ The guide consists of the following sections and you will need to have a working
2729

2830
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.
2931

30-
31-
3232
## 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):
34-
```shell
35-
git submodule add -b master https://github.com/openremote/openremote.git openremote/
36-
```
3733

38-
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:
3937

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)
4241

42+
The [Release Management](../user-guide/deploying/release-management) documentation describes how to update the OpenRemote version of these artefacts.
4343

4444
## 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:
4647

4748
* `/deployment` - Directory/module for custom code/files
4849
* `/gradle` - Gradle files
49-
* `/openremote` - OpenRemote repo submodule
5050
* `.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)
5151
* `gradlew`/`gradlew.bat` - Gradle wrapper execution script
5252
* `build.gradle` - Gradle root project build config
5353
* `gradle.properties` - Gradle properties file
54-
* `settings.gradle` - Gradle multi project config (loads OpenRemote submodule projects)
54+
* `settings.gradle` - Gradle multi project config
5555
* `LICENSE.txt` - Copy of `LICENSE.txt` from main OpenRemote repo
5656

5757
### 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:
5960

6061
* `/deployment/build/image` - Content to be added to the deployment Docker image at `/deployment`
6162
* `/deployment/build/Dockerfile` - Docker build file used to build `deployment` Docker image (copied from `/deployment` during `installDist`)
6263

6364
### 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)).
6567

6668
### 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.
6872

6973
### 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.
7174

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.
7276

7377
## Setup code
78+
7479
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.
7580

7681
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.

docs/developer-guide/setting-up-an-ide.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ This is not necessary if you prefer [Working on the UI](working-on-ui-and-apps.m
1010

1111
## Download custom-project
1212

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.
1514

1615
## Run Docker container
1716

@@ -109,7 +108,7 @@ For custom working directory or launch settings, you may need to configure `.vsc
109108

110109
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.
111110

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.
113112

114113
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:
115114

docs/user-guide/deploying/custom-deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In this guide we will go through the first time setting up your [custom project]
1313
## Follow these steps to run your custom project
1414
1. Prepare your [environment](../../developer-guide/preparing-the-environment.md)
1515
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)
1717
3. [Set up your IDE](../../developer-guide/setting-up-an-ide.md). Note that Application run configurations are already prepared when using this template. \
1818
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.
1919
4. Run the modelWatch gradle task to build the typescript model `./gradlew modelWatch`

0 commit comments

Comments
 (0)