Click here to Skip to main content
15,063,085 members
Articles / DevOps / TFS
Article
Posted 2 Feb 2015

Stats

17.5K views
91 downloads
2 bookmarked

Developing a Custom Comment Checkin Policy for TFS and Eclipse

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
2 Feb 2015CPOL4 min read
This article helps you develop, test and deploy a custom comment check in policy for Eclipse IDE and Microsoft TFS. A plug-in should be written for comment checkin policy development

Introduction

This article shows you how to implement a custom comment check in policy for Eclipse IDE and Microsoft TFS. A plug-in should be written for comment checkin policy development. The implementatin is explained with 4 section,

  • Configuring of the Environment, 
  • Development of the Plugin,
  • Testing the plugin,
  • Deployment

Configuring the Environment

Step 1 The eclipse products that can help for plugin development are known as Eclipse for RCP/Plug-in Developers. The IDE can be downloaded from https://eclipse.org/downloads/packages/eclipse-rcp-and-rap-developers/lunasr1a . 


Microsoft Team Explorer Everywhere plugin helps you make integration with Microsoft Team Foundation Server and your Eclipse. In the project it will be used, it can be downloaded it from http://www.microsoft.com/en-us/download/details.aspx?id=40785 . 

After downloading Microsoft Team Explorer Everywhere plugin, go Help menu of IDE and then click Install New software which is showing as Figure 1 .

Figure 1 – Eclipse Install New Software


Step 2 Click Add button to give the file location on local drive(for downloaded Micorsoft Team Explorer Plugin plugin) in Add repository window. Give any name in the Name field and then move ahead to install plugin. Chose Path For TFSEclipsePlugin-UpdateSiteArchive-XXXXX. Figure 2 is showing adding repository.

 

Figure 2– Adding Repository

 

Step 3 To check if it is working fine, go Window menu of IDE, click open perspective and other which is shown in Figure 3. 

Figure 3– Open Perspective

 

Select Team Foundation Server Exploring which is shown Figure 4.

Figure 4 – Team Foundation Server Exploring

 

Development of the Plugin

Step 4 Create new plugin development project from the IDE as shown Figure 5 and Figure 6.

 

Figure 5 – Plugin Project

 

Figure 6 – Create Plugin Project

 

Step 5 Add the com.microsoft.tfs.checkingpolicies as the dependency to Manifest.MF file as Figure 7 shows.

 

Figure 7 – Adding Dependency


Step 6 Add com.microsoft.tfs.checkinpolicies.checkinPolicy as Extension to Extensions of the plugin project as Figure 8 shows.

 

Figure 8 – Adding Extension

 

Step 7 In overview tab of the plugin clear “Activator” and “active this plugin when one of its classes is loaded” fields as Figure 9 shows.

 

Figure 9 – Clear Activator Fields

 

Step 8 Create a class with CommentCheckinPolicy in src folder. Import com.microsoft.tfs.core.checkinpolicies.PolicyBase and extend the class from PolicyBase. Add unimplemented methods, your class will be seen as Figure 10.

 

Figure 10 – CommentCheckinPolicy Class

 

Step 9 Create policy type with appropriate parameters such as installation guide, explanation etc as Figure 11 shows.

 

 

Figure 11 – Creating Policy Type

 

Step 10 In the evaluate method getPedningCheckin and via pendingcheckin get the comment entered. Check if the comment is valid, if it is invalid add it to failures array and show a special warning message. The evaluate method should be return PolicyFailure array. Figure 12 shows the Evaluate method.

 

Figure 12 – Evaluate Method

 

Step 11 The edit method should return true to show the policy in policy menu after edit as Figure 13 shows.

 

Figure 13 – Edit Method

 

Testing The Plugin

 

Step 12 You can run the plugin project with run button, when the new IDE occurs select the setting menu of Microsoft Team Explorer Everywhere as shown in Figure 14.

Figure 14 – Team Explorer Everywhere Settings 

 

Step 13 Figure 15 shows the settings menu and how to add our Comment Policy.

 

Figure 15 – Adding checkin policy

 

Step 14 If you try a checkin after adding the policy with invalid comment, the below message will be occur.

 

Figure 16 – Invalid Comment Warning

 

Deployment


Step 15 Since check-in policies for the TFS Plug-in for Eclipse are simply Eclipse plug-ins, they can be deployed to a target IDE using any method it supports. 


Please follow the steps for plugin deployment


1. In Package Explorer, right-click on the sample plug-in project and choose Export,
2. In the dialog that appears, select Plug-in Development > Deployable plug-ins and fragments as the destination and click Next.
3. Choose your preferred output format and name, then complete the wizard.
4. Copy the output into the dropins directory (or plugins directory for older Eclipse versions) of the target IDE.

 

 

History

02.02.2015: Version 1

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Yildirim Kocdag
Architect
Turkey Turkey
Phd. Yildirim Kocdag is a Computer Engineer.

Programming Languages
Android, Objective-c, c#, vb.net, asp.net, javascript, TSQL.

Computer Science
DataMining, Compilers, Expert Systems, Digital Image Processing, AI and Extreme Programming.

ykocdag@yahoo.com

http://www.linkedin.com/profile/view?id=223886830

Comments and Discussions

 
-- There are no messages in this forum --