Using TortoiseSVN with NWDS for NW 7.0
In this post I will show how we can setup and work with a popular code source and revision control tool — TortoiseSVN — together with the NetWeaver Developer Studio for AS version 7.0. Normally, you should take advantage of NetWeaver Developer Infrastructure (NWDI) when developing with Java in NWDS, which takes care of revision control for you (among other things). But to setup a fully functioning NWDI is not always an option. Sometimes you just need to be able to revert to or compare a file in your project with its version in the repository. Moreover, you are not always develop using Development Components (DCs) architecture required by NWDI. All this, naturally, might get you thinking about using an SVN repository to track changes to your NWDS projects. The problem is that, unlike the recent NWDS for AS 7.3, the older NWDS for AS 7.0 (in my case 7.0.25) is built on an old Eclipse version 2.1.2, which does not have many SVN plugins. The solution to the problem is to use an external SVN client to keep track of changes in the NWDS workspace, without Eclipse being aware of it.
Until recently, the problem with this solution was that SVN protocol required an .SVN folder with metadata being placed in every folder of the project. When working with some type of projects like WDJ (or with DCs in Local Development), NWDS has to copy some contents around (gen* and bin folders) and recreate some folders upon every build. This caused, SVN clients to complain (since .SVN folders were copied as well). Fortunately, the recent versions of SVN protocol specify one top-level .SVN folder containing all of the SVN metadata for the project. This made it a breeze to be able to use an external SVN client with any type of NWDS project.
Download and install Tortoise SVN client, it integrates seamlessly with Windows file explorer interface.
I assume we are going to create a new NWDS workspace under the path c:\svn\workspace. I also assume you have an SVN repository set up on a remote server. Use SVN Repo Browser from the context menu in c:\svn folder to browse to the root folder of the SVN repository where you want to import your workspace.
Create a remote folder workspace.
Once the workspace (remote) folder has been created, check it out to your local c:\svn\workspace directory. You should now have a SVN controlled workspace directory ready for NWDS projects.
Start NWDS with -data argument pointing to the c:\svn\workspace directory (copy NWDS shortcut, right click on the new shorcut, select Properties). NWDS will complete the setup for the new workspace. We will create a simple WDJ and Java projects for illustration purposes. Java project has a POJO (Person.java) and WDJ project imports this POJO as Java Bean Model and maps it all the way to the visual controller in the main Web Dynpro component. This is how the project files look in the Resource Perspective of the NWDS.
Notice that in the WDJ project we have bin, gen_ddic, gen_wdp folders that will be populated by WDJ at compile time (thus they should not be included in SVN).
Before we go futher, you can add some useful shortcuts to the context menu of TortoiseSVN by selecting TortoiseSVN –> Settings, then General –> Context Menu from the context menu. You can, for example, add Check for modifications to the context menu, since you’ll probably use it often.
The first thing we want to do is to add .metadata folder in our workspace to SVN ignore list. This is were NWDS stores all the workspace metadata files and it could be quite voluminous and contain many subfolders. To do it, select c:\workspace\.metadata folder and select TortoiseSVN –> Add to ignore list –> .metadata.
Then add Java project to SVN control by selecting it and selecting TortoiseSVN –> Add… from context menu. You can deselect all of the .class files (or any other files or directories that you don’t want to have under SVN control).
Do the same with WDJ project, I don’t add any bin, gen_ddic, or gen_wdp folders to version control since they are automatically generated by WDJ.
To commit project files to SVN, select SVN Commit… from the context menu of workspace root folder, then select all but non-versioned (ignored) files and select Commit… from the context menu.
Enter the commit comment.
And TortoiseSVN commits the selected files to the remote repository.
If you decided not to add some folders to SVN, you should probably add them to the ignore list now. This can also be done for any non-versioned entires from the Commit… or Check for modifications screens as well. Do not forget to commit the changes to the ignore list.
As an exercise, let’s try to modify one of our projects slightly and see if we can the difference with the committed version. We add a comment to the POJO in the Java project. If we then select the project and choose Check for modifications, we see that the Java class was modified and we can see where exactly if we select Compare with base from the context menu.
TortoiseSVN is a great tool, here I have just shown how easy it is to use it together with NWDS 7.0 to add version control to local projects (or DCs without NWDI). Also check out WinMerge, which works well with TortoiseSVN, to compare files.