Re: Running groovy programs

Andriy Rysin <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CAOZT1o3qRraNhTC5wA=4ycyLtK2POONn=gzNnhxjw=bCyMDGKA@mail.gmail.com>
This approach may work well for simple file include but if I have packages
(and import statements, which is inevitable if program grows) it does not
compile.

Andriy

On Wed, Mar 9, 2022 at 4:47 AM Jochen Theodorou <[email protected]> wrote:

> On 08.03.22 19:08, Andriy Rysin wrote:
> > So it looks like groovy picks up groovy scripts from the current
> > directory by default.
> > So the users can't just do "/path/to/scripts/TagText.groovy <myfile>"
> > any more.
> > They would have to do:
> > cd /path/to/scripts/
> > ./TagText.groovy <myfile>
> >
> > or they would have to invoke groovy explicitly:
> > groovy -cp /path/to/scripts /path/to/scripts/TagText.groovy <myfile>
>
> what you could also do is to make something like a small loader. Use
>
> https://docs.groovy-lang.org/latest/html/gapi/groovy/transform/SourceURI.html
> to get the uri of the file, then add the to the classloader to then
> finally load the class that is really doing the work and has
> dependencies on other scripts. This loader should not have any direct
> source dependencies for this to work.
>
> bye Jochen
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.