CVS Java Client

2008/07/31 10:46

 

프로그램이 NetBeans 프로젝트로 존재한다.

 

Command Line으로 접근할 수 있는 대부분의 CVS 명령어를 자바로 수행할 수 있다.

 

이곳을 참조하시라.. http://javacvs.netbeans.org/source/browse/javacvs/

 

샘플 코드는..

 com.ibm.rational.CVSUtil update C:\BuildServer\Staging :pserver:anoncvs@XXX.XXX.XX.XX:/XXXX staging

/*
 * 작성된 날짜: 2007-01-30
 *
 * TODO 생성된 파일에 대한 템플리트를 변경하려면 다음으로 이동하십시오.
 * 창 - 환경 설정 - Java - 코드 스타일 - 코드 템플리트
 */
package com.ibm.rational;

import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.netbeans.lib.cvsclient.CVSRoot;
import org.netbeans.lib.cvsclient.Client;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
import org.netbeans.lib.cvsclient.command.GlobalOptions;
import org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand;
import org.netbeans.lib.cvsclient.command.update.UpdateCommand;
import org.netbeans.lib.cvsclient.connection.PServerConnection;

/**
 * @author d19957
 *
 * CVS 관련 Utility
 */
public class CVSUtil {

 
 private static Log log = LogFactory.getLog(CVSUtil.class);
 
 public static void main(String[] args) {
  /*
  String destDir = "C:\\BuildServer\\Staging";
  String location = ":pserver:anoncvs@172.21.99.4:/MBIRepo";
  String module = "DSMbibEJB";
  */
  String cmd = args[0];
  String destDir = args[1];
  String location = args[2];
  String module = args[3];
  
  if( "checkout".equals(cmd)) {
   CVSUtil.checkout( destDir, location, module);
  } else if( "update".equals(cmd)) {
   CVSUtil.update( destDir, location, module);
  } else {
   log.info("No Matched Command!!!");
  }
 }
 
 public static void checkout(String destDir, String location, String module) {
  CVSRoot cvsroot = CVSRoot.parse(location);
//  Properties props = new Properties();
//  props.put("method", "pserver");
//  props.put("hostname", "172.21.99.4");
//  props.put("port", "2401");
//  props.put("username", "anoncvs");
//  props.put("password", "");
//  props.put("repository", "/DEPRepo");
//  CVSRoot cvsroot = CVSRoot.parse(props);
   
  GlobalOptions globalOptions = new GlobalOptions();
  globalOptions.setCVSRoot(cvsroot.toString());
  
  PServerConnection con = new PServerConnection(cvsroot);
  
  Client client = new Client(con, new StandardAdminHandler());
  client.setLocalPath(destDir);
  
  CheckoutCommand checkout = new CheckoutCommand(true, module);
  try {
   client.executeCommand(checkout, globalOptions);
  } catch (Exception e) {
   log.error("", e);
  }
 }

 public static void update(String destDir, String location, String branch) {
  CVSRoot cvsroot = CVSRoot.parse(location);
  GlobalOptions globalOptions = new GlobalOptions();
  globalOptions.setCVSRoot(cvsroot.toString());
  
  PServerConnection con = new PServerConnection(cvsroot);
  
  Client client = new Client(con, new StandardAdminHandler());
  client.setLocalPath(destDir);
  
  UpdateCommand update = new UpdateCommand();
  
  update.setCVSCommand('P', "");
  update.setCVSCommand('d', "");
  update.setCVSCommand('C', "");
  
  update.setCVSCommand('r', branch);
  
  log.debug("Executing...." + update.getCVSCommand() );
  
  try {
   client.executeCommand(update, globalOptions);
  } catch (Exception e) {
   log.error("", e);
  }
 }
}
 

이 글은 스프링노트에서 작성되었습니다.

Posted by 아프락사스
<< PREV : [1] : ... [56] : [57] : [58] : [59] : [60] : [61] : [62] : [63] : [64] : ... [160] : NEXT >>

BLOG main image

공지사항

카테고리

분류 전체보기 (160)
MAMP LAMP (1)
Open Project (4)
Knowhow (57)
JEE Technologies (3)
Rational Products (94)
Etc (0)