Menu

Cleartool commands with CLI - examples?

Help
2008-11-14
2013-04-06
  • Shaman Mahmoudi

    Shaman Mahmoudi - 2008-11-14

    Hi,

    I am trying to write a little ClearCase application which will be used in testing. Basically what I want is to interact with the cleartool prompt >cleartool, and among other things I want to checkin, checkout, lsact, lsactivity, mkactiviy etc. and also be able to answer questions by cleartool such as do you really want to delete this file? [no]. So I want to send commands continuesly depending on the output from the CLI.

    Is there such a CLI in ClearCase for java? I am suspecting ClearCaseCLIImpl is a good candidate, but I have a hard time finding any good documentation and example code.. Not only this CLI class, but in general.

    Thanks in advance!

     
    • Vincent Latombe

      Vincent Latombe - 2008-11-14

      Hi,

      the purpose of Clearcase for Java is to provide a Java API to access ClearCase features. ClearCaseCLIImpl implements this API using cleartool executable behind the scenes. I recommend you to read the documentation of ClearCaseInterface in the project to know what features we currently provide.

      As for the documentation, as we are currently very short on resources on the project, there isn't any except from the javadoc itself.

      Hope it helps,

      Vincent

       
      • Shaman Mahmoudi

        Shaman Mahmoudi - 2008-11-14

        Hi,

        Thanks for the reply!

        That is basically what I want to do, use the existing cleartool executable via Java, and if possible using the cleartool executable via its CLI.

        I will definitely check out the ClearCaseInterface.. Thansk again!

         
    • Shaman Mahmoudi

      Shaman Mahmoudi - 2008-11-17

      Hi,

      I am having some issues with ClearCaseCLIImpl. I can not even set a view. What I want to do is set an existing view, with default configspec.

      I read the documentation for ClearCaseInterface, here it what is says:

      If the file name is <code>null</code>, the config spec will be resetted to the view's default.

      Ok so I do this:

      ClearCaseInterface clearCaseInterface = ClearCase.createInterface(ClearCase.INTERFACE_CLI);

      clearCaseInterface.setViewConfigSpec("<name of my view>", null);

      And I get an exception (getUncaughtExceptionHandler(), which I can only see with step debugging, I guess I am not catching it) and the thread terminates.

      From the output it looks like this:

      cleartool setcs -tag <name of my view>

      I don't believe this is correct. Shouldn't it also pass the -default flag with it? I.e. if file name is null, then add -default flag to the command. Sure enough file name = null is not handled in ClearCaseCLIImpl when checking source code.

       
    • Shaman Mahmoudi

      Shaman Mahmoudi - 2008-11-17

      >And I get an exception (getUncaughtExceptionHandler(), which I can only see with step >debugging, I guess I am not catching it) and the thread terminates.

      Sorry. This is not true. I get exit code 1 from cleartool.

       
    • Shaman Mahmoudi

      Shaman Mahmoudi - 2008-11-20

      Hi,

      Could I get a simple example to get this up and running?

      My scenario is,

      I set my view in xterm, and then I run eclipse from there. I run the CC for Java program which has imported Clearcase for Java.

      The code looks like this:

      ClearCaseInterface clearCaseInterface = ClearCase.createInterface(ClearCase.INTERFACE_CLI);

      String [] test000 = new String[1];
      test000[0] = "/vobs/mystuff/example.txt";

      try {
      ClearCaseElementState [] states = clearCaseInterface.checkout(test000, "", ClearCase.None, null);
      } catch (IllegalArgumentException e) {
          System.out.println("From checkout: "+e);
      }
        catch (ClearCaseException e) {
          System.out.println("From checkout: "+e);
      }
        catch (Exception e) {
          System.out.println("From checkout: "+e);
      }

      try {
          clearCaseInterface.dispose();

      }

       
    • Shaman Mahmoudi

      Shaman Mahmoudi - 2008-11-20

      Continued from last post as I accidently posted it prematurely:

      catch (Throwable t) {
      System.out.println("From dispose: "+t);
      }

      And the output is:

      From checkout: java.lan.IllegalThreadException: process hasn't exited
      <then prints out that it is checking out fine and says cleartool exited with code 1 and sometimes exits with code 0>
      From dispose: java.lang.ExceptionInitalizerError

      Then I check the file in xterm, and sure enough it has been checked out just fine.

      So what am I missing here? It looks like some problem with initalization. Thanks in advance.

       
  • Neeraj Sharma

    Neeraj Sharma - 2013-01-11

    Hi,
    I want to write a java program which can access clear case and create a view and child stream. I am new to clear case.
    Please help me from where i shoudl start with.
    Thanks.

     
  • Mikael Petterson

    Hi,

    For code have a look at:

    https://sourceforge.net/projects/clearcase-java/

    Besides that I don't have much time to assist you in code writing.

    Good luck !

    //Mike

     

Log in to post a comment.