[p4] Java interface to Perforce / P4API for Java

Chris Patti cpatti at atg.com
Wed Oct 31 15:02:26 PST 2001


At 04:32 PM 10/30/2001 -0800, you wrote:
>[Sending a copy to perforce-user, since I think that these URLs are
>particularly useful.   And "yes, the command-line interface is so
>robust and easy to use that I would NOT bother with the C++ API
>for any sort of build needs, ever. For linking against an application
>written in C++ that does other stuff, maybe; for Perl/shell/Python
>sorts of scripts, the command-line's great!"     -jab]
>
>At 12:32 PM 10/30/2001 -0700, you wrote:
>>Thanks for your response Jeff--I'll look into it.  Do you know if the
>>command-line interface is very robust?
>
>         VERY robust. You'll find FAQs at
>                 http://public.perforce.com/public/perforce/faq/index.html
>         The build one is 
> http://public.perforce.com/public/perforce/faq/build.html
>
>         I wouldn't bother with the API unless I was writing GUI applications
>         that needed a C++ library to link against; the most I'd do is write
>         in Python (which I like a lot) and use the "p4 -G" option to have it
>         write its output (and read its input) in Python-friendly 
> "marshal" objects.
>
>         -jab


Jeff;

All of what you say is completely true and I hope you'll understand that 
I'm *NOT* arguing with any of it (In fact see my endorsement of your 
suggestion below :)

However, doing the parsing by hand (even with -s, which is marginally 
useful at best..  It considers a sync with no files needing to be synced an 
error, whereas some REAL errors are marked info.  Useless, or nearly so) is 
not only a drag but a recipe for disaster.

A better solution is needed.  Perforce's inclusion of the undocumented -G 
option for Python scripters is proof positive that at least on some level 
they're aware of this.

I agree that the C++ api approach is severely flawed as well for most 
normal scripting applications - if faced with a choice between that 
extremely complex, event driven API (Way, *WAY* too heavyweight for what 
script writers want) and the command line flawed though it may be for 
scripting purposes, I'll choose the command line any day of the week.

If I can find time I plan to pursue a solution for Java that uses a Java 
class someone wrote that understands the Python marshalled object format, 
thus making Java a usable vehicle for pre-parsed objects to be passed back 
from the p4 client using the -G option, more detail to follow.

-Chris
(The Java class in question is at 
http://www.gjt.org/pkgdoc/org/gjt/jjt/marshal/index.html )





More information about the perforce-user mailing list