-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(monorepo): add archetype for quick creation of new connectors
- Loading branch information
1 parent
96ef5f2
commit 472ab0d
Showing
13 changed files
with
539 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,22 @@ | ||
#!/bin/bash | ||
|
||
CONNECTORS_DIR='connectors' | ||
TMP_DIR="${CONNECTORS_DIR}/tmp" | ||
|
||
CONNECTOR_NAME=${1} | ||
ARTIFACT_NAME="connector-${CONNECTOR_NAME}" | ||
|
||
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
|
||
mvn archetype:generate \ | ||
-DarchetypeGroupId=io.camunda.connector \ | ||
-DarchetypeArtifactId=connector-archetype-internal \ | ||
-DarchetypeVersion=${VERSION} \ | ||
-DinteractiveMode=false \ | ||
-DconnectorName=${CONNECTOR_NAME} \ | ||
-DoutputDirectory=${TMP_DIR} | ||
|
||
# Rename directory to follow convention | ||
mv "${TMP_DIR}/${ARTIFACT_NAME}" "${CONNECTORS_DIR}/${CONNECTOR_NAME}" | ||
|
||
rm -rf TMP_DIR |
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.camunda.connector</groupId> | ||
<artifactId>connectors-bundle-parent</artifactId> | ||
<version>0.14.3-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>connector-archetype-internal</artifactId> | ||
<packaging>maven-archetype</packaging> | ||
|
||
<properties> | ||
<archetype-packaging.version>3.2.1</archetype-packaging.version> | ||
<!-- this archetype is for internal connectors only, so skip Maven Central release --> | ||
<skip.central.release>false</skip.central.release> | ||
</properties> | ||
|
||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>org.apache.maven.archetype</groupId> | ||
<artifactId>archetype-packaging</artifactId> | ||
<version>${archetype-packaging.version}</version> | ||
</extension> | ||
</extensions> | ||
</build> | ||
|
||
</project> |
47 changes: 47 additions & 0 deletions
47
connector-archetype-internal/src/main/resources/META-INF/maven/archetype-metadata.xml
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,47 @@ | ||
<archetype-descriptor | ||
xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0" | ||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0 https://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd" | ||
name="connector-internal-archetype"> | ||
|
||
<fileSets> | ||
<fileSet filtered="true" packaged="true" encoding="UTF-8"> | ||
<directory>src/main/java</directory> | ||
</fileSet> | ||
<fileSet filtered="true" packaged="true" encoding="UTF-8"> | ||
<directory>src/test/java</directory> | ||
</fileSet> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>src/main/resources</directory> | ||
</fileSet> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>element-templates</directory> | ||
</fileSet> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory></directory> | ||
<includes> | ||
<include>README.md</include> | ||
<include>LICENSE.txt</include> | ||
</includes> | ||
</fileSet> | ||
</fileSets> | ||
|
||
<requiredProperties> | ||
<requiredProperty key="connectorName"/> | ||
<requiredProperty key="name"> | ||
<defaultValue>${connectorName}</defaultValue> | ||
</requiredProperty> | ||
<requiredProperty key="artifactId"> | ||
<defaultValue>connector-${connectorName}</defaultValue> | ||
</requiredProperty> | ||
<requiredProperty key="groupId"> | ||
<defaultValue>io.camunda.connector</defaultValue> | ||
</requiredProperty> | ||
<requiredProperty key="version"> | ||
<defaultValue>${version}</defaultValue> | ||
</requiredProperty> | ||
<requiredProperty key="package"> | ||
<defaultValue>${groupId}.${connectorName}</defaultValue> | ||
</requiredProperty> | ||
</requiredProperties> | ||
</archetype-descriptor> |
5 changes: 5 additions & 0 deletions
5
connector-archetype-internal/src/main/resources/archetype-resources/LICENSE.txt
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 @@ | ||
Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under one or more contributor license agreements and licensed to you under a proprietary license. | ||
You may not use this file except in compliance with the proprietary license. | ||
The proprietary license can be either the Camunda Platform Self-Managed Free Edition license (available on Camunda’s website) or the Camunda Platform Self-Managed Enterprise Edition license (a copy you obtain when you contact Camunda). | ||
The Camunda Platform Self-Managed Free Edition comes for free but only allows for usage of the software (file) in non-production environments. | ||
If you want to use the software (file) in production, you need to purchase the Camunda Platform Self-Managed Enterprise Edition. |
45 changes: 45 additions & 0 deletions
45
connector-archetype-internal/src/main/resources/archetype-resources/README.md
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,45 @@ | ||
# Camunda Connector Template | ||
|
||
## Build | ||
|
||
```bash | ||
mvn clean package | ||
``` | ||
|
||
## API | ||
|
||
### Input | ||
|
||
```json | ||
{ | ||
"myProperty": "....." | ||
} | ||
``` | ||
|
||
### Output | ||
|
||
```json | ||
{ | ||
"result": { | ||
"myProperty": "....." | ||
} | ||
} | ||
``` | ||
|
||
### Error codes | ||
|
||
| Code | Description | | ||
| - | - | | ||
| FAIL | Message starts with 'fail' (ignoring case) | | ||
|
||
## Test locally | ||
|
||
Run unit tests | ||
|
||
```bash | ||
mvn clean verify | ||
``` | ||
|
||
## Element Template | ||
|
||
The element templates can be found in the [element-templates](element-templates) directory. |
106 changes: 106 additions & 0 deletions
106
...internal/src/main/resources/archetype-resources/element-templates/template-connector.json
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,106 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json", | ||
"name": "Template: Some Function", | ||
"id": "io.camunda.connectors.Template.v1", | ||
"description": "Describe this connector", | ||
"version": 1, | ||
"documentationRef": "https://docs.camunda.io/docs/components/modeler/web-modeler/connectors/available-connectors/template/", | ||
"icon": { | ||
"contents": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20height%3D%2218%22%20width%3D%2218%22%20viewBox%3D%220%200%2010%2010%22%20shape-rendering%3D%22geometricPrecision%22%3E%3Ctitle%3ESlack%3C%2Ftitle%3E%3Cg%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M0%2C0%20L0%2C10%20L10%2C10%20L10%2C0%20z%22%20fill%3D%22%23ecb12f%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E" | ||
}, | ||
"category": { | ||
"id": "connectors", | ||
"name": "Connectors" | ||
}, | ||
"appliesTo": [ | ||
"bpmn:Task" | ||
], | ||
"elementType": { | ||
"value": "bpmn:ServiceTask" | ||
}, | ||
"groups": [ | ||
{ | ||
"id": "authentication", | ||
"label": "Authentication" | ||
}, | ||
{ | ||
"id": "compose", | ||
"label": "Compose" | ||
}, | ||
{ | ||
"id": "output", | ||
"label": "Output Mapping" | ||
}, | ||
{ | ||
"id": "errors", | ||
"label": "Error Handling" | ||
} | ||
], | ||
"properties": [ | ||
{ | ||
"type": "Hidden", | ||
"value": "io.camunda:template:1", | ||
"binding": { | ||
"type": "zeebe:taskDefinition:type" | ||
} | ||
}, | ||
{ | ||
"label": "OAuth Token", | ||
"group": "authentication", | ||
"type": "String", | ||
"feel": "optional", | ||
"binding": { | ||
"type": "zeebe:input", | ||
"name": "token" | ||
}, | ||
"constraints": { | ||
"notEmpty": true | ||
} | ||
}, | ||
{ | ||
"label": "Message", | ||
"group": "compose", | ||
"type": "Text", | ||
"feel": "optional", | ||
"binding": { | ||
"type": "zeebe:input", | ||
"name": "data.message" | ||
}, | ||
"constraints": { | ||
"notEmpty": true | ||
} | ||
}, | ||
{ | ||
"label": "Result Variable", | ||
"description": "Name of variable to store the response in", | ||
"group": "output", | ||
"type": "String", | ||
"binding": { | ||
"type": "zeebe:taskHeader", | ||
"key": "resultVariable" | ||
} | ||
}, | ||
{ | ||
"label": "Result Expression", | ||
"description": "Expression to map the response into process variables", | ||
"group": "output", | ||
"type": "Text", | ||
"feel": "required", | ||
"binding": { | ||
"type": "zeebe:taskHeader", | ||
"key": "resultExpression" | ||
} | ||
}, | ||
{ | ||
"label": "Error Expression", | ||
"description": "Expression to handle errors. Details in the <a href=\"https://docs.camunda.io/docs/components/connectors/use-connectors/\" target=\"_blank\">documentation</a>.", | ||
"group": "errors", | ||
"type": "Text", | ||
"feel": "required", | ||
"binding": { | ||
"type": "zeebe:taskHeader", | ||
"key": "errorExpression" | ||
} | ||
} | ||
] | ||
} |
39 changes: 39 additions & 0 deletions
39
connector-archetype-internal/src/main/resources/archetype-resources/pom.xml
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,39 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.camunda.connector</groupId> | ||
<artifactId>connector-function-parent</artifactId> | ||
<version>0.14.3-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<name>${artifactId}</name> | ||
<description>${artifactId} for Camunda 8</description> | ||
<artifactId>${artifactId}</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<licenses> | ||
<license> | ||
<name>Camunda Platform Self-Managed Free Edition license</name> | ||
<url>https://camunda.com/legal/terms/cloud-terms-and-conditions/camunda-cloud-self-managed-free-edition-terms/</url> | ||
</license> | ||
<license> | ||
<name>Camunda Platform Self-Managed Enterprise Edition license</name> | ||
</license> | ||
</licenses> | ||
|
||
<dependencies> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
63 changes: 63 additions & 0 deletions
63
...chetype-internal/src/main/resources/archetype-resources/src/main/java/Authentication.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,63 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package ${package}; | ||
|
||
import io.camunda.connector.api.annotation.Secret; | ||
import java.util.Objects; | ||
import javax.validation.constraints.NotEmpty; | ||
|
||
public class Authentication { | ||
|
||
@NotEmpty private String user; | ||
|
||
@NotEmpty @Secret private String token; | ||
|
||
public String getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(String user) { | ||
this.user = user; | ||
} | ||
|
||
public String getToken() { | ||
return token; | ||
} | ||
|
||
public void setToken(String token) { | ||
this.token = token; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(token, user); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) return true; | ||
if (obj == null) return false; | ||
if (getClass() != obj.getClass()) return false; | ||
Authentication other = (Authentication) obj; | ||
return Objects.equals(token, other.token) && Objects.equals(user, other.user); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Authentication [user=" + user + ", token=" + token + "]"; | ||
} | ||
} |
Oops, something went wrong.