704 WebSphere Studio Application Developer Version 5 Programming Guide Figure 22-1 CVSNT service configuration (Service Status page) On the Service Status page, stop the CVS services by clicking both Stop buttons. Click Repositories to switch to the page to configure our new repository. Select the Repository Prefix option because we want our repositories to be under a common root directory. This is just an organizational feature, and is not really mandatory for your own setups. You have to manually create a C:\Repositories directory in your file system before configuring it. Now click Add to create the new /RedBank repository and complete the dialog as shown in Figure 22-2. Figure 22-2 New repository path Click OK . A confirmation dialog informs you that C:/Repositories/RedBank does not exist. Click Ye s to create it. After you are done, the Repositories page should look like Figure 22-3. Note: CVS users must have the appropriate access rights to the repository directory structure (full control in Windows). Chapter 22. Using Concurrent Versions System 705 Figure 22-3 CVSNT service configuration (Repositories page) CVSNT uses either the domain or the local server directory for user authentication under the pserver protocol. You have to choose the correct value for your environment. This setting only applies if your machine is connected to a Windows domain. This specification is in the Advanced page (Figure 22-4). Figure 22-4 CVSNT service configuration (Advanced page) 706 WebSphere Studio Application Developer Version 5 Programming Guide Click Apply to commit your new repository. Switch back to the Service Status page and restart both CVS services (Figure 22-5). Figure 22-5 CVSNT service configuration (Service Status page) Configuring CVS in Application Developer The team support for CVS had some major improvements in Application Developer Version 5. What is new in Application Developer Version 5? These are the most important improvements in team support: CVS Repository Exploring perspective to browse the content of repositories CVS Console view showing messages returned from the CVS server Consistent CVS terms used throughout, for example, branch instead of stream File compression options for transferring files to the CVS repository Requirement that new resources must be explicitly added to CVS control Text/binary support by identifying what file types are text or binary Synchronization of outgoing change optimizations (only outgoing changes are synchronized, which reduces network traffic) Showing of CVS decorators as visual indicators next to resources This list does not include all the new features, but points to the major differences compared to previous versions of WebSphere Studio products. Chapter 22. Using Concurrent Versions System 707 CVS preferences Before you start working with CVS, you should look through the CVS preferences. Select Windows -> Preferences and expand the Team section (Figure 22-6). Figure 22-6 CVS preferences Also expand the CVS section and verify the settings of the subsections. For example, you can change these options: Show the CVS Console when there is output Name of the CVS server (in case you renamed the server during installation) Keyword expansion It is interesting to get the versioning information that is inside of CVS in the Javadoc that is created for each file. One way to accomplish this is through keyword expansion. On the CVS preferences page, set Default keyword substitution to ASCII with keyword expansion (-kkv) . Some of the available keywords (case sensitive) are: – $RCSfile$—Adds the file name without the path 708 WebSphere Studio Application Developer Version 5 Programming Guide – $Revision$—Adds the latest version number – $Date$—Adds the date and time when the last revision was checked in – $Author$—Adds the name of the author – $Id$—Adds all of the above in one string – $Log$—Adds the comments written on every check in. These keywords will be expanded anywhere in the source file. There is unfortunately no way to selectively turn off keyword substitution. You can add the keywords to the Javadoc for the classes as in: /** * class comment goes here. * * <pre> * Date $Date$ * CVS History: * $Log$ * </pre> * @author $Author$ * @version $Revision$ */ If you want all your new Java files to contain this header, it is easy to add it to the default class level template. Select Window -> Preferences -> Java -> Tem pla tes . Now select the typecomment template. Click Edit and replace the text with this code (Figure 22-7): /** * class comment goes here. * * <pre> * Date $$Date$$ <=== $ must be written as $$ * CVS History: * $$Log$$ * </pre> * @author $$Author$$ * @version $$Revision$$ */ To make the same change for files generated by the Application Developer wizards, also change the filecomment template. Chapter 22. Using Concurrent Versions System 709 Figure 22-7 Using CVS keywords in Java comments After committing a new class to CVS, you can see the comments in the source: /** * class comment goes here. * * <pre> * Date $Date: 2003/04/20 02:14:05 $ * CVS History: * $Log: Test.java,v $ * Revision 1.1 2032/04/20 02:14:05 UELI * Change 2 * * </pre> * @author $Author: UELI $ * @version $Revision: 1.1 $ */ 710 WebSphere Studio Application Developer Version 5 Programming Guide What changes could impact your work? In Version 4, after adding an EJB project to CVS, you can delete the project from the workspace and, when necessary, import it again. In this case, all the components are reloaded. In Version 5, this scenario will lead to many errors, such as missing classes, and you have to redeploy the EJBs. The reason is that some of the components, such as the deployed code, are not stored in the CVS repository in the default setup. Ignored Resources To store the deployed code in the CVS repository, you have to change the preferences of the Workbench: Select Window -> Preferences -> Team -> Ignored Resources (Figure 22-8). Remove the check marks to store EJB deployed code in CVS. Figure 22-8 CVS ignored resources preferences More details on the ignored Resources preference On the Ignored Resources page, you can specify file name patterns to be excluded from the version control management system. Chapter 22. Using Concurrent Versions System 711 Files are matched against the list of patterns, before they are considered as version control candidates. A file or directory that matches any one of the patterns will be ignored during update or commit operations. The patterns may contain the wildcard characters * (any sequence of zero or more characters) and ? (any one character). To add a file type to the ignore list, click the Add button. In the window, enter a file type (for example, *.class). To remove a file type from the ignore list, select the file type in the ignore list and click Remove . You can temporarily disable ignoring the file pattern by de-selecting it from the list; you do not have to remove the specified file pattern from the list. Ignoring resources from version control When synchronizing resources, you may not want to commit all resources to the repository. There are two ignore facilities provided, allowing the user to specify which resources should be excluded from update and commit operations: The first is a global ignore facility, provided by the Workbench as shown in Figure 22-8. The second is the CVS ignore facility, which reads the contents of a special .cvsignore file to determine what to ignore. CVS ignore facility The Eclipse CVS client recognizes a file named .cvsignore in each directory of a project. This is a standard CVS facility and many existing CVS projects may contain such a file. This text file consists of a list of files, directories, or patterns. In a similar way to the global ignore facility, the wildcard * and ? may be present in any entry in the .cvsignore file. Any file or subdirectory in the current directory that matches any one of the patterns is ignored. It is important to note that the semantics of this file differ from that of the global ignore facility in that they apply only to files and directories in the same directory as the .cvsignore file itself. A project may contain one .cvsignore file in each directory. For more information, visit http://www.cvshome.org. Resources that have not been added to CVS control can be ignored by selecting Team > Add to .cvsignore from the context menu of the resource in the Navigator view. This menu option is also available in the Synchronize view. 712 WebSphere Studio Application Developer Version 5 Programming Guide Label decorations By default, Application Developer does not show CVS label decorations that give you a visual indication of when a project, folder, or file is linked to a repository, and whether or not the file has been updated in the workspace, but not in the repository. Before we begin working with CVS in Application Developer, select Window -> Preferences , then select Workbench -> Label Decorations in the Preferences window. Select CVS in the label decorations list, as shown in Figure 22-9. Click OK to save these preferences. The results of this are evident in this chapter in all figures that show the Navigator view. Figure 22-9 Workbench Label Decorations CVS console In the CVS Console view, you can see all the interactions between Application Developer and CVS. Select Window -> Show View -> Other -> CVS -> CVS Console to open the view. Chapter 22. Using Concurrent Versions System 713 Development scenario To show you how to work with CVS in Application Developer, we will follow a simple but typical development scenario, shown in Table 22-1. Two developers, stade1 and stade2, work together to create three entity beans: Customer, TransRecord and Account. These are the same entity beans created in Chapter 12, “Developing EJB applications” on page 373, so you can refer to that chapter for additional details. Table 22-1 Sample development scenario Steps 1 through 3 are serial development—no parallel work is being done. During steps 4 and 5, both developers work in parallel, resulting in inevitable conflicts. These conflicts are resolved using Application Developer’s tooling. In the sections that follow, we will perform each of the steps and explain the team actions in detail. Step Developer 1 (stade1) Developer 2 (stade2) 1 Creates a new EJB project named ITSOProGuideCVS, adds it to version control and commits it to the repository. 2 Imports the ITSOProGuideCVS CVS module as a Workbench project. Creates the Customer entity bean, adds it to the version control and synchronizes the project with the repository. 3 Synchronizes the project with the repository before doing new development. 4 Creates the Account entity bean. Creates the TransRecord entity bean, adds it to the version control and synchronizes the project with the repository. 5 Adds the Account bean to the version control and synchronizes the project with the repository, resolving conflicts in the process. 6 Versions the project. . also available in the Synchronize view. 712 WebSphere Studio Application Developer Version 5 Programming Guide Label decorations By default, Application Developer does not show CVS label decorations. $RCSfile$—Adds the file name without the path 708 WebSphere Studio Application Developer Version 5 Programming Guide – $Revision$—Adds the latest version number – $Date$—Adds the date and time when. 704 WebSphere Studio Application Developer Version 5 Programming Guide Figure 22-1 CVSNT service configuration (Service Status page) On