You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Aaron Kaplan <Aa...@xrce.xerox.com> on 2007/09/26 18:09:27 UTC

Cleaning up JCasGen output

When I first started playing with UIMA, I let the eclipse plugin run 
jcasgen for me automatically whenever I changed the type system 
descriptor.  After a few days of that, I noticed that my src folder was 
full of definitions of obsolete classes, corresponding to types I had 
once defined and then either renamed or deleted.  It was a pain to clean 
them all up, because they were scattered among files that I had written 
by hand, so I had to inspect each file under src and decide whether to 
delete it or not.

In order to avoid that, I now tell jcasgen to create its output in a 
separate directory, say jcasgen-src instead of src.  My ant "clean" 
target wipes out that directory.

The problem with this solution is that now eclipse can't build my 
project.  As far as I can see, the jcasgen output directory can't be 
configured in the eclipse plugin.  So I have to remember to run an ant 
task each time I change my type system (at least until I get around to 
figuring out how to write a custom eclipse builder).

Do people have other strategies for cleaning up obsolete jcasgen output?

Obviously if you modify the jcasgen output by hand, you can't use my 
strategy, otherwise "clean" would wipe out your work.  But is there any 
reason to modify the jcasgen-generated class definitions, rather than 
leaving them as they are and subclassing them?

-Aaron

Re: Cleaning up JCasGen output

Posted by Aaron Kaplan <Aa...@xrce.xerox.com>.
Marshall Schor wrote:

> The other thing that *might* work - I believe that JCasGen uses the
> "first" src folder it finds in the project.  You might try configuring
> your project with additional source folders, and putting the one you
> want JCasGen to use, first.  You can add src folders in the project -
> properties - Java build path menu, and there is an "Order and Export"
> tab where you can set the order.  If you try this, let us know if it
> works :-)

It solves the biggest part of the problem, anyway.  Now I can allow the 
Component Descriptor Editor to run jcasgen automatically when the type 
system changes, because the output goes where I want it instead of 
polluting src.

The eclipse build still doesn't work completely smoothly: I still need 
to run jcasgen by hand after wiping out the jcasgen-src directory, 
otherwise the eclipse build fails.  But I guess there's no way around 
that short of defining a custom eclipse builder.  I'm wiping out 
jcasgen-src behind eclipse's back, so it's not surprising that eclipse 
gets confused.

> Unfortunately, the main JCas class, not a subclass, is used by the
> framework when the framework needs to create new instances. ...
> (for example, if you are iterating through the CAS and use the
> iterator.next() method)

I see.

Thanks for your help
-Aaron



Re: Cleaning up JCasGen output

Posted by Marshall Schor <ms...@schor.com>.
Aaron Kaplan wrote:
> When I first started playing with UIMA, I let the eclipse plugin run
> jcasgen for me automatically whenever I changed the type system
> descriptor.  After a few days of that, I noticed that my src folder
> was full of definitions of obsolete classes, corresponding to types I
> had once defined and then either renamed or deleted.  It was a pain to
> clean them all up, because they were scattered among files that I had
> written by hand, so I had to inspect each file under src and decide
> whether to delete it or not.
>
> In order to avoid that, I now tell jcasgen to create its output in a
> separate directory, say jcasgen-src instead of src.  My ant "clean"
> target wipes out that directory.
>
> The problem with this solution is that now eclipse can't build my
> project.  As far as I can see, the jcasgen output directory can't be
> configured in the eclipse plugin.  
That's right.  But it sounds like a reasonable new feature request.  If
you wanted to fix this, I'll take a look at your patch and see about
committing it :-)

The other thing that *might* work - I believe that JCasGen uses the
"first" src folder it finds in the project.  You might try configuring
your project with additional source folders, and putting the one you
want JCasGen to use, first.  You can add src folders in the project -
properties - Java build path menu, and there is an "Order and Export"
tab where you can set the order.  If you try this, let us know if it
works :-)
> So I have to remember to run an ant task each time I change my type
> system (at least until I get around to figuring out how to write a
> custom eclipse builder).
>
> Do people have other strategies for cleaning up obsolete jcasgen output?
>
> Obviously if you modify the jcasgen output by hand, you can't use my
> strategy, otherwise "clean" would wipe out your work.  But is there
> any reason to modify the jcasgen-generated class definitions, rather
> than leaving them as they are and subclassing them?
Unfortunately, the main JCas class, not a subclass, is used by the
framework when the framework needs to create new instances.  If
"BaseJCasClass" is a base class, and you derive "SubJCasClass" from it,
you could create a new instance:
    new SubJCasClass(...)

but the framework, which also needs to sometimes create new instances
(for example, if you are iterating through the CAS and use the
iterator.next() method) - will use the BaseJCasClass because it doesn't
know about your extension..
>
> -Aaron
>
>