An open API service indexing awesome lists of open source software.

https://github.com/cdapio/cdap-maven-plugin

Collection of CDAP Maven Plugins
https://github.com/cdapio/cdap-maven-plugin

cdap create-plugin-json maven-plugin

Last synced: 3 months ago
JSON representation

Collection of CDAP Maven Plugins

Awesome Lists containing this project

README

          

# CDAP Maven Plugin

Join CDAP community [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

This Maven Plugin has 4 goals:
* `mvn cdap:create-plugin-json`
* Generates a CDAP Plugin JSON file
* `mvn cdap:create-plugin-spec-json`
* Generates a `spec.json` file
* `mvn cdap:package-artifacts-for-hub`
* Moves artifacts to a user specified output dir
* Note: cannot be run alone
* `mvn cdap:create-pipeline-json`
* Extracts configuration from exported pipelines
* Suitable for Hub

## Maven Goals

1. [Create Plugin Json](#create-plugin-json)
2. [Create Plugin Spec JSON](#create-plugin-spec-json)
3. [Move Artifact Files](#move-artifact-files)
4. [Extract Configuration From Exported Pipelines ](#extract-configuration-from-exported-pipelines)

### Create Plugin Json

This goal generates the cdap plugin json file. The maven goal is `create-plugin-json`.

To run only the goal use:

```mvn cdap:create-plugin-json```

The generated file will be placed in the `${project.build}` directory.

#### Configurations

| Configuration | Required | Default | Description |
| :------------ | :------: | :----- | :---------- |
| **cdapArtifacts** | **Y** | N/A | Specifies all the parent CDAP artifacts and scope this plugin is applicable for.|
| **widgetsDirectory** | **N** | ```${project.dir}/widgets``` | Specifies alternate widgets directory.|
| **docsDirectory** | **N** | ```${project.dir}/docs``` | Specifies alternate documentation directory.|
| **iconsDirectory** | **N** | ```${project.dir}/icons``` | Specifies alternate icons directory.|

#### Example POM

```

co.cask
1.1.3
cdap-maven-plugin


system:cdap-data-pipeline[4.0.0,9.0.0-SNAPSHOT)
system:cdap-data-streams[4.0.0,9.0.0-SNAPSHOT)




create-artifact-config
prepare-package

create-plugin-json


```

#### Output
```
[INFO] ------------------------------------------------------------------------
[INFO] Building Trash Sink 1.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cdap-maven-plugin:1.0-SNAPSHOT:create-plugin-json (default-cli) @ trash-plugin ---
[INFO] ------------------------------------------------------------------------
[INFO] CDAP Plugin JSON
[INFO] ------------------------------------------------------------------------
[INFO] Project : Trash Sink
[INFO] Group ID : co.cask
[INFO] Artifact ID : trash-plugin
[INFO] Version : 1.1.0-SNAPSHOT
[INFO] Base Directory : /Users/nitin/Work/Devel/plugin-json-test
[INFO] Build Directory : /Users/nitin/Work/Devel/plugin-json-test/target
[INFO] Widgets Directory : /Users/nitin/Work/Devel/plugin-json-test/widgets
[INFO] Docs Directory : /Users/nitin/Work/Devel/plugin-json-test/docs
[INFO] CDAP Artifacts
[INFO] system:cdap-data-pipeline[4.0.0,9.0.0-SNAPSHOT)
[INFO] system:cdap-data-streams[4.0.0,9.0.0-SNAPSHOT)
[INFO] ------------------------------------------------------------------------
[INFO] Successfully created : trash-plugin-1.1.0-SNAPSHOT.json
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.026 s
[INFO] Finished at: 2017-03-19T03:21:38-07:00
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------
```

### Create Plugin Spec JSON

This goal generates the `spec.json` file. The maven goal is `create-plugin-spec-json`

To run only the goal use:

```mvn cdap:create-plugin-spec-json```

The generated file will be placed in the ```${project.build}``` directory.

#### Configuration

| Configuration | Required | Default | Description |
| :------------ | :------: | :----- | :---------- |
| **isPipeline** | **N** | ```false``` | Specifies if Spec.json is for a pipeline.|
| **actionType** | **N** | ```one_step_deploy_plugin``` | Specifies actionType - needs to be `create_pipeline_draft` if isPipeline true.|
| **scope** | **N** | ```user``` | Artifact scope.|
| **version** | **N** | ```${project.version}``` | Artifact version.|
| **cdapArtifacts** | **Y** | N/A | Specifies all the parent CDAP artifacts and scope this plugin is applicable for.|
| **label** | **N** | ```${project.name}``` | Short description that will be displayed to users during the install process.|
| **actionType** | **Y** | ```one_step_deploy_plugin``` | Action specification type.|
| **description** | **N** | ```${project.description}``` | Plugin description.|
| **author** | **N** | ```${project.author}``` | Plugin author.|
| **org** | **N** | ```${project.org}``` | Plugin author organisation.|
| **categories** | **N** | N/A | List of Categories.|
| **buildDirectory** | **N** | ```${project.build.directory}``` | Target directory for the `spec.json` file.|
| **artifactId** | **N** | ```${project.artifactId}``` | Used to reference the config (json) file name.|
| **additionalActionArguments** | **N** | N/A | List of key/value parameters to include in the Action.|

**NOTE: Categories affect the display of the HUB - please include at the bare minimum the team and type of item**

#### Example POM

Including both `create-plugin-json` and `create-plugin-spec-json` goals

```

co.cask
1.1.3
cdap-maven-plugin


system:cdap-data-pipeline[6.0.0-SNAPSHOT,9.0.0-SNAPSHOT)
system:cdap-data-streams[6.0.0-SNAPSHOT,9.0.0-SNAPSHOT)

LiveRamp
LiveRamp
optional plugin description

cat1
cat2



jar
${project.artifactId}-${project.version}.jar


user



create-artifact-config
prepare-package

create-plugin-json
create-plugin-spec-json


```

Including only `create-plugin-spec-json` goal

```


co.cask
cdap-maven-plugin
1.1.3


system:cdap-data-pipeline[6.0.0-SNAPSHOT,9.0.0-SNAPSHOT)
system:cdap-data-streams[6.0.0-SNAPSHOT,9.0.0-SNAPSHOT)


cat1

create_pipeline_draft
true



create-artifact-config
prepare-package

create-plugin-spec-json



```

#### Output

```
[INFO] ------------------------------------------------------------------------
[INFO] CDAP Plugin JSON
[INFO] ------------------------------------------------------------------------
[INFO] Project : Adhoc SQL Plugin
[INFO] Group ID : co.cask
[INFO] Artifact ID : adhoc_sql
[INFO] Version : 0.1.0
[INFO] Base Directory : /Users/user1/code/cdap-plugins/lsh/misc/adhoc_sql
[INFO] Build Directory : /Users/user1/code/cdap-plugins/lsh/misc/adhoc_sql/target
[INFO] Widgets Directory : widgets
[INFO] Icons Directory : icons
[INFO] Docs Directory : docs
[INFO] CDAP Artifacts
[INFO] system:cdap-data-pipeline[6.0.0-SNAPSHOT,9.0.0-SNAPSHOT)
[INFO] system:cdap-data-streams[6.0.0-SNAPSHOT,9.0.0-SNAPSHOT)
[INFO] ------------------------------------------------------------------------
[INFO] Successfully created : adhoc_sql-0.1.0.json
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cdap-maven-plugin:1.1.1-SNAPSHOT:create-plugin-spec-json (create-artifact-config) @ adhoc_sql ---
[INFO] ------------------------------------------------------------------------
[INFO] CDAP Plugin JSON - Spec Json creator
[INFO] ------------------------------------------------------------------------
[INFO] specVersion : 0.1.0
[INFO] label : Adhoc SQL Plugin
[INFO] description : optional plugin description
[INFO] author : LiveRamp
[INFO] org : LiveRamp
[INFO] created : 1608720834834
[INFO] cdapVersion : [6.0.0-SNAPSHOT,9.0.0-SNAPSHOT)
[INFO] action type : one_step_deploy_plugin
[INFO] action label : Adhoc SQL Plugin
[INFO] action arg name : Adhoc SQL Plugin
[INFO] action arg version : 0.1.0
[INFO] action arg scope : user
[INFO] action arg config : adhoc_sql-0.1.0.json
[INFO] action arg jar : adhoc_sql-0.1.0.jar
[INFO] categories
[INFO] cat1
[INFO] cat2
[INFO] ------------------------------------------------------------------------
[INFO] Successfully created: spec.json
[INFO] ------------------------------------------------------------------------
```

### Move Artifact Files

This plugin aims to move built artifacts packages to a common user specified output directory in the format expected
by a CDAP HUB and HUB packaging/publishing tools.
The goal is useful in case you'd want to run CDAP publisher from that output directory.

The maven goal is `package-artifacts-for-hub`

#### Configuration

| Configuration | Required | Default | Description |
| :------------ | :------: | :----- | :---------- |
| **relativeOutputDir** | **Y** | "${project.build.directory}/packages/" | Specifies the Output Directory **Relative** to the module build directory|

Example `relativeOutputDir` value : `/../../../../packages/`

#### Using Directory Maven Plugin

To simplify the `relativeOutputDir` value the `directory-maven-plugin` should be used in the parent Pom

**Example of `directory-maven-plugin` plugin configuration to have in parent pom.xml**
```

org.commonjava.maven.plugins
directory-maven-plugin
0.3.1


directories

directory-of

initialize

parent_module.basedir

com.org.groupId
artifactId



```

Using this simplifies `relativeOutputDir` value to `${parent_module.basedir}/packages`.

If left to default value the output will be placed under the module build dir

#### Execution settings

The goal must be run after any pre-package goals specified. In order to do this the following execution settings need
to be applied.

```


package-artifacts-for-hub

move-artifacts
package

```

#### Example POM

```

co.cask
1.1.3
cdap-maven-plugin


system:cdap-data-pipeline[6.1.0-SNAPSHOT,7.0.0-SNAPSHOT)
system:cdap-data-streams[6.1.0-SNAPSHOT,7.0.0-SNAPSHOT)



jar
${project.artifactId}-${project.version}.jar


user
LiveRamp
LiveRamp
optional plugin description

${parent_module.basedir}/packages




create-plugin-json
create-plugin-spec-json

create-artifact-config
prepare-package



package-artifacts-for-hub

move-artifacts
package

```

#### Output

```
[INFO]
[INFO] --- cdap-maven-plugin:1.1.2-SNAPSHOT:package-artifacts-for-hub (move-artifacts) @ adhoc_sql ---
[INFO] Creating artifact output dir at: /Users/user1/code/cdap-plugins/lsh/misc/adhoc_sql/target/../../../../packages/adhoc_sql/0.1.0
[INFO] Copying adhoc_sql-0.1.0.jar to /Users/user1/code/cdap-plugins/lsh/misc/adhoc_sql/target/../../../../packages/adhoc_sql/0.1.0/adhoc_sql-0.1.0.jar
[INFO] Copying adhoc_sql-0.1.0.json to /Users/user1/code/cdap-plugins/lsh/misc/adhoc_sql/target/../../../../packages/adhoc_sql/0.1.0/adhoc_sql-0.1.0.json
[INFO] Copying spec.json to /Users/user1/code/cdap-plugins/lsh/misc/adhoc_sql/target/../../../../packages/adhoc_sql/0.1.0/spec.json
```

Packages moved to output directory:
```
- packages
- artifact-A
- 1.0.0
- artifact-A-1.0.0.jar
- artifact-A-1.0.0.json
- spec.json
- artifact-B
- 1.1.0
- artifact-B-1.1.0.jar
- artifact-B-1.1.0.json
- spec.json
- icon.json [Optional]
```

### Extract Configuration From Exported Pipelines

Maven goal to extract and rename an exported Pipeline JSON so that it is able to be published and consumed by a HUB

The goal is `create-pipeline-json`

#### Configuration
| Configuration | Required | Default | Description |
| :------------ | :------: | :----- | :---------- |
| **pipelineJsonFile** | **Y** | "" | Specifies the exported Json file|

Note: The pipelineJsonFile value needs to be the full path hence using `${project.baseDir}` will be needed.

E.g: `${project.basedir}/exported_jsonFile.json`

If the path is not correct you will see a

```
[ERROR] exported_jsonFile.json
```

#### Example POM

```

Test Exported Pipeline
co.cask
test_exported_pipeline
1.0.0
4.0.0


${project.basedir}

UTF-8




co.cask
1.1.3
cdap-maven-plugin

${basedir}/../exported_pipeline.json



create-artifact-config
prepare-package

create-pipeline-json





```

#### Output

A `exported_pipeline.json` file should be created in the specified path in `pipelineJsonFile` property.