generated from openremote/custom-project
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ebd502b
Showing
71 changed files
with
19,891 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# CI/CD workflow files | ||
This directory follows the same structure as the main [OpenRemote repo](https://github.com/openremote/openremote/tree/master/.ci_cd). |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This just references the CI/CD workflow in the main OpenRemote repo | ||
name: CI/CD | ||
|
||
on: | ||
# Push excluding tags and workflow changes | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '*.*' | ||
paths-ignore: | ||
- '.github/**' | ||
- '.ci_cd/**' | ||
- '**/*.md' | ||
|
||
# When a release is published | ||
release: | ||
types: [published] | ||
|
||
# Manual trigger | ||
workflow_dispatch: | ||
inputs: | ||
ENVIRONMENT: | ||
description: 'Environment to use (if any)' | ||
MANAGER_TAG: | ||
description: 'Manager docker tag to pull' | ||
CLEAN_INSTALL: | ||
description: 'Delete data before starting' | ||
type: boolean | ||
COMMIT: | ||
description: 'Repo branch or commit SHA to checkout' | ||
|
||
# Un-comment to monitor manager docker image tags for changes and trigger a redeploy when they change (see .ci_cd/README.md) | ||
# schedule: | ||
# - cron: '*/17 * * * *' | ||
|
||
jobs: | ||
call-main-repo: | ||
name: CI/CD | ||
uses: openremote/openremote/.github/workflows/ci_cd.yml@master | ||
with: | ||
INPUTS: ${{ toJSON(github.event.inputs) }} | ||
secrets: | ||
SECRETS: ${{ toJSON(secrets) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Build and Release Folders | ||
bin-debug/ | ||
bin-release/ | ||
[Oo]bj/ | ||
[Bb]in/ | ||
[Bb]uild/ | ||
[Oo]ut/ | ||
[Tt]mp/ | ||
|
||
# Other files and folders | ||
.settings/ | ||
.gradle/ | ||
.vagrant/ | ||
.node/ | ||
.classpath/ | ||
.classpath | ||
.project/ | ||
.project | ||
.vscode/ | ||
.idea/ | ||
.sts4-cache/ | ||
.local/ | ||
.DS_*/ | ||
apminsight-javaagent/ | ||
console/iOS/DerivedData | ||
console/iOS/Pods | ||
manager/.factorypath/ | ||
Pods/ | ||
node_modules/ | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
# Specific files and logs | ||
openremote.log | ||
dive.log | ||
yarn-error.log | ||
local.properties | ||
|
||
# File extensions | ||
*.mbtiles | ||
*.air | ||
*.ipa | ||
*.apk | ||
*.dab | ||
*.sh | ||
*.iml | ||
*.ipr | ||
*.iws | ||
*.tsbuildinfo | ||
*~ | ||
*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[submodule "openremote"] | ||
path = openremote | ||
url = https://github.com/openremote/openremote.git | ||
branch = master | ||
update = rebase |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nodeLinker: node-modules | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs | ||
spec: "@yarnpkg/plugin-typescript" | ||
|
||
yarnPath: ".yarn/releases/yarn-berry.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# ADDITIONAL CUSTOM PROJECT LICENSES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Custom Project | ||
This repo is a template for custom projects; showing the recommended project structure and including `README` files in the `deployment` directory to provide details about how to customise each part. | ||
|
||
## Setup Tasks | ||
The following `OR_SETUP_TYPE` value(s) are supported: | ||
|
||
* `production` - Requires `CUSTOM_USER_PASSWORD` environment variable to be specified | ||
|
||
Any other value will result in default setup. | ||
|
||
## Encrypted files | ||
If any encrypted files are added to the project then you will need to specify the `GFE_PASSWORD` environment variable to be able to build the project and decrypt the | ||
files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apply plugin: "java-library" | ||
|
||
dependencies { | ||
api resolveProject(":agent") | ||
api project(":model") | ||
} | ||
|
||
task installDist { | ||
dependsOn jar | ||
} |
83 changes: 83 additions & 0 deletions
83
agent/src/main/java/org/openremote/agent/custom/CustomAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2017, OpenRemote Inc. | ||
* | ||
* See the CONTRIBUTORS.txt file in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.openremote.agent.custom; | ||
|
||
import org.openremote.model.asset.Asset; | ||
import org.openremote.model.asset.agent.Agent; | ||
import org.openremote.model.asset.agent.AgentDescriptor; | ||
import org.openremote.model.asset.agent.DefaultAgentLink; | ||
import org.openremote.model.value.AttributeDescriptor; | ||
import org.openremote.model.value.ValueDescriptor; | ||
|
||
import jakarta.persistence.Entity; | ||
import java.util.Optional; | ||
|
||
/** | ||
* This is an example of a custom {@link Agent} type; this must be registered via an | ||
* {@link org.openremote.model.AssetModelProvider} and must conform to the same requirements as custom {@link Asset}s and | ||
* in addition the following requirements: | ||
* | ||
* <ul> | ||
* <li>Optionally add a custom {@link org.openremote.model.asset.agent.AgentLink} (the {@link Class#getSimpleName} must | ||
* be unique compared to all other registered {@link org.openremote.model.asset.agent.AgentLink}s) | ||
* <li>Must define a {@link org.openremote.model.asset.agent.Protocol} implementation that corresponds to this {@link Agent} | ||
* <li>Must have a public static final {@link org.openremote.model.asset.agent.AgentDescriptor} rather than an | ||
* {@link org.openremote.model.asset.AssetDescriptor} | ||
* </ul> | ||
*/ | ||
@Entity | ||
public class CustomAgent extends Agent<CustomAgent, CustomProtocol, DefaultAgentLink> { | ||
|
||
public enum Option { | ||
ONE, | ||
TWO, | ||
THREE | ||
}; | ||
|
||
public static final ValueDescriptor<Option> OPTION_VALUE_DESCRIPTOR = new ValueDescriptor<>("customAgentOption", Option.class); | ||
|
||
public static final AttributeDescriptor<Option> OPTION_ATTRIBUTE_DESCRIPTOR = new AttributeDescriptor<>("option", OPTION_VALUE_DESCRIPTOR); | ||
|
||
public static final AgentDescriptor<CustomAgent, CustomProtocol, DefaultAgentLink> DESCRIPTOR = new AgentDescriptor<>( | ||
CustomAgent.class, CustomProtocol.class, DefaultAgentLink.class | ||
); | ||
|
||
protected CustomAgent() { | ||
} | ||
|
||
public CustomAgent(String name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
public CustomProtocol getProtocolInstance() { | ||
return new CustomProtocol(this); | ||
} | ||
|
||
public Optional<Option> getOption() { | ||
return getAttributes().getValue(OPTION_ATTRIBUTE_DESCRIPTOR); | ||
} | ||
|
||
public CustomAgent setOption(Option value) { | ||
getAttributes().getOrCreate(OPTION_ATTRIBUTE_DESCRIPTOR).setValue(value); | ||
return this; | ||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
agent/src/main/java/org/openremote/agent/custom/CustomAgentModelProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2021, OpenRemote Inc. | ||
* | ||
* See the CONTRIBUTORS.txt file in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.openremote.agent.custom; | ||
|
||
import org.openremote.model.AssetModelProvider; | ||
|
||
public class CustomAgentModelProvider implements AssetModelProvider { | ||
|
||
@Override | ||
public boolean useAutoScan() { | ||
return true; | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
agent/src/main/java/org/openremote/agent/custom/CustomProtocol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2017, OpenRemote Inc. | ||
* | ||
* See the CONTRIBUTORS.txt file in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.openremote.agent.custom; | ||
|
||
import org.openremote.agent.protocol.AbstractProtocol; | ||
import org.openremote.model.Container; | ||
import org.openremote.model.asset.agent.DefaultAgentLink; | ||
import org.openremote.model.attribute.Attribute; | ||
import org.openremote.model.attribute.AttributeEvent; | ||
import org.openremote.model.syslog.SyslogCategory; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import static org.openremote.model.syslog.SyslogCategory.PROTOCOL; | ||
|
||
/** | ||
* A custom protocol that is used by the {@link CustomAgent}; there is a one-to-one mapping between an {@link | ||
* CustomAgent} {@link org.openremote.model.asset.Asset} and its' {@link org.openremote.model.asset.agent.Protocol}. | ||
* This example does nothing useful but is intended to show where protocol classes should be created. | ||
*/ | ||
public class CustomProtocol extends AbstractProtocol<CustomAgent, DefaultAgentLink> { | ||
|
||
public static final String PROTOCOL_DISPLAY_NAME = "Custom"; | ||
private static final Logger LOG = SyslogCategory.getLogger(PROTOCOL, CustomProtocol.class); | ||
protected boolean running; | ||
|
||
public CustomProtocol(CustomAgent agent) { | ||
super(agent); | ||
} | ||
|
||
@Override | ||
protected void doStart(Container container) throws Exception { | ||
running = true; | ||
} | ||
|
||
@Override | ||
protected void doStop(Container container) throws Exception { | ||
|
||
} | ||
|
||
@Override | ||
protected void doLinkAttribute(String assetId, Attribute<?> attribute, DefaultAgentLink agentLink) throws RuntimeException { | ||
|
||
} | ||
|
||
@Override | ||
protected void doUnlinkAttribute(String assetId, Attribute<?> attribute, DefaultAgentLink agentLink) { | ||
|
||
} | ||
|
||
@Override | ||
protected void doLinkedAttributeWrite(Attribute<?> attribute, DefaultAgentLink agentLink, AttributeEvent event, Object processedValue) { | ||
|
||
} | ||
|
||
@Override | ||
public String getProtocolName() { | ||
return PROTOCOL_DISPLAY_NAME; | ||
} | ||
|
||
@Override | ||
public String getProtocolInstanceUri() { | ||
return "custom://" + agent.getOption(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
agent/src/main/resources/META-INF/services/org.openremote.model.AssetModelProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.openremote.agent.custom.CustomAgentModelProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
allprojects { | ||
// Apply common project setup but exclude submodule, it has its own build.gradle | ||
if (!path.startsWith(":openremote")) { | ||
apply from: "${project(":openremote").projectDir}/project.gradle" | ||
} | ||
} | ||
|
||
// Uncomment the following to configure files to be encrypted/decrypted | ||
// Each file must be explicitly added to .gitignore otherwise git commit will fail | ||
// When using encryption the the GFE_PASSWORD environment variable must be set or the build will fail | ||
// use ./gradlew encryptFiles to encrypt files | ||
|
||
//apply plugin: "com.cherryperry.gradle-file-encrypt" | ||
//gradleFileEncrypt { | ||
// // files to encrypt | ||
// plainFiles.from("deployment/manager/fcm.json") | ||
// // (optional) setup file mapping to store all encrypted files in one place for example | ||
// //mapping = [ 'deployment/mySensitiveFile' : 'secrets/mySensitiveFile' ] | ||
// // Use custom password provider as standard env mechanism doesn't seem to work | ||
// passwordProvider = { | ||
// def password = System.env.GFE_PASSWORD | ||
// if (!password) { | ||
// throw new IllegalStateException("GFE_PASSWORD environment variable must be set!") | ||
// } | ||
// return password.toCharArray() | ||
// } | ||
//} | ||
//task checkFilesGitIgnoredNew(type: Exec) { | ||
// // The provided checkFilesGitIgnored task doesn't work on Windows so here's one that does | ||
// def args = [] | ||
// if (org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS)) { | ||
// args.add("cmd") | ||
// args.add("/c") | ||
// } | ||
// args.add("git") | ||
// args.add("check-ignore") | ||
// args.add("-q") | ||
// args.addAll(project.getProperties().get("gradleFileEncrypt").plainFiles) | ||
// | ||
// commandLine args | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ---------------------------------------------------------------------------------------- | ||
# Docker image for populating deployment-data volume with project specific customisations | ||
# ---------------------------------------------------------------------------------------- | ||
FROM alpine:latest | ||
|
||
RUN mkdir -p /deployment/manager/extensions | ||
ADD image /deployment |
Oops, something went wrong.