Shamnad P S Shamnad P S - 9 months ago 67
Java Question

How to do CVS commit using java code

I need to commit a file into CVS repository using java code.

My requirement is, When a submit button is clicked, I need to receive the call to java method and then commit a file to CVS repository using Java code in the background without using any GUI tools.

I know the below items.

  • Branch to commit.

  • Name and path of the file to Commit.

  • CVS repo url.

  • CVS Username and password.

How can I use the above details to connect to CVS server and then do the commit?

Answer Source

Please find below the solution which worked for me. Its pretty straightforward and easy.

   ProcessBuilder builder = new ProcessBuilder(
            "cmd.exe", "/c", "cd D:/CVS_REPO/ && dir && cvs checkout  && cd project_folder && cvs commit -m \"Admin Tool\"");
        Process p = builder.start();
        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line;
        while (true) {
            line = r.readLine();
            if (line == null) { break; }