Create the POM file to generate sources

Talend Software Development Life Cycle Best Practices Guide

author
Talend Documentation Team
EnrichVersion
6.5
EnrichProdName
Talend Big Data
Talend MDM Platform
Talend Data Integration
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend Data Management Platform
task
Design and Development
Deployment
Administration and Monitoring
EnrichPlatform
Talend Repository Manager
Talend Studio
Talend Administration Center
Talend JobServer
Talend CommandLine
Talend Artifact Repository

Procedure

  1. Create a POM file (in XML format), called BuildJob_pom.xml for example, holding information on Maven project and its configuration and the instructions to generate your sources. It could look as follows (note that the parts in italics need to be modified):
    • Recommended: Local generation (script mode)

      When you choose to generate sources in script mode (local-generate), you do not need to launch the Talend CommandLine as it will be launched and shut down automatically, but you do need to specify in this POM file:
      • properties linked to the Talend CommandLine used to generate the sources:
        • <product.path>: path to Talend CommandLine

        • <commandline.workspace>: path to the workspace which is the base folder where all the projects were checked out before

        • <projectsTargetDirectory>: folder where all the sources of your project will be generated

        • <deploy.version>: defines the version of the items to be published on Nexus and applies -SNAPSHOT tags to these items (can be Jobs, Routines, Test cases, etc.). This parameter affects the output result of the generation.

          Example of snapshot version: <deploy.version>1.0.0-SNAPSHOT</deploy.version>

          Example of release version: <deploy.version>1.0.0</deploy.version>
          Tip: The only requirement is to store all projects in the workspace folder, this means you have the possibility create a Jenkins task that clones the projects and copy them (folders only) to the workspace.
      • the configuration parameters that allow you to customize the execution:
      • the Nexus repository where the CI Builder plugin is stored: the parameter <pluginRepository> allows you to specify the URL of the Nexus thirdparty repository in which you have uploaded the CI Builder files.

      The Maven documentation of the CI Builder plugin is embedded in the CI Builder archive file, see the files in the <CIBuilder_home>/help folder for more information.

      <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>
      <groupId>org.talend</groupId>
      <artifactId>buildsources</artifactId>
      <version>A.B.C</version>
      
      <properties>
          <!-- Required. Commandline application workspace and Studio path, only for local(script) mode -->
          <commandline.workspace>commandline_workspace_path</commandline.workspace>   
          <product.path>studio_path</product.path>
          <!-- Optional. Specify target directory where generated sources will be stored -->
          <projectsTargetDirectory>${basedir}/projectSources</projectsTargetDirectory> 
          <!-- Optional. Specify version for the artifact to be built. Can be set for each Job independently -->
          <deploy.version>A.B.C-SNAPSHOT</deploy.version>
      </properties>
      
      <build>
          <plugins>
              <plugin>
                  <groupId>org.talend</groupId>
                  <artifactId>ci.builder</artifactId>
                  <version>A.B.C</version>
                  <executions>
                      <execution>
                          <phase>generate-sources</phase>
                          <goals>
                              <!-- local(script) mode -->
                              <goal>local-generate</goal>
                          </goals>
                          <configuration>
                              <!-- Optional. Specify CommandLine user -->
                              <commandlineUser>jobbuilder@talend.com</commandlineUser>
                              <!-- Optional. Jvm Parameters for local(script) mode -->
                              <!-- <jvmArguments>-ea -Xms512m -Xmx1300m -XX:+CMSClassUnloadingEnabled -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:+HeapDumpOnOutOfMemoryError</jvmArguments> -->
                              <!-- Optional. Parameter used to filter on specific Job status (TEST, DEV, PROD, etc)  -->
                              <!-- <itemFilter>(status=TEST)or(status=PROD)or(status="")</itemFilter> -->
                          </configuration>
                      </execution>
                  </executions>
              </plugin>
          </plugins>
      </build>
      
      <pluginRepositories>
          <!-- everything through Maven Central Proxy -->
              <pluginRepository>
                  <id>Central</id>
                  <name>Central</name>
                  <url>http://<host>:<port>/nexus/content/repositories/central</url>
              </pluginRepository>
              <pluginRepository>
                  <id>thirdparty</id>
                  <name>thirdparty</name>
                  <url>http://<host>:<port>/nexus/content/repositories/thirdparty/</url>
              </pluginRepository>
      </pluginRepositories>
      
      </project>
    • Alternative: Remote generation (server mode)

      When you choose to generate sources in server mode (generate), you need the Talend CommandLine to be launched (the best practice would be to have it installed as a service) and you then need to specify its access parameters in the GenerateSources Jenkins project.

      <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>
      <groupId>org.talend</groupId>
      <artifactId>buildsources</artifactId>
      <version>A.B.C</version>
      <packaging>pom</packaging>
      
      <build>
          <plugins>
              <plugin>
                  <groupId>org.talend</groupId>
                  <artifactId>ci.builder</artifactId>
                  <version>A.B.C</version>
                  <executions>
                      <execution>
                          <phase>generate-sources</phase>
                          <goals>
                              <!-- server mode -->
                              <goal>generate</goal>
                          </goals>
                          <configuration>
                          </configuration>
                      </execution>
                  </executions>
              </plugin>
          </plugins>
      </build>
      
      <pluginRepositories>
          <!-- everything through Maven Central Proxy -->
              <pluginRepository>
                  <id>Central</id>
                  <name>Central</name>
                  <url>http://<host>:<port>/nexus/content/repositories/central</url>
              </pluginRepository>
              <pluginRepository>
                  <id>thirdparty</id>
                  <name>thirdparty</name>
                  <url>http://<host>:<port>/nexus/content/repositories/thirdparty/</url>
              </pluginRepository>
      </pluginRepositories>
      
      </project>

      For more information on Maven life cycle and goals, see the Apache Maven documentation.

  2. You also have the possibility to customize some of the information that are generated by default for your project from Talend Studio, through the menu Project Settings > Build > Maven > Default > Project: from here you can edit the default <groupId> that will be used when publishing on Nexus, the <version> as well as other default information.