Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(monorepo): add archetype for quick creation of new connectors #166

Merged
merged 4 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions add_new_connector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

CONNECTORS_DIR='connectors'

CONNECTOR_NAME=${1}
ARTIFACT_NAME="connector-${CONNECTOR_NAME}"

VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

# Using old (3.1.0) version due to a bug in the newer one (3.2.1)
# https://issues.apache.org/jira/browse/ARCHETYPE-584
mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.0:generate \
-DarchetypeGroupId=io.camunda.connector \
-DarchetypeArtifactId=connector-archetype-internal \
-DarchetypeVersion=${VERSION} \
-DinteractiveMode=false \
-DconnectorName=${CONNECTOR_NAME} \
-DoutputDirectory=${CONNECTORS_DIR}

# Rename directory to follow convention
mv "${CONNECTORS_DIR}/${ARTIFACT_NAME}" "${CONNECTORS_DIR}/${CONNECTOR_NAME}"
sed "s/${ARTIFACT_NAME}/${CONNECTOR_NAME}/" ${CONNECTORS_DIR}/pom.xml \
| diff -p ${CONNECTORS_DIR}/pom.xml /dev/stdin | patch
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,31 @@
<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>${archetypeVersion}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<name>${artifactId}</name>
<description>${connectorName} cnnector 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>

</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