Thanks Paul and Erik! My needs are to browse the code examples and run them to improve my understanding. So I rather download the Groovy 2.4 or use http://groovyconsole.appspot.com My groovy experience so far is writing medium-difficulty declarative pipelines for Jenkins. After seeing some peer inspirations how to write shell scripts with groovy I decided to invest some time. Hope this clears what I want to achieve. Dimitar
На вт, 2.04.2024 г. в 19:21 Nelson, Erick <erick.nel...@hdsupply.com> написа: > Not sure if this is the best way to do this, but I wrap antbuilder in my > own class so that I can get ant event messages to my logger > > > > *package* script.ant > > > > *import* groovy.ant.AntBuilder *as* AB > > *import* org.apache.tools.ant.BuildEvent > > *import* org.apache.tools.ant.BuildLogger > > > > @groovy.util.logging.Slf4j > > *class* AntBuilder { > > *static* AB newInstance () { > > AB ab = *new* AB() > > ab.project.buildListeners.each { ab.project.removeBuildListener(it) > } > > ab.antProject.addBuildListener(*new* BuildLogger() { > > @Override *public* *void* buildStarted (BuildEvent > event) { } > > @Override *public* *void* buildFinished (BuildEvent > event) { } > > @Override *public* *void* targetStarted (BuildEvent > event) { } > > @Override *public* *void* targetFinished (BuildEvent > event) { } > > @Override *public* *void* taskStarted (BuildEvent event) > { } > > @Override *public* *void* taskFinished (BuildEvent > event) { } > > @Override *public* *void* messageLogged (BuildEvent > event) { > > *if* (event?.task) *log*.info("[{}] {}", > event.task.taskName, > event.message) > > } > > @Override *public* *void* setMessageOutputLevel (*int* > level) { } > > @Override *public* *void* setOutputPrintStream > (PrintStream output) { } > > @Override *public* *void* setEmacsMode (*boolean* > emacsMode) { } > > @Override *public* *void* setErrorPrintStream > (PrintStream err) { } > > }) > > ab > > } > > } > > > > > > *From: *Paul King <pa...@asert.com.au> > *Date: *Tuesday, April 2, 2024 at 5:37 AM > *To: *users@groovy.apache.org <users@groovy.apache.org> > *Subject: *[EXT] Re: making the most of Groovy in Action 2nd edition > > Hi Dimitar, > > From Groovy 4, Groovy's "module" jars are fully-compliant with the > JPMS rule disallowing split packages. The Groovy 3 and 4 release notes > have more details. > > But basically, for the example you are showing, AntBuilder is now in > the groovy.ant package, so if you add the appropriate import, you'll > be good to go. AntBuilder was in the groovy.util package in earlier > Groovy versions, and so didn't need the import. Mind you, there will > likely be numerous places where such changes are needed. > > We haven't produced an updated version of those examples for Groovy 4. > > Cheers, Paul. > > On Tue, Apr 2, 2024 at 8:01 PM Dimitar Vassilev > <dimitar.vassi...@gmail.com> wrote: > > > > Hi all, > > > > After a bit of extensive bashing, I found some time to re-read Groovy in > Action 2nd edition. > > I've downloaded the source code from the publisher also and am wondering > how to make the most from the book provided I run Groovy 4.0.20/Mac 12.7.4 > > Running groovysh from the console is fine, but it doesn't always print > the examples > > going into the groovy book source > > GroovyInAction % groovy alltests.groovy > > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > > /Users/xxxx/GroovyInAction/alltests.groovy: 2: unable to resolve class > AntBuilder > > @ line 2, column 15. > > def ant = new AntBuilder() > > ^ > > > > 1 error > > Thanks! >