Set a maven URL for external Library dependency for job/routine

Highlighted
Five Stars

Set a maven URL for external Library dependency for job/routine

From docs, forum and blogs the only ways to add a dependency to an external jar are:

  • edit routine libraries, by adding a local jar
  • use tLibraryLoad on a job, to load a local jar
  • someone talks about editing project pom, but there are no details about it.

My question regards both open and enterprise versions.

Methods 1 and 2 would be fine only if you work alone. With many users with different workspaces sharing a git project both approaches won't work since the libraries are referenced by their local path which won't exists for other users.
So each user must download by itself the jars and put them manually into the right path. This is awful: possible mistakes in jar version, lot of manual work.. and even worse: by definying dependencies on a single routine/job if you develop new objects with same dependencies you must repeat the process of definying the dependencies.
I would like new users to open project, discovering needed jars automatically through a well-built maven pom file and installing only needed jars with the exact versions specified on poms.
Can you explain how to modify project or job pom files (or even routine pom which is hidden in studio) to edit maven dependencies and add jars as maven urls?
No clue on official docs to explain how to do It. What are the differencies in editing these two files?
Also, can you explain how to add additional maven repositories to user_settings xml?
I have many customers using Talend both with subscription and Open. I would like to find a solution for both situations.
Thanks.

Moderator

Re: Set a maven URL for external Library dependency for job/routine

Hello,

Talend 6 uses Apache Maven commands to build jobs and routes/service and uses Sonatype Nexus to share libraries for each Studio/command line and to store jobs for nexus jobs on TAC :Job Conductor and route/services for TAC: ESB Conductor.

To resolve library dependency issues on each Studio/CommandLine, Nexus repository should be configured on TAC > configuration > custom libraries. Local repositories are defined in studio\configuration\maven_user_settings.xml for Studio and cmdline\studio\configuration\maven_user_settings.xml for CommandLine. By default the local repository path is (cmdline) /studio/configuration/.m2/repository.

nexussyncup.pngsyncup.png

When Talend Studio build Jobs or routes/services, it uses maven commands specified in POM file (A POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project).  The Talend products allow us to customize the pom files and store in SVN or Git repository to share with other Studio instances and command line process.

[Project Settings] Build > Maven > Default; These script templates apply to all Jobs in the root folder and all sub-folders except those with their own build script templates set up at [Project Settings] Build > Maven > Setup custom scripts by folder.

  1. Project – project POM

SVN : [repository]/trunk/.settings/org.talend.designer.maven.ui.prefs

GIT: [repository]/<git url id>/<git branch>/<current project>/.settings/org.talend.designer.maven.ui.prefs

  1. Standalone Job – POM_[jobname/route/service].xml

SVN : [repository]/trunk/.settings/org.talend.designer.maven.job.prefs

GIT : [repository]/<git url id>/<git branch>/<current project>/.settings/ org.talend.designer.maven.job.prefs

* Routes and services are built as standard job and use the same pom files.

mavenpomfile.png

 

Let us know if this online user guide helps.

https://help.talend.com/reader/HqPypUO_cLctKv_dAWcgFw/9WDYGy~~HiY~WRpzzy_UFQ

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: Set a maven URL for external Library dependency for job/routine

Hi,
I managed to install a dependency both in local maven and in Nexus custom libs but I still have problems on my job.
I created a simple job with a tJava inside which uses org.apache.camel.Exchange class . This is Just an example to see if an the dependency imported in maven works: I configured camel-core/2.22.1 both in project pom and in standalone job pom, and It is installed on local maven repo and in Nexus. But neither of them gets the job working. The job outputs the error "could not resolve org.apache.camel.Exchange". Is It possible that the dependency doesn't bind to the job? No clue or how to do It on docs and forums. Can you help me?