现在的位置: 首页 > 综合 > 正文

利用JNI监控CVS仓库变动,自动更新到相应目录——简化WEB小组开发(三、cvs篇)

2018年05月21日 ⁄ 综合 ⁄ 共 1661字 ⁄ 字号 评论关闭
 接下来的任务就非常简单了,就是编写各种各样的Action

这里我们更新cvs用javacvs开源包

import org.junit.Test;
import org.netbeans.lib.cvsclient.Client;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
import org.netbeans.lib.cvsclient.command.CommandAbortedException;
import org.netbeans.lib.cvsclient.command.CommandException;
import org.netbeans.lib.cvsclient.command.GlobalOptions;
import org.netbeans.lib.cvsclient.command.update.UpdateCommand;
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
import org.netbeans.lib.cvsclient.connection.PServerConnection;


public class ClientCVS {
    
    @Test
    
public void fileSystemChanged() {
        
        CVSRoot cvsRoot 
= new CVSRoot(":pserver:wxy@192.168.10.231:/data/cvsroot/projects");
        cvsRoot.setPassword(
"wxy2007");
        
        PServerConnection c 
= new PServerConnection(cvsRoot);
        
        Client client 
= new Client(c, new StandardAdminHandler());
        client.setLocalPath(
"D:/aaa");
        
        client.getEventManager().addCVSListener(
new BaseListener());
        
        
//CheckoutCommand command = new CheckoutCommand(true,"Team-Tool");
        
        UpdateCommand command 
= new UpdateCommand();
        command.setBuildDirectories(
true);
        command.setPruneDirectories(
true);
        
        
        
try {
            client.executeCommand(command, 
new GlobalOptions());
        }
 catch (CommandAbortedException e) {
            e.printStackTrace();
        }
 catch (CommandException e) {
            e.printStackTrace();
        }
 catch (AuthenticationException e) {
            e.printStackTrace();
        }

        
    }


}

其他还应该写一些action来相互配合,比如第一次发现新的模块,则先签出,之后就更新,这些就是对这个cvs包的应用了

抱歉!评论已关闭.