Integrating 3rd Party Version Control Tools with JDeveloper

Codeless Integration of 3rd Party Tools with JDeveloper


Written by Shay Shmeltzer
Oracle Corporation May 2005

Important Note

Since this article was created a new Subversion extension has started shipping from Oracle - for integration with Subversion please refer to the Subversion Developer Guide. This document can however be used for integration of other version management tools and as an intro to the external toole option in JDeveloper.

Introduction

Oracle JDeveloper 10.1.3 developer preview comes with built in support for CVS and Clearcase as source control management tools, offering exceptional support for working with these code repositories. But what can you do if you need to use another version control tool?
One option is to use the JDeveloper Extension SDK to build an extension that will integrate JDeveloper with your tools. But building such an extension, although not a complex task, will require you to learn the JDeveloper development API. In this how-to I'll describe a quick and dirty way to build basic integration of third party tools that offer a command line interface into JDeveloper. All this without writing a single line of Java code.

Sounds too good to be true? - Let me introduce you to the "External Tools" menu option.

The "External Tools" menu option (located in the tools menu option) provides a dialog that lets you add calls to the command line of external tools. It also allows you to provide parameters from the JDeveloper environment to the command line. You can then add menu and context menu options to activate your extension.

In this how-to I'll show you how to integrate with Subversion, but the concepts explained here can be applied to any other tool.

Setting up Subversion

Subversion is an open-source version control product that you can get at http://subversion.tigris.org/. For more information about Subversion and services from its primary sponsor, go to http://www.collab.net/subversion.

After installing subversion on your machine, the first operation you'll probably want to do is create a subversion repository (unless you are going to connect to an existing repository). To do this issue the following command from the command line prompt:

Svnadmin create c:\svnrep

(c:\svnrep is the directory where you want the repository to be located).

Adding a Subversion Command to JDeveloper

Now that you have a repository, the next logical step is to import a project into this repository. Let's add the ability to do project imports directly from the JDeveloper development environment.

Activate the External Tools option and click the "New" button to create a new command.

In the dialog that comes up choose "External Program" in step 1. In Step 2 fill out the following details:

For program executable - svn.

For Arguments - write import and then press the insert button and from the list select "Project Directory" then you need to add a pointer to your repository in our example this will be: file:///c:/svnrep .

The last argument should be a message that you provide when importing the module, so add -m and then click the insert button and choose Prompt (place the prompt between double quotes to handle spaces).

The complete arguments parameter should look like:

import ${project.dir} file:///c:/svnrep -m "${prompt}"

For the run directory click the insert button and add the project directory.

The next step lets you add a caption for the menu option "SVN Import Project" is a good fit here. You can also specify a tooltip and an icon for your command.

In the next step you specify where you want the menu option to appear, I specified here that the option should appear in the navigator context menu. And in the next step we can specify when this option needs to be on - I chose "Always".

To test your new command, create a simple project in JDeveloper - stand on the project node - right click and choose the new "svn Import" option you have just added. You can see the svn command that was issued and the results in the log window, and your code should now be checked-in inside the Subversion repository.

Checking-out a Module

We'll skip adding a check-out project option to JDeveloper, instead just do it manually from a command line.

The command to issue from the command line is:

Svn checkout file:///c:/svnrep Project1.jpr

To use the code you just checked out in JDeveloper, create a new workspace without a project. Then, choose file->open and locate the jpr file for the project you just checked out.

Adding More Subversion Commands

The next three commands that we want to add to JDeveloper will enable us to Add, Update and Commit files from the repository.

For the Add option the command attributes should be:

add ${file.path} file:///c:/svnrep

Add the menu to the Navigator context menu, and in the integration select "When a file is selected or open in the code editor"

Similarly add the Update command - which gets the latest copy of the code from the repository to your code directory:

The arguments for this command are:

update ${file.path}

Add the menu to the Navigator context menu, and in the integration select "When a file is selected or open in the code editor"

For the commit command - that checks in a file after you changed it -the arguments are:

commit -m "${prompt}" ${file.path}

Again add the menu to the Navigator context menu, and in the integration select "When a file is selected or open in the code editor".

In a similar way you can also add the Diff command of Subversion, which allows you to compare to a specific version of the code. Here are the attributes in the JDeveloper command:

diff --revision "${prompt}" ${file.path}

Another useful command of Subversion is the Status command, which let you check the status of the file in the repository compared to your local copy without actually updating the local copy. Here are the attributes in the JDeveloper command:

status --verbose ${file.path}

Now you are ready to develop and use Subversion. Have a look at this on-line demo to see a basic working scenario.

Conclusion

This paper showed you the power of the "External Tool" menu option in JDeveloper as a simple and fast way to add integration between JDeveloper and other tools. For more powerful integration, check out the JDeveloper Extension SDK and the code samples that come with it.

false ,,,,,,,,,,,,,,,