Building components with Maven

To develop new components, Talend Component Kit requires a build tool in which you will import the component project generated from the starter.

You will then be able to install and deploy it to Talend applications. A Talend Component Kit plugin is available for each of the supported build tools.

talend-component-maven-plugin helps you write components that match best practices and generate transparently metadata used by Talend Studio.

You can use it as follows:

<plugin>
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${component.version}</version>
</plugin>

This plugin is also an extension so you can declare it in your build/extensions block as:

<extension>
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${component.version}</version>
</extension>

Used as an extension, the goals detailed in this document will be set up.

Maven lifecycle

The Talend Component Kit plugin integrates some specific goals within Maven build lifecycle. For example, to compile the project and prepare for deploying your component, run mvn clean install. Using this command, the following goals are executed:

Maven clean install

The build is split into several phases. The different goals are executed in the order shown above. Talend Component Kit uses default goals from the Maven build lifecycle and adds additional goals to the building and packaging phases.

Goals added to the build by Talend Component Kit are detailed below. The default lifecycle is detailed in Maven documentation.

Talend Component Kit Maven goals

The Talend Component Kit plugin for Maven integrates several specific goals into Maven build lifecycle.

To run specific goals individually, run the following command from the root of the project, by adapting it with each goal name, parameters and values:

$ mvn talend-component:<name_of_the_goal>[:<execution id>] -D<param_user_property>=<param_value>

Dependencies

The first goal is a shortcut for the maven-dependency-plugin. It creates the TALEND-INF/dependencies.txt file with the compile and runtime dependencies, allowing the component to use it at runtime:

<plugin>
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${component.version}</version>
  <executions>
    <execution>
      <id>talend-dependencies</id>
      <goals>
        <goal>dependencies</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Scan

The scan-descriptor goal scans the current module and optionally other configured folders to precompute the list of interesting classes for the framework (components, services). It allows to save some bootstrap time when launching a job, which can be useful in some execution cases:

<plugin>
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${component.version}</version>
  <executions>
    <execution>
      <id>talend-scan-descriptor</id>
      <goals>
        <goal>scan-descriptor</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Configuration - excluding parameters used by default only:

Name Description User property Default

output

Where to dump the scan result. Note: It is not supported to change that value in the runtime.

talend.scan.output

${project.build.outputDirectory}/TALEND-INF/scanning.properties

scannedDirectories

Explicit list of directories to scan.

talend.scan.scannedDirectories

If not set, defaults to ${project.build.outputDirectory}

scannedDependencies

Explicit list of dependencies to scan - set them in the groupId:artifactId format. The list is appended to the file to scan.

talend.scan.scannedDependencies

-

SVG2PNG

The svg2png goal scans a directory - default to target/classes/icons - to find .svg files and copy them in a PNG version size at 32x32px and named with the suffix _icon32.png to enable the studio to read it:

<plugin>
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${component.version}</version>
  <executions>
    <execution>
      <id>talend-svg2png</id>
      <goals>
        <goal>svg2png</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Configuration:

Name Description User property Default

icons

Where to scan for the SVG icons to convert in PNG.

talend.icons.source

${project.build.outputDirectory}/icons

workarounds

By default the shape of the icon will be enforce in the RGB channels (in white) using the alpha as reference. This is useful for black/white images using alpha to shape the picture because Eclipse - Talend Studio - caches icons using RGB but not alpha channel, pictures not using alpha channel to draw their shape should disable that workaround.

talend.icons.workaround

true

if you use that plugin, ensure to set it before the validate mojo otherwise validation can miss some png files.

Validating the component programming model

This goal helps you validate the common programming model of the component. To activate it, you can use following execution definition:

<plugin>
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${component.version}</version>
  <executions>
    <execution>
      <id>talend-component-validate</id>
      <goals>
        <goal>validate</goal>
      </goals>
    </execution>
  </executions>
</plugin>

It is bound to the process-classes phase by default. When executed, it performs several validations that can be disabled by setting the corresponding flags to false in the <configuration> block of the execution:

Name Description User property Default

validateInternationalization

Validates that resource bundles are presents and contain commonly used keys (for example, _displayName)

talend.validation.internationalization

true

validateModel

Ensures that components pass validations of the ComponentManager and Talend Component runtime

talend.validation.model

true

validateSerializable

Ensures that components are Serializable. This is a sanity check, the component is not actually serialized here. If you have a doubt, make sure to test it. It also checks that any @Internationalized class is valid and has its keys.

talend.validation.serializable

true

validateMetadata

Ensures that components have an @Icon and a @Version defined.

talend.validation.metadata

true

validateDataStore

Ensures that any @DataStore defines a @HealthCheck and has a unique name.

talend.validation.datastore

true

validateDataSet

Ensures that any @DataSet has a unique name. Also ensures that there is a source instantiable just filling the dataset properties (all others not being required). Finally, the validation checks that each input or output component uses a dataset and that this dataset has a datastore.

talend.validation.dataset

true

validateComponent

Ensures that the native programming model is respected. You can disable it when using another programming model like Beam.

talend.validation.component

true

validateActions

Validates action signatures for actions not tolerating dynamic binding (@HealthCheck, @DynamicValues, and so on). It is recommended to keep it set to true.

talend.validation.action

true

validateFamily

Validates the family by verifying that the package containing the @Components has a @Icon property defined.

talend.validation.family

true

validateDocumentation

Ensures that all components and @Option properties have a documentation using the @Documentation property.

talend.validation.documentation

true

validateLayout

Ensures that the layout is referencing existing options and properties.

talend.validation.layout

true

validateOptionNames

Ensures that the option names are compliant with the framework. It is highly recommended and safer to keep it set to true.

talend.validation.options

true

validateLocalConfiguration

Ensures that if any TALEND-INF/local-configuration.properties exists then keys start with the family name.

talend.validation.localConfiguration

true

validateOutputConnection

Ensures that an output has only one input branch.

talend.validation.validateOutputConnection

true

validatePlaceholder

Ensures that string options have a placeholder. It is highly recommended to turn this property on.

talend.validation.placeholder

false

locale

The locale used to validate internationalization.

talend.validation.locale

root

Generating the component documentation

The asciidoc goal generates an Asciidoc file documenting your component from the configuration model (@Option) and the @Documentation property that you can add to options and to the component itself.

<plugin>
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${component.version}</version>
  <executions>
    <execution>
      <id>talend-component-documentation</id>
      <goals>
        <goal>asciidoc</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Name Description User property Default

level

Level of the root title.

talend.documentation.level

2 (==)

output

Output folder path. It is recommended to keep it to the default value.

talend.documentation.output

${classes}/TALEND-INF/documentation.adoc

formats

Map of the renderings to do. Keys are the format (pdf or html) and values the output paths.

talend.documentation.formats

-

attributes

Asciidoctor attributes to use for the rendering when formats is set.

talend.documentation.attributes

-

templateEngine

Template engine configuration for the rendering.

talend.documentation.templateEngine

-

templateDir

Template directory for the rendering.

talend.documentation.templateDir

-

title

Document title.

talend.documentation.title

${project.name}

version

The component version. It defaults to the pom version

talend.documentation.version

${project.version}

workDir

The template directory for the Asciidoctor rendering - if 'formats' is set.

talend.documentation.workdDir

${project.build.directory}/talend-component/workdir

attachDocumentations

Allows to attach (and deploy) the documentations (.adoc, and formats keys) to the project.

talend.documentation.attach

true

htmlAndPdf

If you use the plugin as an extension, you can add this property and set it to true in your project to automatically get HTML and PDF renderings of the documentation.

talend.documentation.htmlAndPdf

false

Rendering your documentation

To render the generated documentation in HTML or PDF, you can use the Asciidoctor Maven plugin (or Gradle equivalent). You can configure both executions if you want both HTML and PDF renderings.

Make sure to execute the rendering after the documentation generation.

HTML rendering

If you prefer a HTML rendering, you can configure the following execution in the asciidoctor plugin. The example below:

  1. Generates the components documentation in target/classes/TALEND-INF/documentation.adoc.

  2. Renders the documentation as an HTML file stored in target/documentation/documentation.html.

<plugin> (1)
  <groupId>org.talend.sdk.component</groupId>
  <artifactId>talend-component-maven-plugin</artifactId>
  <version>${talend-component-kit.version}</version>
  <executions>
    <execution>
      <id>documentation</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>asciidoc</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin> (2)
  <groupId>org.asciidoctor</groupId>
  <artifactId>asciidoctor-maven-plugin</artifactId>
  <version>1.5.7</version>
  <executions>
    <execution>
      <id>doc-html</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>process-asciidoc</goal>
      </goals>
      <configuration>
        <sourceDirectory>${project.build.outputDirectory}/TALEND-INF</sourceDirectory>
        <sourceDocumentName>documentation.adoc</sourceDocumentName>
        <outputDirectory>${project.build.directory}/documentation</outputDirectory>
        <backend>html5</backend>
      </configuration>
    </execution>
  </executions>
</plugin>

PDF rendering

If you prefer a PDF rendering, you can configure the following execution in the asciidoctor plugin:

<plugin>
  <groupId>org.asciidoctor</groupId>
  <artifactId>asciidoctor-maven-plugin</artifactId>
  <version>1.5.7</version>
  <executions>
    <execution>
      <id>doc-html</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>process-asciidoc</goal>
      </goals>
      <configuration>
        <sourceDirectory>${project.build.outputDirectory}/TALEND-INF</sourceDirectory>
        <sourceDocumentName>documentation.adoc</sourceDocumentName>
        <outputDirectory>${project.build.directory}/documentation</outputDirectory>
        <backend>pdf</backend>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>org.asciidoctor</groupId>
      <artifactId>asciidoctorj-pdf</artifactId>
      <version>1.5.0-alpha.16</version>
    </dependency>
  </dependencies>
</plugin>

Including the documentation into a document

If you want to add some more content or a title, you can include the generated document into another document using Asciidoc include directive.

For example:

= Super Components
Super Writer
:toc:
:toclevels: 3
:source-highlighter: prettify
:numbered:
:icons: font
:hide-uri-scheme:
:imagesdir: images

include::{generated_doc}/documentation.adoc[]

To be able to do that, you need to pass the generated_doc attribute to the plugin. For example:

<plugin>
  <groupId>org.asciidoctor</groupId>
  <artifactId>asciidoctor-maven-plugin</artifactId>
  <version>1.5.7</version>
  <executions>
    <execution>
      <id>doc-html</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>process-asciidoc</goal>
      </goals>
      <configuration>
        <sourceDirectory>${project.basedir}/src/main/asciidoc</sourceDirectory>
        <sourceDocumentName>my-main-doc.adoc</sourceDocumentName>
        <outputDirectory>${project.build.directory}/documentation</outputDirectory>
        <backend>html5</backend>
        <attributes>
          <generated_adoc>${project.build.outputDirectory}/TALEND-INF</generated_adoc>
        </attributes>
      </configuration>
    </execution>
  </executions>
</plugin>

This is optional but allows to reuse Maven placeholders to pass paths, which can be convenient in an automated build.

You can find more customization options on Asciidoctor website.

Testing a component web rendering

Testing the rendering of your component configuration into the Studio requires deploying the component in Talend Studio. Refer to the Studio documentation.

In the case where you need to deploy your component into a Cloud (web) environment, you can test its web rendering by using the web goal of the plugin:

  1. Run the mvn talend-component:web command.

  2. Open the following URL in a web browser: localhost:8080.

  3. Select the component form you want to see from the treeview on the left. The selected form is displayed on the right.

Two parameters are available with the plugin:

  • serverPort, which allows to change the default port (8080) of the embedded server. Its associated user property is talend.web.port.

  • serverArguments, that you can use to pass Meecrowave options to the server. Learn more about that configuration at openwebbeans.apache.org/meecrowave/meecrowave-core/cli.html.

Make sure to install the artifact before using this command because it reads the component JAR from the local Maven repository.

Finally, you can switch the lang of the component UI (documentation, form) using language query parameter in the webapp. For instance localhost:8080?language=fr.

Changing the UI bundle

If you built a custom UI (JS + CSS) bundle and want to test it in the web application, you can configure it in the pom.xml file as follows:

<configuration>
  <uiConfiguration>
    <jsLocation>https://cdn.talend.com/myapp.min.js</jsLocation>
    <cssLocation>https://cdn.talend.com/myapp.min.css</cssLocation>
  </uiConfiguration>
</configuration>
This is an advanced feature designed for expert users. Use it with caution.

Generating the component archive

Component ARchive (.car) is the way to bundle a component to share it in the Talend ecosystem. It is an executable Java ARchive (.jar) containing a metadata file and a nested Maven repository containing the component and its dependencies.

mvn talend-component:car

This command creates a .car file in your build directory. This file can be shared on Talend platforms.

This command has some optional parameters:

Name Description User property Default

attach

Specifies whether the component archive should be attached.

talend.car.attach

true

classifier

The classifier to use if attach is set to true.

talend.car.classifier

component

metadata

Additional custom metadata to bundle in the component archive.

-

-

output

Specifies the output path and name of the archive

talend.car.output

${project.build.directory}/${project.build.finalName}.car

packaging

Specifies the packaging

-

${project.packaging}

This CAR is executable and exposes the studio-deploy command which takes a Talend Studio home path as parameter. When executed, it installs the dependencies into the Studio and registers the component in your instance. For example:

# for a studio
java -jar mycomponent.car studio-deploy /path/to/my/studio
or
java -jar mycomponent.car studio-deploy --location /path/to/my/studio

# for a m2 provisioning
java -jar mycomponent.car maven-deploy /path/to/.m2/repository
or
java -jar mycomponent.car maven-deploy --location /path/to/.m2/repository

You can also upload the dependencies to your Nexus server using the following command:

java -jar mycomponent.car deploy-to-nexus --url <nexus url> --repo <repository name> --user <username> --pass <password> --threads <parallel threads number> --dir <temp directory>

In this command, Nexus URL and repository name are mandatory arguments. All other arguments are optional. If arguments contain spaces or special symbols, you need to quote the whole value of the argument. For example:

--pass "Y0u will \ not G4iess i' ^"

Deploying to the Studio

The deploy-in-studio goal deploys the current component module into a local Talend Studio instance.

Table 1. Parameters
Name Description User property Default

studioHome

Path to the Studio home directory

talend.component.studioHome

-

studioM2

Path to the Studio maven repository if not the default one

talend.component.studioM2

-

You can use the following command from the root folder of your project:

$ mvn talend-component:deploy-in-studio -Dtalend.component.studioHome="<studio_path>"

Help

The help goal displays help information on talend-component-maven-plugin. Call mvn talend-component:help -Ddetail=true -Dgoal=<goal-name> to display the parameter details of a specific goal.

Table 2. Parameters
Name Description User property Default

detail

Displays all settable properties for each goal.

detail

false

goal

The name of the goal for which to show help. If unspecified, all goals are displayed.

goal

-

indentSize

Number of spaces per indentation level. This integer should be positive.

indentSize

2

lineLength

Maximum length of a display line. This integer should be positive.

lineLength

80

Scroll to top