Skip to content

Commit

Permalink
feat(monorepo): add archetype for quick creation of new connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
chillleader committed Dec 28, 2022
1 parent 96ef5f2 commit 472ab0d
Show file tree
Hide file tree
Showing 13 changed files with 539 additions and 0 deletions.
22 changes: 22 additions & 0 deletions add_new_connector.sh
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
33 changes: 33 additions & 0 deletions connector-archetype-internal/pom.xml
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>
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>
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.
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.
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"
}
}
]
}
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>
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 + "]";
}
}
Loading

0 comments on commit 472ab0d

Please sign in to comment.