Thursday, 30 May 2013

The definitive guide to running Talend 5.3.0 from source - that doesn't work

I have spent vast amounts of man hours trying to get my copy of the Talend for Data Integration 5.3.0 source to compile and run without making changes to the original source.  I have finally managed to get an Eclipse RCP install to accept the source, with minor errors (5 errors all related to unimplemented methods).  Very hopeful and extremely enthusiastically I launched, only be disappointed... again...

I thought I'd at least share how I got the source loaded without ending up with over 200K errors to deal with.  Here's the most elegant of all my efforts...

Installation and prep:

So the first thing we need to do is install Talend for Data Integration 5.3.0 (you can get it here), and Eclipse RCP (you can get it here).  I thought I'd go for Eclipse Indigo R2, for no reason other that I already had a copy downloaded.  Install both of those, get them up and running and at peace with the fact that everything seem to work as it should.

Now before we got on to the fun stuff lets deal with the source.  After a couple of times trying to get this to work, I decided it might be easier on my internet bill if I downloaded a copy of the source from SVN and kept it locally.  It started making sense by the third day, while I was waiting for my seventh copy of the 3.09Gb source to come down.   If I still lived in the US this would have probably not been an issue, but here in Australia we're just not that fast, or cheap, on the cable yet.
I use TortoiseSVN to deal with all my pesky SVN issues, it's simply the best in my opinion.  So I created a directory to hold my copy of the 5.3.0 source, I pointed Tortoise to http://talendforge.org/svn/tos/tags/release-5_3_0 and true to it's name, Tortoise took what seemed forever but finally got my copy safe and sound.

So now that I had both Talend and Eclipse running, and my copy of the source handy, it's on to the good stuff...

Setting up the Target Platform:

You can shut down Talend for this, but get Eclipse running if it's not, and open the Preferences.

Now browse to or search for the Target Platform (Plug-in Development -> Target Platform)
Where we want to add a Target Platform, so hit the Add button

 Hit the Add button, again...

Select Installation, since we want to build this Target Platform from the copy of Talend we installed earlier, and click Next.

Browse to your Talend for Data Integration installation and hit the Next button.

Click on Finish.

You can name your new Target Platform anything you like.  I have a slipping memory so I find it helpful to give it a relevant name.
From here click on the Arguments tab...
I found it better not to provide Program Arguments at this time.  It kinda clashes (duplicates) with the Program Arguments when (if) you set up a dedicated Runtime (discussed later).
Add the following VM Arguments: -Dosgi.requiredJavaVersion=1.5 -Xms512m -Xmx1536m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8

And hit the Finish button.
Allrighty then, we have our new Target Platform configured. All we need to do is select (click on) it to make it Active and hit the OK button.  Making it the Active Platform is quite important, make sure you don't miss this step.
You may want to grab a fresh cuppa coffee at this point, I did.

Importing the Source:

Next we want to import the source from the local copy we made.  You can of course get your source however you're most comfortable with.  I'll stick to my local copy.  So, from our prepared Eclipse environment, open the Import dialog (File -> Import).

(General -> Existing Projects into Workspace) and click Next.

Here you can browse to where your source is kept, and make sure to tick the "Copy projects in to workspace" option before you click Finish.  It gets pretty easy to loose your "safe" local copy of the source, and making any changes to code in your workspace will invalidate your local copy.

After waiting for the source to import and build, I was quite happy ending up with only 1,107 errors.  Things where looking good so far.


Knock those Errors out of the park!

To do this we're going to need a couple things.  So go ahead and download Mockito (here), Powermock (here) and Powermock's Junit4-rule module (jar is here).  You may need to get the files out of the zip archives, and your aim is to have these three files ready; mockito.jar, powermock-mokito-1.5-full.jar, and powermock-module-junit4-rule-1.5.jar

org.talend.testutils

I have seen claims that this is "included" and we shouldn't be needing to do this but I pretty much searched everywhere and tried everything to find org.talend.testutils, which is quite an important requirement if we want to get our error count down, but I couldn't find it anywhere.  So let's just build it why don't we...

In Eclipse open the Plug-in from Existing JAR Archives wizzard.  Click on (File -> New -> Other)

Then select (Plug-in Development -> Plug-in from Existing JAR Archives)

Click on Add External and add those three jar files mentioned earlier.
Then click next.

It's quite important to name the plug-in correctly.  I wasn't sure of the version so I just left that for now.  When you click Finish, the Plugin Overview page will open automagically.

Make sure to select "This plug-in is a singleton" and click Save, or you'll end up with a couple of extra errors.

com.javamex

Go ahead and download classmexer (zip is here) and extract classmexer.jar from the zip archive. Open the Plug-in from Existing JAR Archives wizzard as before (File -> New -> Other) then (Plug-in Development -> Plug-in from Existing JAR Archives).  This time adding the classmexer.jar file we just acquired.

Name your Plug-in as above, click Finish and MAKE SURE you select "This Plug-in is a singleton" and save when the Overview window opens.

org.eclipse.wst.xsd.ui

I'm not sure why the next three plug-ins we're going to create does not get picked up by our environment when they are installed.  Never the less, the only way to get rid of the errors they are responsible for was (to me) by explicitly creating them in my project.
The first I found was already there with my Eclipse RCP installation.

So using the same method described (twice) above, I created a new plug-in from existing jar archive and ended up with the following...
Note how I made sure "This plug-in is a singleton" is selected.

Two more, we're almost there!

We need two more plugins, but these we need to install first before we can get to their jars. So from the Eclipse menu, go (Help -> Install New Software)

We need to add the WTP repository.
So click on the Add button next to the Work with dropdown and add http://download.eclipse.org/webtools/repository/indigo/ in the location field, the click OK.

From thenewest WTP SDK, select "Eclipse Java Web Developer Resources for Plug-in Developers" and click Next.
Hit Next on the Install Details dialog, Accept whichever license agreement terms, and Finish the install.

Our two new jar files installed!

Now, add those two individually.  I added UI first...

... and then Validation.

No matter which order, as long as you don't forget...

I got a few unexpected errors after adding each of the last two plug-ins... not sure what to make of them.

Final steps

Look Eclipse is a cool tool, but for some reason not everything happens automagically.  I found that I still had to go and convince some of new stuff to take action.  Here's a few examples;

Hover, then click on "Add 'org.junit.runner' to import packages"

Hover, click on "Add 'com.javamex.classmexer' to import packages"

Then, lastly, I had to make one (ok 5) small change to a class.  This puzzles me tho because why would I need to do that?  Anyway, if I wanted to run this beast I had to... and that was reason enough.
I just added the unimplemented methods...

...and then, for a moment so glorious I could hear angels sing...
 I had no errors.

Run Time!

So as you can imagine, very enthusiastically I opened plugin.xml in org.talend.rcp and hit the "Launch an Eclipse application" link to do a mock run only to initialize a Run Configuration (terminated the run on the Agreement dialog). 

I opened the Run Configurations dialog...

and properly named and checked everything...

...see, I told you before how the Program arguments can duplicate... so I fixed that too.

And holding my breath I hit the Run button.

Yaaaaaay!!!

Aaaww!

And that is how I lost all my hair.

3 comments:

  1. Really nice stuff..Saved lot of my time..Thank you so much

    ReplyDelete
    Replies
    1. Same process worked for Talend 5.5 also

      Delete
    2. It worked for me...able to create Talend jobs..

      Delete