Re: Sort on linkedlists with double values (inside main list)

2024-05-21 Thread Paul King
On Tue, May 21, 2024 at 3:13 PM M.v.Gulik  wrote:
>
> After fixing my local bug I rechecked the "*.sort{ a, b -> a.y == b.y ? -a.y 
> <=> -b.y : a.x <=> b.x }" variant.
> Same result/conclusion.

In terms of referencing the properties, you'd want to swap the order
you have above, i.e. you'd not want to have y ? y : x but rather y ? x
: y or x ? y : x.
Also, the "*.sort" would only be needed if you have lists of lists of maps.

> However, on a hunch, I split in into two separate consecutive sorts. "*.sort{ 
> a, b -> a.x <=> b.x }.sort{ a, b -> -a.y <=> -b.y }"
> So far this seems to do the job of fully sorting my 2d/coordinates set. (so 
> far: no guaranties, as the used data set is somewhat limited and specific.)

This doesn't seem right as written. Perhaps you are abbreviating and
leaving out some info that I am missing.


Re: Sort on linkedlists with double values (inside main list)

2024-05-21 Thread Paul King
Indeed OC, your version is shorter and easier to read (in my eyes too).

Whether it is more performant depends on whether the respective
compareTo method isn't too slow compared to the equals method.

On Tue, May 21, 2024 at 2:22 AM o...@ocs.cz  wrote:
>
> Paul,
>
> side question, completely irrelevant to the original problem, just occurred 
> to me when I read this...
>
> On 20. 5. 2024, at 17:02, Paul King  wrote:
> println ([[x:1, y:100],  [x:2, y:1], [x: 2, y:500]].sort{ a, b -> a.x == b.x 
> ? a.y <=> b.y : a.x <=> b.x }) // works
>
>
> Wouldn't sort { a,b -> a.x<=>b.x ?: a.y<=>b.y } be both more efficient and 
> better readable and intention-revealing? Or do I overlook some reason why it 
> would be a bad idea?
>
> Thanks,
> OC
>
>
> On Tue, May 21, 2024 at 12:52 AM Paul King  wrote:
>
>
> If you have only two dimensions, you'll get away with your solution
> for small integer coordinate values. Here is a counter example with
> integers:
>
> println ([[x:  1, y: 69273666],  [x: 69273666, y: 1]].sort{[it.x,
> it.y]}) // broken
> println ([[x:  1, y: 69273666],  [x: 69273666, y: 1]].sort{ a, b ->
> a.x == b.x ? a.y <=> b.y : a.x <=> b.x }) // works
>
> On Tue, May 21, 2024 at 12:25 AM M.v.Gulik  wrote:
>
>
>
> On Mon, 20 May 2024 at 15:40, Paul King  wrote:
>
>
> What sort result are you trying to achieve? There should be no need to
> perform any recursion.
>
>
>
> Main target was reordering some set of randomly ordered x,y coordinates into 
> (for example*) a x,y(left to right, top to bottom) order (*:where any of the 
> actual sort directions could be easily flipped).
>
> So far "*.sort{[it.y, it.x]}" seems the best and easiest way to do this 
> (despite its Float/Double caveat).
>
>


Re: Sort on linkedlists with double values (inside main list)

2024-05-20 Thread Paul King
This might even be more obvious:

println ([[x:1, y:100],  [x:2, y:1], [x: 2, y:500]].sort{[it.x,
it.y]}) // broken: [[x:2, y:1], [x:1, y:100], [x:2, y:500]]
println ([[x:1, y:100],  [x:2, y:1], [x: 2, y:500]].sort{ a, b -> a.x
== b.x ? a.y <=> b.y : a.x <=> b.x }) // works

On Tue, May 21, 2024 at 12:52 AM Paul King  wrote:
>
> If you have only two dimensions, you'll get away with your solution
> for small integer coordinate values. Here is a counter example with
> integers:
>
> println ([[x:  1, y: 69273666],  [x: 69273666, y: 1]].sort{[it.x,
> it.y]}) // broken
> println ([[x:  1, y: 69273666],  [x: 69273666, y: 1]].sort{ a, b ->
> a.x == b.x ? a.y <=> b.y : a.x <=> b.x }) // works
>
> On Tue, May 21, 2024 at 12:25 AM M.v.Gulik  wrote:
> >
> >
> > On Mon, 20 May 2024 at 15:40, Paul King  wrote:
> >>
> >> What sort result are you trying to achieve? There should be no need to
> >> perform any recursion.
> >
> >
> > Main target was reordering some set of randomly ordered x,y coordinates 
> > into (for example*) a x,y(left to right, top to bottom) order (*:where any 
> > of the actual sort directions could be easily flipped).
> >
> > So far "*.sort{[it.y, it.x]}" seems the best and easiest way to do this 
> > (despite its Float/Double caveat).


Re: Sort on linkedlists with double values (inside main list)

2024-05-20 Thread Paul King
If you have only two dimensions, you'll get away with your solution
for small integer coordinate values. Here is a counter example with
integers:

println ([[x:  1, y: 69273666],  [x: 69273666, y: 1]].sort{[it.x,
it.y]}) // broken
println ([[x:  1, y: 69273666],  [x: 69273666, y: 1]].sort{ a, b ->
a.x == b.x ? a.y <=> b.y : a.x <=> b.x }) // works

On Tue, May 21, 2024 at 12:25 AM M.v.Gulik  wrote:
>
>
> On Mon, 20 May 2024 at 15:40, Paul King  wrote:
>>
>> What sort result are you trying to achieve? There should be no need to
>> perform any recursion.
>
>
> Main target was reordering some set of randomly ordered x,y coordinates into 
> (for example*) a x,y(left to right, top to bottom) order (*:where any of the 
> actual sort directions could be easily flipped).
>
> So far "*.sort{[it.y, it.x]}" seems the best and easiest way to do this 
> (despite its Float/Double caveat).


Re: Sort on linkedlists with double values (inside main list)

2024-05-20 Thread Paul King
What sort result are you trying to achieve? There should be no need to
perform any recursion.

On Mon, May 20, 2024 at 11:36 PM M.v.Gulik  wrote:
>
> Tried "*.sort{ a, b -> a.x == b.x ? a.y <=> b.y : a.x <=> b.x }" in the 
> actual source code so see its effect
> And it turns out its not doing the same job as "*.sort{[it.y, it.x]}" (not 
> unless, I guess, its run recursively until the list-order stopped changing 
> ... which I'm ofc not going to do)
>


Re: Sort on linkedlists with double values (inside main list)

2024-05-20 Thread Paul King
The one argument closure variant of sort is expecting the closure to
return a comparable. The values of any two items are sorted according
to that comparable.

ArrayLists aren't comparable. In that case the hashCode is used as a
fallback for the comparison value. The hashCode for a Java array list
is calculated in terms of the hashCodes of the individual elements and
will only work by fluke, e.g. for small values of integers.

If the floats are small, you could use something like:
sorttest.sort{ it.x * 1000 + it.y }
sorttest.sort{ it.x * -1000 - it.y }

Cheers, Paul.

On Mon, May 20, 2024 at 8:53 PM M.v.Gulik  wrote:
>
> Verified that "*.sort{ a, b -> a.x == b.x ? -a.y <=> -b.y : -a.x <=> -b.x }" 
> actually behaves ok when using Double or Float values (ie: same ordered 
> output as with Integer or BigDecimal values).
>
> Why "*.sort{[ -it.x, -it.y]}" behaved differently when using Double or Float 
> values in this case is beyond me ... Guess i just chalk it up as some 
> peculiar groovy thing.


Re: Sort on linkedlists with double values (inside main list)

2024-05-19 Thread Paul King
I am not 100% sure what you are after. If you are wanting sort by x
and then y, you just want something like this:

sorttest.sort{ a, b -> a.x == b.x ? a.y <=> b.y : a.x <=> b.x }
sorttest.sort{ a, b -> a.x == b.x ? b.y <=> a.y : b.x <=> a.x } //
reverse of above

On Mon, May 20, 2024 at 6:43 AM M.v.Gulik  wrote:
>
> Hmm. Same deal with Float values.
>
> (Guess I'm down to enforce BigDecimal values in case of sorting with
> Float or Double values.)


Re: Unsupported class file major version 65 when running on java 21

2024-05-16 Thread Paul King
Our JDK version support is determined first and foremost by the
version of ASM bundled by Groovy:
JDK20 is supported from 4.0.6
JDK21 is supported from 4.0.11
JDK22 is supported from 4.0.16
JDK23 is supported from 4.0.21

On Fri, May 17, 2024 at 10:05 AM Daniel Sun  wrote:
>
> Could you try the latest stable version, i.e. 4.0.21. As the following 
> configuration shows, Java 21 is supported by Groovy 4.0.21.
>
> https://github.com/apache/groovy/blob/c4615cec66ed07c7f0d9c8c73ee9a6dbda147952/.github/workflows/groovy-build-test-ea.yml#L32
>
> Cheers,
> Daniel Sun
>
> On 2024/05/16 10:19:56 Johan Compagner via users wrote:
> > Hi
> >
> > We are using Jasper that bundles Groovy (4.0.8) but are getting:
> >
> > org.codehaus.groovy.GroovyBugError: BUG! exception in phase 'semantic
> > analysis' in source unit
> > 'calculator_fin_lay_003_f17d19ddf85e94f0e0558ad16053ed00cbb6578a89a5f69df26044d903df00e6'
> > Unsupported class file major version 65
> > at
> > org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:900)
> > ~[groovy-4.0.8.jar:4.0.8]
> > at
> > org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:692)
> > ~[groovy-4.0.8.jar:4.0.8]
> > at
> > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:666)
> > ~[groovy-4.0.8.jar:4.0.8]
> > at
> > net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:112)
> > ~[jasperreports-6.21.0.jar:6.21.0-unknown]
> > at
> > net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:231)
> > ~[jasperreports-6.21.0.jar:6.21.0-unknown]
> >
> >
> > now i tried to search and find anything related what groovy really is
> > supported on what version
> >
> > and i can't really find anything related to this.. I do get go gradle (and
> > you need 8.5 for java 21) but nothing really related to the actual groovy
> > version and what groovy is supporting (not from but until)
> >
> >
> > I do find more people with the same problem, but no real answers on those
> > questions..
> >
> > johan
> >
> >
> >
> >
> > --
> > Johan Compagner
> > Servoy
> >


Re: AST Transformation in Groovy 4.0.x VS 3.0.x

2024-04-14 Thread Paul King
Can you give us more of the stack trace where Groovy is failing for
the "size==0" error?

I would in general expect very few changes needed between 3 and 4.
Groovy's built-in AST transforms had almost no changes.

Cheers, Paul.

On Sun, Apr 14, 2024 at 11:31 AM Adrien Guichard
 wrote:
>
> Is there any guideline to port AST Transformations for Groovy 4.0 ?
>
> I am porting Taack-UI to Groovy 4.0, and I am stuck with errors like:
> [. . . ]
>   General error during instruction selection: size==0
> [. . .]
>
> At the moment I just added casts at ReturnStatements. (See 
> https://github.com/Taack/infra/blob/main/taack-ui/src/main/groovy/taack/ast/model/TaackFieldEnumASTTransformation.groovy)
>
> Thanks !
>
> --
> Adrien Guichard
> + 33 6 10 78 75 88
> https://taack.org
> 29 Boulevard Edgar Quinet
> 75014 Paris
> France


Re: [ANNOUNCE] Groovy 4.0.21 and 5.0.0-alpha-8 Windows installers released

2024-04-09 Thread Paul King
Thanks Keegan!

On Wed, Apr 10, 2024 at 6:54 AM Keegan Witt  wrote:
>
> Windows installers for Groovy 4.0.21 and 5.0.0-alpha-8 are now available.
>
> groovy-4.0.21.msi
> groovy-5.0.0-alpha-8.msi
>
> -Keegan


[ANNOUNCE] Apache Groovy 4.0.21 released

2024-04-09 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.21
of Apache Groovy which includes support for running Groovy on JDK 23.

Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 8 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354415

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 5.0.0-alpha-8 released

2024-04-08 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-8
of Apache Groovy which includes support for running Groovy on JDK 23.

Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is a pre-release of a new version of Groovy.
We greatly appreciate any feedback you can give us when using this version.

This release includes 15 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354408

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: making the most of Groovy in Action 2nd edition

2024-04-02 Thread Paul King
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
 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//GroovyInAction/alltests.groovy: 2: unable to resolve class 
> AntBuilder
>  @ line 2, column 15.
>def ant = new AntBuilder()
>  ^
>
> 1 error
> Thanks!


Re: SQL enhancement request (GROOVY-11342)

2024-03-31 Thread Paul King
On Sat, Mar 30, 2024 at 6:21 AM  wrote:
> Do you have any thoughts around when this enhancement might come out in a 
> release?

Probably in the next couple of weeks pending feedback.

Paul.


Re: SQL enhancement request (GROOVY-11342)

2024-03-28 Thread Paul King
> SQL: INSERT INTO MYTABLE (COL1, COL2) VALUES (0, 1)
> --- eachRow():
> Mar 28, 2024 1:08:49 PM groovy.sql.Sql eachRow
> WARNING: Failed to execute: INSERT INTO MYTABLE (COL1, COL2) VALUES (0, 
> 1) because: This SQL statement does not return a single ResultSet
> SQL did not produce a resultSet but unable to suppress warning
> java.sql.SQLException: This SQL statement does not return a single 
> ResultSet
>
> So the code accessing the column information for the three different examples 
> -
>
> println "  column $colid: column ${colName[colid]}='${element[colid]}' 
> (width=${colWidth[colid]}, type=${colType[colid]})" // from exampleExecute()
> println "  column $colid: column ${colName[colid]}='${element.value}' 
> (width=${colWidth[colid]}, type=${colType[colid]})" // from exampleEachRow()
> println "  column $colid: column ${colName[colid]}='${element.value}' 
> (width=${colWidth[colid]}, type=${colType[colid]})" // from exampleRows()
>
> is identical except that exampleEachRow() uses ${element[colid]} versus the 
> ${element.value} for the other two.  I tried converting exampleEachRow() to 
> use ${element.value} but that (surprisingly) generated an error -
>
> --- eachRow():
> row: 0
> Mar 28, 2024 4:04:21 PM groovy.sql.Sql eachRow
> WARNING: Failed to execute: SELECT * FROM MYTABLE because: Column not 
> found: value
>
> Given the strangeness of the two examples I have attached both versions, 
> being careful not to modify anything.  My version uses a Denodo database, 
> which is the target database that I need to use.  I've worked with Denodo for 
> a few years now and it's JDBC interface has seemed to be pretty standard from 
> what I've seen.  We use it with probably about 60-75 developers using Java 
> and Python (and PowerBI using ODBC) and have never run into any driver 
> anomalies, though Python has been somewhat painful with its weird JayDeBeApi 
> driver (basically it can be slow with very large resultSets, 1B+ rows).  It 
> was that JayDeBeApi driver that initially led me to Groovy since Groovy has a 
> smooth natural Java database driver integration.  These developers ported 
> their skillsets over to Denodo from earlier Oracle/Teradata/SQLServer/MySQL 
> environments and have basically found Denodo to be a plug-n-play drop-in 
> replacement for their earlier databases.
>
> I was happy to see that apparently I understood how to handle the two closure 
> calls correctly!  And you didn't (seem to) throw up when you saw my 
> metaClosure definition with its three parallel lists!  If there's a 
> better/groovier way to accomplish what I'm doing in that closure I'm open to 
> learning.   :)
>
> Apologies for the lengthy email and thanks again,
> Steve
>
> -Original Message-
> From: Paul King 
> Sent: Thursday, March 28, 2024 7:39 AM
> To: users@groovy.apache.org
> Subject: Re: SQL enhancement request (GROOVY-11342)
>
> Here is the result of running a slightly modified version of your script (I 
> attached it to the issue) after applying the PR I just
> created:
>
> > groovy SqlExamples2.groovy execute
> --- main():
> SQL: CREATE TABLE MYTABLE (COL1 integer, COL2 integer)
> --- execute() [no metadata available]:
> successful execution (with no resultSet)
>   rows updated = 0
> --- main():
> SQL: INSERT INTO MYTABLE (COL1, COL2) VALUES (0, 1)
> --- execute() [no metadata available]:
> successful execution (with no resultSet)
>   rows updated = 1
> --- main():
> SQL: DELETE FROM MYTABLE WHERE COL1=1
> --- execute() [no metadata available]:
> successful execution (with no resultSet)
>   rows updated = 0
> --- main():
> SQL: INSERT INTO MYTABLE (COL1, COL2) VALUES (0, 1)
> --- execute() [no metadata available]:
> successful execution (with no resultSet)
>   rows updated = 1
> --- main():
> SQL: SELECT * FROM MYTABLE
> --- execute() [no metadata available]:
> query produced a resultSet
> row 0:
>   column 0: column COL1='0' (width=11, type=4)
>   column 1: column COL2='1' (width=11, type=4) row 1:
>   column 0: column COL1='0' (width=11, type=4)
>   column 1: column COL2='1' (width=11, type=4)
> --- main():
> SQL: DELETE FROM MYTABLE WHERE COL1=0
> --- execute() [no metadata available]:
> successful execution (with no resultSet)
>   rows updated = 2
>
> The eachRow variant worked fine for me. You could try yourself using the 
> modified script - it uses hsqldb, so no need to add your database driver. 
> Maybe the issue you were having is specific to your database/driver. To test 
> the execute path, you'd need to use a snapshot version.
>
> Paul.
>
> On Thu, Mar 28, 2024 at 10:46 AM  wrote:
> >
> &g

Re: SQL enhancement request (GROOVY-11342)

2024-03-28 Thread Paul King
For example, I never could get the exampleEachRow() to completely work; 
> it processes the rows but I couldn't get it to iterate over the columns the 
> way that the other two methods do.
>
> And any educational feedback you might have would be greatly appreciated!  
> After all I'm sure you have plenty of free time to donate!  :D
>
> So the approach you mentioned of adding a new variant to execute() that adds 
> a metaClosure would be perfect, though I've really gotten comfortable with 
> the rows() method - not sure how it scales when resultSets go to billions of 
> rows though...  I expect execute() would perform like a streaming interface 
> and not have any problems at scale.
>
> Thanks for all your help, couldn't have made it this far otherwise,
> Steve
> -Original Message-
> From: Paul King 
> Sent: Monday, March 25, 2024 8:03 PM
> To: users@groovy.apache.org
> Subject: Re: SQL enhancement request
>
> Adding a metaClosure to execute seems the easiest change. I created
> GROOVY-11342 to track here:
>
> https://issues.apache.org/jira/browse/GROOVY-11342
>
> Would the expectation be that the metaClosure is called for each result 
> producing a ResultSet?
>
> Paul.
>
> On Sat, Mar 23, 2024 at 3:40 AM  wrote:
> >
> > Thanks Jörg,
> >
> > Yes, that's one of the approaches I tried but the execute() method doesn't 
> > appear to provide metadata (column names, types, etc) and my application 
> > needs that information.
> >
> > That's why my request was to either
> >
> >   - add the "hasResults" argument to the rows() and eachRow() methods
> >
> > OR
> >
> >   - add metadata results to the execute() method.
> >
> > The relevant variants that I'm seeing are:
> >
> > eachRow(String sql, Closure metaClosure, Closure rowClosure)
> > eachRow(GString gstring, Closure metaClosure, Closure rowClosure)
> >
> > rows(String sql, Closure metaClosure)
> > rows(GString gstring, Closure metaClosure)
> >
> > execute(String sql, Closure processResults)
> > execute(GString gstring, Closure processResults)
> >
> > where for the eachRow() and rows() methods -
> >
> > sql - the sql statement
> > metaClosure - called for metadata (only once after sql execution)
> > rowClosure - called for each row with a GroovyResultSet
> >
> > and for the execute() method -
> >
> > sql - the SQL to execute
> > processResults - a Closure which will be passed two parameters: either 
> > true plus a list of GroovyRowResult values derived from 
> > statement.getResultSet() or false plus the update count from 
> > statement.getUpdateCount(). The closure will be called for each result 
> > produced from executing the SQL.
> >
> > The processResults() closure that execute() calls is passed two parameters, 
> > while the rowClosure() closure that eachRow() and rows() calls only appears 
> > to pass the one parameter, the GroovyResultSet.
> >
> > My enhancement request is to align these three method "families" (eachRow, 
> > rows, and execute) so that they all have a variant with a metaClosure 
> > and/or a two-parameter processResults closure.
> >
> > Thanks,
> > Steve
> >
> > -Original Message-
> > From: Jörg Prante 
> > Sent: Friday, March 22, 2024 12:03 PM
> > To: users@groovy.apache.org
> > Subject: Re: SQL enhancement request
> >
> > Hi Steve,
> >
> > just use this Sql.execute method
> >
> > https://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html#execu
> > te(java.lang.String,groovy.lang.Closure)
> >
> > to send arbitrary statements and decide by the isResultSet flag in the 
> > closure whether you have to obtain a result set from a select query, or an 
> > update counter or something from a non-result set query (update, insert, 
> > delete).
> >
> > There is a short example in the documentation.
> >
> > Best regards,
> >
> > Jörg
> >
> > Am Donnerstag, dem 21.03.2024 um 14:18 -0500 schrieb
> > steve.etchel...@gmail.com:
> > > Groovy team,
> > >
> > > It is my understanding (which can always be improved!) that Groovy
> > > SQL supports about 3 “families” of interaction methods – execute()
> > > and its variants, rows() and eachRow() for submitting SQL statements
> > > and processing any results generated.
> > >
> > > Each of them has a variety of signatures and they are for the most
> > > part really “groovy” and a pleasure to work 

Re: SQL enhancement request

2024-03-25 Thread Paul King
Adding a metaClosure to execute seems the easiest change. I created
GROOVY-11342 to track here:

https://issues.apache.org/jira/browse/GROOVY-11342

Would the expectation be that the metaClosure is called for each
result producing a ResultSet?

Paul.

On Sat, Mar 23, 2024 at 3:40 AM  wrote:
>
> Thanks Jörg,
>
> Yes, that's one of the approaches I tried but the execute() method doesn't 
> appear to provide metadata (column names, types, etc) and my application 
> needs that information.
>
> That's why my request was to either
>
>   - add the "hasResults" argument to the rows() and eachRow() methods
>
> OR
>
>   - add metadata results to the execute() method.
>
> The relevant variants that I'm seeing are:
>
> eachRow(String sql, Closure metaClosure, Closure rowClosure)
> eachRow(GString gstring, Closure metaClosure, Closure rowClosure)
>
> rows(String sql, Closure metaClosure)
> rows(GString gstring, Closure metaClosure)
>
> execute(String sql, Closure processResults)
> execute(GString gstring, Closure processResults)
>
> where for the eachRow() and rows() methods -
>
> sql - the sql statement
> metaClosure - called for metadata (only once after sql execution)
> rowClosure - called for each row with a GroovyResultSet
>
> and for the execute() method -
>
> sql - the SQL to execute
> processResults - a Closure which will be passed two parameters: either 
> true plus a list of GroovyRowResult values derived from 
> statement.getResultSet() or false plus the update count from 
> statement.getUpdateCount(). The closure will be called for each result 
> produced from executing the SQL.
>
> The processResults() closure that execute() calls is passed two parameters, 
> while the rowClosure() closure that eachRow() and rows() calls only appears 
> to pass the one parameter, the GroovyResultSet.
>
> My enhancement request is to align these three method "families" (eachRow, 
> rows, and execute) so that they all have a variant with a metaClosure and/or 
> a two-parameter processResults closure.
>
> Thanks,
> Steve
>
> -Original Message-
> From: Jörg Prante 
> Sent: Friday, March 22, 2024 12:03 PM
> To: users@groovy.apache.org
> Subject: Re: SQL enhancement request
>
> Hi Steve,
>
> just use this Sql.execute method
>
> https://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html#execute(java.lang.String,groovy.lang.Closure)
>
> to send arbitrary statements and decide by the isResultSet flag in the 
> closure whether you have to obtain a result set from a select query, or an 
> update counter or something from a non-result set query (update, insert, 
> delete).
>
> There is a short example in the documentation.
>
> Best regards,
>
> Jörg
>
> Am Donnerstag, dem 21.03.2024 um 14:18 -0500 schrieb
> steve.etchel...@gmail.com:
> > Groovy team,
> >
> > It is my understanding (which can always be improved!) that Groovy SQL
> > supports about 3 “families” of interaction methods – execute() and its
> > variants, rows() and eachRow() for submitting SQL statements and
> > processing any results generated.
> >
> > Each of them has a variety of signatures and they are for the most
> > part really “groovy” and a pleasure to work with.  I really like
> > Groovy and don’t understand why it hasn’t taken the world by storm
> > given its super compatibility with Java.  
> >
> > However, I’ve run across one area that I feel like could benefit from
> > a change/enhancement in the Groovy Sql package.  The execute() methods
> > accept a closure to process the results that come back from the
> > database/driver and that closure accepts two arguments – the first
> > argument specifies whether or not the result set has any results and
> > then the second argument processes any results.  It is that first
> > argument that does not seem to be consistently available in the other
> > methods.  For example, if you were to use the rows() method and the
> > SQL statement was say in INSERT statement then you’ll get an exception
> > stating that the request does not produce a resultSet and there does
> > not appear to be any way to work around it.
> >
> > Of course I could switch from the rows() method to the execute()
> > method but then I (appear) to lose the metadata results (column names,
> > types, etc).
> >
> > My situation is that I do not know in advance what SQL statements are
> > going to be processed, they come from user input.  And I need the
> > metadata information – for those statements that generate results.  I
> > thought maybe I could just use the rows() method and catch any
> > exceptions for statements that do not generate results and then
> > resubmit those statements via execute() but that approach is pretty
> > ugly and seems to generate error messages that are
> > difficult/impossible to suppress.
> >
> > If the other SQL methods supported the “hasResults” flag and/or if the
> > execute() methods supported metadata results I feel like the overall
> > implementation would be 

Re: Odd behaviour of List to Map coercion within function arguments

2024-03-17 Thread Paul King
I am not sure I have the full history of when support started (at
least 15+ years ago) but dynamic Groovy unwraps a list as arguments:

def avg(int a, int b, int c) { (a + b + c)/3 }
assert avg(1, 2, 3) == 2// normal invocation
def nums = [10, 20, 30]
assert avg(nums) == 20// args are a list

It will only do this if the argument is a single List and no method
matching a single List argument was found. Relevant implementation:

https://github.com/apache/groovy/blob/master/src/main/java/groovy/lang/MetaClassImpl.java#L1242
https://github.com/apache/groovy/blob/master/src/main/java/groovy/lang/MetaClassImpl.java#L1246-L1253

You can turn this feature off with @TypeChecked/@CompileStatic.

Cheers, Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sat, Mar 9, 2024 at 7:58 AM Simon Sadedin  wrote:
>
> Hi,
>
> I am trying to understand some behaviour that is causing subtle and odd bugs 
> in our code.
>
> The behaviour is essentially that under very specific circumstances, Groovy 
> is coercing a List of Maps to a single Map. A condensed example is:
>
>class Foo {
> def foo(Map obj) {
> println(obj)
> }
> }
> z = [
> [ a: 1, b:2]
> ]
> f = new Foo()
> f.foo(z)
>
> In here, even though the foo() method requires a Map, the call does not throw 
> a type mismatch exception. Instead, the foo() method receives the Map object 
> that is the first entry of the list as its argument. Consequently, it prints:
>
> [a:1, b:2]
>
> If instead, it is passed a list containing two Maps, eg: z = [ [ a: 1, b:2], 
> [c:1, d:2] ], then it does throw a type conversion error. Also notable is 
> that it will always throw the type conversion error if you attempt to coerce 
> it outside the context of a function call, for example, using z.asType(Map).
>
> So it seems that under very specific circumstances that is both code context 
> and data dependent, Groovy will perform a different type of type conversion 
> to what it would do otherwise.
>
> Can anyone explain why it does this and what the rationale is?
>
> Cheers,
>
> Simon


[ANNOUNCE] Apache Groovy 5.0.0-alpha-7 Released

2024-03-13 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-7 of
Apache Groovy.
This is mostly to fix a minor glitch in the 5.0.0-alpha-6 zip
distribution which affected
users on some platforms (Maven jar artifacts weren't impacted) but also contains
some additional fixes and dependency updates.

Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is a pre-release of a new version of Groovy.
We greatly appreciate any feedback you can give us when using this version.

This release includes 12 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354374

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Apache Groovy 4.0.20 Released

2024-03-13 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.20 of Apache Groovy.
This is mostly to fix a minor glitch in the 4.0.19 zip distribution
which affected
users on some platforms (Maven jar artifacts weren't impacted) but also contains
some additional fixes and dependency updates.

Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 7 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354376

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Apache Groovy 3.0.21 Released

2024-03-01 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.21 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 17 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354073

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 4.0.19 Released

2024-03-01 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.19 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 18 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354149

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Release Apache Groovy 5.0.0-alpha-6

2024-03-01 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-6 of
Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is a pre-release of a new version of Groovy.
We greatly appreciate any feedback you can give us when using this version.

This release includes 29 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354153

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: Cannot process zip file with Groovy

2024-02-15 Thread Paul King
What you are doing to read the zip looks okay.

Just a guess, but it could be that because you haven't written to the
output stream, it is essentially a corrupt data stream as far as NiFi
processing is concerned. What happens if you set "outputStream =
inputStream" as the last line of your callback?

Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Feb 16, 2024 at 8:48 AM James McMahon  wrote:
>
> I am struggling to build a Groovy scri[t I can run from a NiFi ExecuteScript 
> processor to extract from a zip file and stream to a tar archive.
>
> I tried to tackle it all at once and made little progress.
> I am now just trying to read the zip file, and am getting this error:
>
> ExecuteScript[id=ae3e5de5-018d-1000-ff81-b0c807b75086] Error occurred 
> processing FlowFile: org.apache.nifi.processor.exception.ProcessException: 
> IOException thrown from 
> ExecuteScript[id=ae3e5de5-018d-1000-ff81-b0c807b75086]: 
> java.util.zip.ZipException: invalid compression method
> - Caused by: java.util.zip.ZipException: invalid compression method
>
>
> This is my simplified code:
>
>
> import java.util.zip.ZipInputStream
>
> def ff = session.get()
> if (!ff) return
>
> try {
> ff = session.write(ff, { inputStream, outputStream ->
> def zipInputStream = new ZipInputStream(inputStream)
> def entry = zipInputStream.getNextEntry()
> while (entry != null) {
> entry = zipInputStream.getNextEntry()
> }
> } as StreamCallback)
>
> session.transfer(ff, REL_SUCCESS)
> } catch (Exception e) {
> log.error('Error occurred processing FlowFile', e)
> session.transfer(ff, REL_FAILURE)
> }
>
>
> I am able to list and unzip the file at the linux command line, but cannot 
> get it to work from the script.
>
>
> Has anyone had success doing this? Can anyone help me get past this error?
>
>
> Thanks in advance.
>
> Jim
>
>


Re: How to add a ssl server cert for groovy?

2024-02-15 Thread Paul King
Hi David,

Groovy sits on top of the JDK, so if you install cacerts into the JDK
you are using, then Groovy should use them just fine.

Possibly there could be issues depending on what client library you
are using to make the https connection.

Cheers, Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Feb 16, 2024 at 9:25 AM David Karr  wrote:
>
> I work behind a firewall, and it requires that I add a cert for our proxy to 
> the cacerts file in the Java distribution. This works fine.
>
> I have a quite old version of Groovy installed on my desktop, v2.4.21, which 
> is the version used by our Jenkins pipeline script.  I want to test some code 
> in groovyConsole before I try to run it on our CI server. For many things, 
> this works fine. However, I'm trying to iterate on some code that makes a 
> https connection, and I'm getting an error in groovyConsole that I believe is 
> the same error I get when the server cert is missing ("PKIX path building 
> failed"), which isn't surprising because I never installed the root cert in 
> the Groovy distribution.
>
> I've never really looked inside the Groovy distribution before. I don't even 
> see a cacerts file or anything that really looks like it, so it must do this 
> in a different way than the Java distribution. Is it possible that this is 
> because I'm using such an old version of Groovy?


[ANNOUNCE] Apache Groovy 5.0.0-alpha-5 Released

2024-01-19 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-5 of
Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is a pre-release of a new version of Groovy.
We greatly appreciate any feedback you can give us when using this version.

This release includes 21 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354072

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: Groovy on Windows 11, unable to resolve class

2024-01-19 Thread Paul King
Or do you already have GROOVY_HOME set but to somewhere else?


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Jan 18, 2024 at 9:58 PM Søren Berg Glasius  wrote:
>
> I'm not at windows user myself, but seems to remember, that is most likely 
> because of the spaces in "C:\Program Files (x86)\Groovy\"
>
> Den tors. 18. jan. 2024 kl. 11.47 skrev poubelle zenira 
> :
>>
>> I just installed groovy 4 on windows from the installer.
>>
>> When running groovysh I get:
>> "ClassNotFoundException: org.apache.groovy.groovysh.Main"
>>
>> And when trying to import a groovy, i get an "unable to resolve class" error
>>
>> I checked the windows path,
>> GROOVY_HOME is set to C:\Program Files (x86)\Groovy\, where groovy is 
>> installed (I leaved the default installation parameters)
>> And I manually added %GROOVY_HOME%\bin to the path because it was not there.
>>
>> But it still doesn't work.
>
>
>
> --
>
> Med venlig hilsen,
> Søren Berg Glasius
>
> Hedevej 1, Gl. Rye, 8680 Ry
> Mobile: +45 40 44 91 88
> --- Press ESC once to quit - twice to save the changes.


[ANNOUNCE] Apache Groovy 4.0.18 Released

2024-01-18 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.18 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 16 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12354066

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: CommunityOverCode EU CFP closing soon! See you in Bratislava!

2024-01-11 Thread Paul King
Last day today! Get your submissions in!

Cheers, Paul.

On Fri, Jan 5, 2024 at 3:50 PM Paul King  wrote:
>
> Hi folks,
>
> Only a week to go to submit your Apache Groovy talks for
> CommunityOverCode EU in Slovakia, June 2024. We welcome beginner,
> intermediate and advanced talks. You can talk about Groovy or
> Groovy-related projects in the broader Groovy ecosystem. Since slots
> are limited at the conference, it's also a bonus if you talk about
> Groovy and other ASF projects. Plus there's plenty of other great ASF
> tracks.
>
> https://eu.communityovercode.org/
>
> I hope to see you there!
>
> Cheers, Paul.
>
> <https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
> Virus-free.www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: Strange behaviour when using the Grab annotation

2024-01-08 Thread Paul King
If you look up the Javadoc for Grab, you will see that it can be on
more things than just an import. It can be on a type, a method, a
field, a local variable and so forth. It can't be used on a single
statement. The suggestion for placing it on an import statement is
really just a suggestion. It is often preferred to place it there
rather than on a field or single method because it will be applicable
for the whole script regardless of where you place it - you wouldn't
want someone to think the @Grab was only applicable for a particular
method for instance.

If you just have a single println and nothing else, that is a local
variable called "println" which will come from the binding and have
value null since you haven't defined any value.

Cheers, Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sun, Jan 7, 2024 at 7:21 PM Clemens Quoss  wrote:
>
> Hello Bob!
>
> Thanks for your answer. Yes, of course the right way would be to also use the 
> 'grabbed' dependency in one way or the other.
>
> This test script of mine was for investigating what dependency in a large 
> script of mine pulls in groovy-all:2.4.x making this script unusable with 
> Groovy 4.x due to classpath clashes.
>
> Therefore i wrote this small test script putting in only one Grab at a time 
> and deleting ~/.groovy/grapes between the runs to see what is transitively 
> pulled from what @Grab.
>
> And you do not have to write it like this:
>
> @Grab(...)
> import ...
>
> @Grab(...)
> import ...
>
> Grab is not an annotation for a dedicated import statement. I think this part 
> of the doc is misleading.
>
> BTW, i forgot to mention that the script works if i leave out the "Hallo, 
> Groovy!" part and only work with an empty println.
>
> So i do still believe it is a bug of some sort.
>
> Regards
>
> Clemens
>
> Am 07.01.2024 um 01:31 schrieb Bob Brown:
>
> I think that @Grab needs to be ‘attached’ to something like an import.
>
>
>
> The doco (https://groovy-lang.org/grape.html) says:
>
>
>
> “””
>
> Note that we are using an annotated import here, which is the recommended way.
>
> “””
>
>
>
> Take a look at:
>
>
>
> https://dzone.com/articles/groovy-and-jsch-sftp
>
>
>
> HTH
>
>
>
> BOB
>
>
>
> From: Quoß, Clemens (UIT) 
> Sent: Sunday, January 7, 2024 7:04 AM
> To: users@groovy.apache.org
> Subject: Strange behaviour when using the Grab annotation
>
>
>
> Hello everyone!
>
>
>
> When I am running this script with 4.0.17 …
>
> >>>
> @GrabResolver(name = 'nexus', root = 'https://…')
>
> @Grab(group = 'com.jcraft', module = 'jsch', version = '0.1.55')
>
>
>
> println "Hallo, Groovy!"
>
> <<<
>
> … I am getting this:
>
> >>>
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
>
> C:\Temp\test.groovy: 4: Unexpected input: '"Hallo, Groovy!"' @ line 4, column 
> 9.
>
>println "Hallo, Groovy!"
>
>^
>
>
>
> 1 error
>
> <<<
>
> When I remove the Grapes annotations everything works as expected.
>
>
>
> Has anyone encountered similar issues? Is there a cure? Is this considered a 
> bug? To me it looks that way. But maybe I am missing something here.
>
> TIA
>
> Regards
>
>
>
> Union IT-Services GmbH
>
> Clemens Quoß
>
> FDI-INT
>
> Senior Software Entwickler
>
> Neue Mainzer Straße 12
>
> 60311 Frankfurt am Main
>
>
>
> Tel. +49 69 2567 1241
>
> Fax +49 69 2567 61241
>
> Mobil +49 151 55157195
>
> clemens.qu...@union-investment.de
>
>
>
> Sitz der Gesellschaft: Weißfrauenstraße 7, 60311 Frankfurt am Main
>
> Registergericht: Amtsgericht Frankfurt am Main HRB 33314
>
> Geschäftsführer: Stephan Nasterlack, Siegfried Ehlert, Tobias Meier, Gregor 
> Sauerzapf
>
>


CommunityOverCode EU CFP closing soon! See you in Bratislava!

2024-01-04 Thread Paul King
Hi folks,

Only a week to go to submit your Apache Groovy talks for
CommunityOverCode EU in Slovakia, June 2024. We welcome beginner,
intermediate and advanced talks. You can talk about Groovy or
Groovy-related projects in the broader Groovy ecosystem. Since slots
are limited at the conference, it's also a bonus if you talk about
Groovy and other ASF projects. Plus there's plenty of other great ASF
tracks.

https://eu.communityovercode.org/

I hope to see you there!

Cheers, Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Apache Groovy 3.0.20 Released

2023-12-21 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.20 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 59 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353572

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.



Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Apache Groovy 4.0.17 Released

2023-12-21 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.17 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 8 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353979

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Release Apache Groovy 5.0.0-alpha-4

2023-12-21 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-4 of
Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is a pre-release of a new version of Groovy.
We greatly appreciate any feedback you can give us when using this version.

This release includes 16 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353967

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: Groovy 3.0.20 Release Date

2023-12-11 Thread Paul King
We are planning another release before the end of the year - I'll
start discussions with the team. We'll make sure 3_0_X is included. It
would be great if you can use a 3_0_X snapshot version and ensure that
works with Grails.

On Tue, Dec 12, 2023 at 2:00 AM Mattias Reichel
 wrote:
>
> Hello groovy-users!
> I'm new on the mailing list (although a user of groovy myself since pre v1), 
> so first of all, thanks to the "Groovy team" for your excellent work over the 
> years!
>
> I am writing to kindly request information regarding the release of Groovy 
> 3.0.20 or a prospective release date in the near term.
>
> My interest is first and foremost that of 
> https://issues.apache.org/jira/browse/GROOVY-11242 that was promptly 
> addressed after being reported a couple of days ago. I am collaborating with 
> the Grails team in upgrading the Groovy version of Grails 6 to the latest 
> Groovy 3 patch release, and the resolution of this particular issue is 
> essential to overcoming a current roadblock in our efforts.
>
> I understand the complexities involved in the release process and appreciate 
> your hard work in maintaining the quality of the Groovy language project.
>
> Many thanks
> Mattias Reichel


[ANNOUNCE] Apache Groovy 5.0.0-alpha-3 Released

2023-11-29 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-3 of
Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is a pre-release of a new version of Groovy.
We greatly appreciate any feedback you can give us when using this version.

This release includes 49 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353636

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 4.0.16 Released

2023-11-29 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.16 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 26 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353637

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re:

2023-11-12 Thread Paul King
You seem to be wanting to access script bindings but are supplying an
explicit class that isn't a script (doesn't extend Script).
I'd just replace your script definition with this:

final String SCRIPT = "println \"Hello ${foo}\"";

Cheers, Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Nov 13, 2023 at 4:50 AM Jochen Wiedmann
 wrote:
>
> Hi,
>
> could anyone, please, explain to me what to fix in the script below? I
> am getting the error message below:
>
> Thanks,
>
> Jochen
>
>
> <<>>
> : Apparent variable 'foo' was found in a static scope but doesn't
> refer to a local
> variable, static field or class. Possible causes:
> You attempted to reference a variable in the binding or an instance 
> variable
>  from a static context.
>  You misspelled a classname or statically imported field. Please check the
>  spelling.
>  You attempted to use a method 'foo' but left out brackets in a place not
>  allowed by the grammar.
>  @ line 7, column 22.
>  demo.foo = "${foo}";
> <<>>
>
> My Java class looks like this:
>
> <<>>
>  public static void main(String[] args) {
> final String SCRIPT =
> "public class Demo {\n"
> + " public void run() {\n"
> + " System.out.println(\"Hello ${this.foo}\");\n"
> + " }\n"
> + " public static void main(String[] args) {\n"
> + " Demo demo = new Demo().run();\n"
> + " demo.foo = \"${foo}\";\n"
> + " }\n"
>  + "}\n";
> final GroovyShell gsh = new GroovyShell();
> final Map parameters = new HashMap<>();
> parameters.put("foo", "World");
> final Script script = gsh.parse(SCRIPT, new Binding(parameters));
> script.run();
> }
> <<>>
>
>
>
>
> --
> The woman was born in a full-blown thunderstorm. She probably told it
> to be quiet. It probably did. (Robert Jordan, Winter's heart)


Re: 3 > 4 regression

2023-11-01 Thread Paul King
Hmmm, it works with the alpha versions of Groovy 5. There must be a
fix we didn't backport.
A workaround (though shouldn't be needed) is to use an explicit
qualifier, e.g.: "println Foo.wth".
Did you want to create an issue?

Thanks, Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Nov 2, 2023 at 8:57 AM OCsite  wrote:
>
> Hi there,
>
> looks like 3 used to inline private static finals, while 4 does not, which 
> causes the following regression. Is that the intended behaviour, or a bug?
>
> Thanks,
> OC
>
> ===
>
> 1030 ocs /tmp> 
> class Foo {
>
>   private static final String wth='wth'
>
>   def foo() {
>
> 1.times {
>
>   println wth
>
> }
>
>   }
>
> }
>
> class Bar extends Foo { }
>
> new Bar().foo()
>
> 1031 ocs /tmp> /usr/local/groovy-3.0.8/bin/groovy q
>
> wth
>
> 1032 ocs /tmp> /usr/local/groovy-4.0.0-alpha-1/bin/groovy q.m
>
> Caught: java.io.FileNotFoundException: /private/tmp/q.m (/private/tmp/q.m)
>
> java.io.FileNotFoundException: /private/tmp/q.m (/private/tmp/q.m)
>
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method)
>
> at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> 1033 ocs /tmp>
>
> ===


Re: Support for JDK 22-ea?

2023-10-17 Thread Paul King
Hi Francesco,

We have already bumped to the version of ASM that supports JDK22 ea
versions but haven't enabled the 22 constants just yet. I'll try to do
that later this week. Feel free to create a Jira ticket if you'd like
to track the activity. I haven't checked whether anything will be
required on the gmavenplus side of things.

Cheers, Paul.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Oct 17, 2023 at 4:46 PM Francesco Chicchiriccò
 wrote:
>
> Hi there,
> at Syncope we have been using Groovy and GMavenPlus for quite some time now, 
> thank you!
>
> After recently enabling Eclipse Temurin 22-ea for GitHub actions, we found 
> out that the Maven build is failing with following message:
>
> Error:  Failed to execute goal 
> org.codehaus.gmavenplus:gmavenplus-plugin:3.0.2:execute (default) on project 
> syncope: Error occurred while calling a method on a Groovy class from 
> classpath.: InvocationTargetException: BUG! exception in phase 'semantic 
> analysis' in source unit 'Script1.groovy' Unsupported class file major 
> version 66 -> [Help 1]
>
> At present we are using GMavenPlus 3.0.2 and Groovy 4.0.15, declared as 
> follows:
>
>
>  org.codehaus.gmavenplus
>  gmavenplus-plugin
>  3.0.2
>  
>
>  org.apache.groovy
>  groovy-ant
>  4.0.15
>
>  
>
>
> Is there already a version supporting JDK 22-ea? Even SNAPSHOTs would work, 
> it's on our master branch.
>
> TIA
> Regards.
>
> --
> Francesco Chicchiriccò
>
> Tirasa - Open Source Excellence
> http://www.tirasa.net/
>
> Member at The Apache Software Foundation
> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
> http://home.apache.org/~ilgrosso/
>


Re: Using variables in an embedded Groovy script

2023-09-27 Thread Paul King
For a GString, the strings property contains the static parts and the
values property contains the expressions.

def name = 'world'
def gstr = "Hello, $name!"
assert gstr.strings[0] == 'Hello, '
assert gstr.strings[1] == '!'
assert gstr.values[0] == 'world'
assert gstr.toString() == 'Hello, world!'

Your code is just concatenating the static parts. You can just use the
toString() value or in general if you wanted to concatenate by hand
strings[0] + values[0] + strings[1] + values[1] + strings[2] +
values[2] + strings[3] and so forth for as many terms as needed.

Another example:

def gstr = "foo ${1+1} bar ${'w' * 3} baz"
assert gstr.strings == ['foo ', ' bar ', ' baz']
assert gstr.values == [2, 'www']
assert gstr.toString() == 'foo 2 bar www baz'

On Wed, Sep 27, 2023 at 9:45 PM Jochen Wiedmann  wrote:
>
>
> Hi, Paul,
>
> could you, please, explain what you mean? I really have no idea, what you 
> mean.
>
> Thanks,
>
> Jochen
>
>
> On 2023/09/25 15:07:28 Paul King wrote:
> > You'd need to interleave the values from the GString.
> >
> > On Tue, Sep 26, 2023 at 12:43 AM Jochen Wiedmann
> >  wrote:
> > >
> > > Hi,
> > >
> > > can anyone advise me, what is wrong with the following code: I'd
> > > expect it to write out the word "Okay". Instead, it throws the
> > > exception "Unexpected result: Hello, !"
> > >
> > > final String scriptStr = "return \"Hello, $name!\";";
> > > final GroovyShell gs = new GroovyShell();
> > > final Script script = gs.parse(new StringReader(scriptStr));
> > >
> > > final Binding binding = new Binding();
> > > binding.setProperty("name", "world");
> > > script.setBinding(binding);
> > >
> > > final GStringImpl gsi = (GStringImpl) script.run();
> > > final String[] gsArray = gsi.getStrings();
> > > final String result;
> > >
> > > if (gsArray == null || gsArray.length == 0) {
> > > result = null;
> > > } else {
> > > result = String.join("", gsArray);
> > > }
> > >
> > > if (!"Hello, world!".equals(result)) {
> > > throw new IllegalStateException("Unexpected result: " + result);
> > > }
> > > System.out.println("Okay.");
> > >
> > >
> > >
> > > --
> > > The woman was born in a full-blown thunderstorm. She probably told it
> > > to be quiet. It probably did. (Robert Jordan, Winter's heart)
> >


Re: Using variables in an embedded Groovy script

2023-09-25 Thread Paul King
You'd need to interleave the values from the GString.

On Tue, Sep 26, 2023 at 12:43 AM Jochen Wiedmann
 wrote:
>
> Hi,
>
> can anyone advise me, what is wrong with the following code: I'd
> expect it to write out the word "Okay". Instead, it throws the
> exception "Unexpected result: Hello, !"
>
> final String scriptStr = "return \"Hello, $name!\";";
> final GroovyShell gs = new GroovyShell();
> final Script script = gs.parse(new StringReader(scriptStr));
>
> final Binding binding = new Binding();
> binding.setProperty("name", "world");
> script.setBinding(binding);
>
> final GStringImpl gsi = (GStringImpl) script.run();
> final String[] gsArray = gsi.getStrings();
> final String result;
>
> if (gsArray == null || gsArray.length == 0) {
> result = null;
> } else {
> result = String.join("", gsArray);
> }
>
> if (!"Hello, world!".equals(result)) {
> throw new IllegalStateException("Unexpected result: " + result);
> }
> System.out.println("Okay.");
>
>
>
> --
> The woman was born in a full-blown thunderstorm. She probably told it
> to be quiet. It probably did. (Robert Jordan, Winter's heart)


[ANNOUNCE] Apache Groovy 4.0.15 Released

2023-09-14 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.15 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 12 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353571

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 5.0.0-alpha-2 Released

2023-09-14 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-2 of
Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is a pre-release of a new version of Groovy.
We greatly appreciate any feedback you can give us when using this version.

This release includes 20 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353570

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Groovy turns 20!

2023-08-25 Thread Paul King
Happy Birthday to Groovy!

After over 2 billion downloads, 240 releases, 4+ commits, and over 450
contributors, next Monday, Groovy turns 20!!

Join a few of us (virtually) for a casual meet and greet to celebrate the
occasion. This is a live interactive session where we'll chat about all
things Groovy. Everyone is invited!

https://zoom.us/webinar/register/7216929801435/WN_ER2YfNZJQGW_Qbq9JNxwwg

Cheers, Paul.


Community over Code Groovy track in Halifax

2023-08-25 Thread Paul King
Hi folks,

We are very excited to be offering some great sessions in the Groovy
track at the ASF's flagship NA conference Community over Code:

https://communityovercode.org/schedule/

Come along and learn:

* The latest details for Groovy 4 and 5 including what's happening
with Groovy and Groovy-related frameworks in the Groovy and Java
ecosystems.
* Why Groovy still adds value in 2023 looking at Groovy vs Java
features up to JDK21.
* Lots of tips for Java developers to get up to speed coding and
testing with Groovy including best practices for testing Java code
with Groovy
* How to deploy Groovy kubernetes, Grails and Micronaut applications
to the cloud.
* Look at using Groovy for data science applications with GraalVM for
native application startup speed.
* Explore using Groovy with Apache Ignite for scaling up your data
science applications, looking
at applications from solving Rubik's cubes to clustering Whiskey
flavor profiles.
* Leveraging the features of GORM Data Services in your Groovy applications.
* Taking a step back and look at how the work we do for projects
within the Groovy ecosystem and the broader open source community can
continue to be successful and become a more integral part of our
industry.

Word on the street is that accommodation is filling up fast, and last
year the conference sold out early, so register and book in now!

https://communityovercode.org/registration/

For those that can make it, see you there!

Cheers, Paul.


[ANNOUNCE] Apache Groovy 5.0.0-alpha-1 Released

2023-08-23 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 5.0.0-alpha-1 of
Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This is the first pre-release of our next version of Groovy. We
greatly appreciate any feedback you can give us when using this
version.

We don't recommend you use this version of Groovy in production. It is
not feature complete and is subject to change. Having said that, we
don't anticipate porting to Groovy 5 will be a significant activity
for most users.

This release includes 118 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12351227

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 2.5.23 Released

2023-08-22 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 2.5.23 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_2_5_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 2 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353077

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 3.0.19 Released

2023-08-22 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.19 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 7 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353387

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 4.0.14 Released

2023-08-22 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.14 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.
It is the most recent Groovy version recommended for production use.

This release includes 15 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353386

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: Indy churning through LambdaForm classes

2023-08-07 Thread Paul King
Yes, please create a ticket.

On Mon, Aug 7, 2023 at 11:16 PM Gillespie, Oli 
wrote:

> Hi Jochen,
>
> Thanks for looking, and for the findings - interesting!
>
> Actually I think my reproducer was not a good representation of the real
> issue I saw in production.
> I added the getName() call in my first repro as a random thing to do with
> the argument, but that introduced unintended behaviour.
>
> My real case is closer to this (literally implementations of List, in my
> case):
>
> ```
> def foo(List x) {  }
> def bar(List x) { foo(x) }
> List l1 = new ArrayList();
> List l2 = new LinkedList();
> while (true) {
> bar(l1)
> 127.times { bar(l2) }
> }
> ```
>
> The call site causing the difficulty here is (I think) foo(x) within bar,
> where a 'sameClasses' guard is inserted and
> invalidates the previous method handle whenever the argument class changes
> (LinkedList != ArrayList) -
> I confirmed this by adding logging to the guard.
>
> Oli
>
> P.S. I now have a JIRA account for Groovy, should I create a ticket?
>
>
>
> Amazon Development Centre (London) Ltd. Registered in England and Wales
> with registration number 04543232 with its registered office at 1 Principal
> Place, Worship Street, London EC2A 2FA, United Kingdom.
>
>
>
>


Community Over Code Groovy Track

2023-07-10 Thread Paul King
Hi,

The deadline to submit talks to the Community Over Code conference is only
a few days away and will not be extended. The CFP closes on July 13th.

For the Groovy track, we are interested in topics relating to Groovy or
projects within the broader ecosystem which use Groovy. Talks aimed at
beginner and advanced levels, and everything in between, are welcome.

Please submit a talk at:
https://communityovercode.org/call-for-presentations/.

Community Over Code is an in-person conference and will be held in Halifax,
Nova Scotia, October 7-10, 2023. For more information, see"
https://communityovercode.org/

The ASF also has a Travel Assistance Committee with a small amount of
funding for folks who might not otherwise be able to travel to the
conference. See this link for further details:
https://tac.apache.org/

Regards,
Paul


Re: matcher is failing

2023-07-09 Thread Paul King
Yes, Spencer's info is correct. This script gives an example for a date in
dd-mm-yy[yy] format:

candidate = '14-06-2023'
matcher = candidate =~ /(?x) # enable whitespace and comments
  ^  # start of line
  (0?[1-9]|[12]\d|3[01]) # capture day, e.g. 1, 01, 12, 30
  [\-\/]+# ignore separator
  (\d{1,2})  # capture month, e.g. 1, 01, 12
  [\-\/]+# ignore separator
  (\d{4}|\d{2})  # capture year, e.g. 1975, 23
  $  # end of line
/
(_, day, month, year) = matcher[0]
assert [year, month, day] == ['2023', '06', '14']

You'd need a slight tweak to instead/also handle USA dates in mm-dd-yy[yy]
format.

Cheers, Paul.


On Mon, Jul 10, 2023 at 6:53 AM Spencer Allain via users <
users@groovy.apache.org> wrote:

> You have changed the first grouping into a non-capture group with ?:, so
> matcher[0][3] will be null, and matcher[0][1] will be the month and
> matcher[0][2] will be the year.
>
> I also believe that you should be able to reduce [\\\-\\\/] to be simply
> [-\/] because of using slashy-string for the regex (as only forward slash
> needs to be escaped)
>
> -Spencer
>
> On Sunday, July 9, 2023 at 12:08:17 PM EDT, James McMahon <
> jsmcmah...@gmail.com> wrote:
>
>
> Correction: this is my code...
>
> else if ( candidate =~
> /^(?:0?[1-9]|[12]\d|3[01])[\\\-\\\/]+(\d{2}|\d{1})[\\\-\\\/]+(\d{4}|\d{2})$/
> ) {
>
>   log.error("BINGO!")
>
>   matcher = candidate =~
> /^(?:0?[1-9]|[12]\d|3[01])[\\\-\\\/]+(\d{2}|\d{1})[\\\-\\\/]+(\d{4}|\d{2})$/
>   matchedSubstring = matcher[0][0]
>   log.error("Matcher: ${matcher.toString()}")
>   log.error("Matched substring: ${matchedSubstring}")
>   day = matchedSubstring[matcher[0][1]]
>   month = matchedSubstring[matcher[0][2]]
>   year = matcherSubstriong[matcher[0][3]]
>
>   log.error("Day: ${day}")
>   log.error("Month: ${month}")
>   log.error("Year: ${year}")
>
>   log.error("Length of Day: ${day.length()}")
>   log.error("Length of Month: ${month.length()}")
>   log.error("Length of Year: ${year.length()}")
>
>}
>
> I suspect I need to look at how I'm setting day, month, and year from
> matcher.
>
> The log output:
> 2023-07-09 16:04:47,406 ERROR [Timer-Driven Process Thread-10]
> o.a.nifi.processors.script.ExecuteScript
> ExecuteScript[id=33a5179c-1df4-128b-52be-aaa96b947012] Candidate: 06-14-2023
> 2023-07-09 16:04:47,406 ERROR [Timer-Driven Process Thread-10]
> o.a.nifi.processors.script.ExecuteScript
> ExecuteScript[id=33a5179c-1df4-128b-52be-aaa96b947012] BINGO!
> 2023-07-09 16:04:47,406 ERROR [Timer-Driven Process Thread-10]
> o.a.nifi.processors.script.ExecuteScript
> ExecuteScript[id=33a5179c-1df4-128b-52be-aaa96b947012] Matcher:
> java.util.regex.Matcher[pattern=^(?:0?[1-9]|[12]\d|3[01])[\\\-\\/]+(\d{2}|\d{1})[\\\-\\/]+(\d{4}|\d{2})$
> region=0,10 lastmatch=06-14-2023]
> 2023-07-09 16:04:47,406 ERROR [Timer-Driven Process Thread-10]
> o.a.nifi.processors.script.ExecuteScript
> ExecuteScript[id=33a5179c-1df4-128b-52be-aaa96b947012] Matched substring:
> 06-14-2023
> 2023-07-09 16:04:47,406 ERROR [Timer-Driven Process Thread-10]
> o.a.nifi.processors.script.ExecuteScript
> ExecuteScript[id=33a5179c-1df4-128b-52be-aaa96b947012] Could not parse:
> 06-14-2023
>
> On Sun, Jul 9, 2023 at 11:59 AM James McMahon 
> wrote:
>
> Hello. I have a conditional clause in my Groovy script that attempts to
> parse a date pattern of this form: 06-14-2023. It fails - I believe in the
> matcher.
>
> I am running from a NiFi ExecuteScript processor. Here is my conditional:
>
>   } else if ( candidate =~
> /^(?:0?[1-9]|[12]\d|3[01])[\\\-\\\/]+(\d{2}|\d{1})[\\\-\\\/]+(\d{4}|\d{2})$/
> ) {
>
>   log.error("BINGO!")
>
>   matcher = candidate =~
> /^(?:0?[1-9]|[12]\d|3[01])[\\\-\\\/]+(\d{2}|\d{1})[\\\-\\\/]+(\d{4}|\d{2})$/
>   log.error("Matcher: ${matcher.toString()}")
>   log.error("Matched substring: ${matchedSubstring}")
>   day = matchedSubstring[matcher[0][1]]
>   month = matchedSubstring[matcher[0][2]]
>   year = matcherSubstriong[matcher[0][3]]
>
>   log.error("Day: ${day}")
>   log.error("Month: ${month}")
>   log.error("Year: ${year}")
>
>   log.error("Length of Day: ${day.length()}")
>   log.error("Length of Month: ${month.length()}")
>   log.error("Length of Year: ${year.length()}")
>
>}
>
> My log output tells me I make it into the conditional, but then I fail on
> the matcher:
>
> 2023-07-09 15:52:23,547 ERROR [Timer-Driven Process Thread-2]
> o.a.nifi.processors.script.ExecuteScript
> ExecuteScript[id=33a5179c-1df4-128b-52be-aaa96b947012] Candidate: 06-14-2023
> 2023-07-09 15:52:23,547 ERROR [Timer-Driven 

Re: [ANNOUNCE] Apache Groovy 4.0.13 Released

2023-06-30 Thread Paul King
The search indexing mustn't have caught up with the artifacts yet, but the
artifacts are there:
https://repo.maven.apache.org/maven2/org/apache/groovy/groovy-all/4.0.13/

Cheers, Paul.

<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Jun 30, 2023 at 11:04 AM Alberto Lepe  wrote:

> When it will become available in Maven:
> https://mvnrepository.com/artifact/org.apache.groovy/groovy-all ?
>
> On Thu, 29 Jun 2023 at 17:05, Paul King  wrote:
>
>> Dear community,
>>
>> The Apache Groovy team is pleased to announce version 4.0.13 of Apache
>> Groovy.
>> Apache Groovy is a multi-faceted programming language for the JVM.
>> Further details can be found at the https://groovy.apache.org website.
>>
>> This release is a maintenance release of the GROOVY_4_0_X branch.
>> It is strongly encouraged that all users using prior
>> versions on this branch upgrade to this version.
>>
>> This release includes 25 bug fixes/improvements as outlined in the
>> changelog:
>>
>> https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353213
>>
>> Sources, convenience binaries, downloadable documentation and an SDK
>> bundle can be found at: https://groovy.apache.org/download.html
>> We recommend you verify your installation using the information on that
>> page.
>>
>> Jars are also available within the major binary repositories.
>>
>> We welcome your help and feedback and in particular want
>> to thank everyone who contributed to this release.
>>
>> For more information on how to report problems, and to get involved,
>> visit the project website at https://groovy.apache.org/
>>
>> Best regards,
>>
>> The Apache Groovy team.
>>
>> <
>> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail
>> >
>> Virus-free.www.avast.com
>> <
>> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail
>> >
>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>


[ANNOUNCE] Apache Groovy 3.0.18 Released

2023-06-29 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.18 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 34 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353078

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Apache Groovy 4.0.13 Released

2023-06-29 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.13 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 25 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353213

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Upcoming Groovy birthday

2023-06-27 Thread Paul King
Hi folks,

In just 2 months time, Groovy turns 20. Who has some ideas on how to
celebrate?

I plan to release the first alpha for Groovy 5 by then and also write a
"Using Groovy with JDK21" blog post, expanding on:

https://groovy.apache.org/blog/groovy-sequenced-collections

But these are almost business-as-usual activities, I think our 20th needs
something a little extra special.

Thoughts?

Cheers, Paul.



Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: Planned release date for 4.0.13?

2023-06-25 Thread Paul King
I am planning to prepare a 4.0.13 candidate for voting today or tomorrow.
We have been held up by a Jfrog glitch which has delayed completion of our
CI testing:

https://status.gradle.com/incidents/7x4wqd7zv715

This is mostly fixed but there are still some artifacts like below which
hasn't been reinstated yet which impacts our ability to complete regression
testing of Micronaut builds:

https://plugins.gradle.org/m2/null/groovydoc-gradle-plugin/null/groovydoc-gradle-plugin-null.pom

I am also planning a 3.0.18 release which is also impacted by above and
also I am still completing my review of recent GROOVY-11107
 changes. So that
candidate will be similar to above plus at most one more day.

Cheers, Paul.



Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Jun 26, 2023 at 12:16 PM Alberto Lepe  wrote:

> Is there a planned release date for 4.0.13?
>
> This issue: https://issues.apache.org/jira/browse/GROOVY-11072
> was solved and merged a month ago, but we are still waiting for its release
> so we can release our library.
>
> Thank you.
>


Community over code (formerly ApacheCon) CFP is closing soon

2023-06-19 Thread Paul King
Hi folks,

Community Over Code (formerly @ApacheCon), the ASF's in-person conference,
is October 7-10 in Halifax, Canada. Get your talks in now while the CFP is
still open:

https://communityovercode.org/call-for-presentations/

For the Groovy track, we are interested in topics relating to Groovy or
projects within the broader ecosystem which use Groovy. Beginner and
advanced levels, and everything in between, are welcome.

The ASF also has a Travel Assistance Committee with a small amount of
funding for folks who might not otherwise be able to travel to the
conference. See this link for further details:
https://tac.apache.org/

Cheers, Paul.


Re: isGraalAvailable error

2023-06-10 Thread Paul King
But what exception?

<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sat, Jun 10, 2023 at 11:44 PM Blake McBride  wrote:

> Thanks for the response, Paul!
>
> It is an exception.  The top of the backtrace is:  isGrallAvailable:114,
> JreCompat (org.apache.tomcat.util.compat)
>
> Other elements on the stack trace are as I indicated.
>
> No.  Not using GraalVM.
>
> This is code that ran fine on Java 8. The only change was switching to
> Java 17.
>
> I am seeing the error reported elsewhere on the net, but no clear answer.
>
> Thanks.
>
> Blake
>
> On Sat, Jun 10, 2023 at 8:33 AM Paul King  wrote:
>
>> What is the actual error? Also, are you using GraalVM?
>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
>> Virus-free.www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
>> <#m_315232805499934_m_8909220699781526507_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Sat, Jun 10, 2023 at 11:35 AM Blake McBride 
>> wrote:
>>
>>> I should add that in the stack trace I am seeing:
>>>
>>> loadClass:862 GroovyClassLoader (groovy.lang)
>>> loadClass:973 GroovyClassLoader (groovy.lang)
>>> loadClass:960 GroovyClassLoader(groovy.lang)
>>> loadClass:593, GroovyClassLoader$InnerLoader (groovy.lang)
>>>
>>> Thanks!
>>>
>>> Blake
>>>
>>> On Fri, Jun 9, 2023 at 8:29 PM Blake McBride 
>>> wrote:
>>>
>>>> Greetings,
>>>>
>>>> I am running a tomcat app and getting the following error as follows:
>>>>
>>>> isGrallAvailable:114, JreCompat (org.apache.tomcat.util.compat)
>>>>
>>>> The reason I post it to this group is that it happens when I try to run
>>>> some dynamic Groovy code.  I thought you'll might have an idea.
>>>>
>>>> Java 17
>>>> Tomcat 9.0.65
>>>> Groovy 4.0.11
>>>>
>>>> Sure appreciate any ideas.
>>>>
>>>> Thanks!
>>>>
>>>> Blake McBride
>>>>
>>>


Re: isGraalAvailable error

2023-06-10 Thread Paul King
What is the actual error? Also, are you using GraalVM?



Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sat, Jun 10, 2023 at 11:35 AM Blake McBride  wrote:

> I should add that in the stack trace I am seeing:
>
> loadClass:862 GroovyClassLoader (groovy.lang)
> loadClass:973 GroovyClassLoader (groovy.lang)
> loadClass:960 GroovyClassLoader(groovy.lang)
> loadClass:593, GroovyClassLoader$InnerLoader (groovy.lang)
>
> Thanks!
>
> Blake
>
> On Fri, Jun 9, 2023 at 8:29 PM Blake McBride  wrote:
>
>> Greetings,
>>
>> I am running a tomcat app and getting the following error as follows:
>>
>> isGrallAvailable:114, JreCompat (org.apache.tomcat.util.compat)
>>
>> The reason I post it to this group is that it happens when I try to run
>> some dynamic Groovy code.  I thought you'll might have an idea.
>>
>> Java 17
>> Tomcat 9.0.65
>> Groovy 4.0.11
>>
>> Sure appreciate any ideas.
>>
>> Thanks!
>>
>> Blake McBride
>>
>


Re: Unable to properly tally all keys in nested json

2023-05-12 Thread Paul King
Something like this worked for me:

def topValuesMap = [:].withDefault{ [:].withDefault{ 0 } }
def tallyMap = [:].withDefault{ 0 }
def tally
tally = { Map json, String prefix ->
json.each { k, v ->
String key = prefix + k
if (v instanceof List) {
  tallyMap[key] += 1
  v.each{ tally(it, key + '.') }
} else {
def val = v?.toString().trim()
if (v) {
tallyMap[key] += 1
topValuesMap[key][v] += 1
if (v instanceof Map) tally(v, key + '.')
}
}
}
}

def root = new JsonSlurper().parse(inputStream)
root.each { // each allows json to be a list, not needed if always a map
tally(it, '')
}
println tallyMap
println topValuesMap.collectEntries{ k, m -> [(k), m.sort{ _, v -> -v.value
}] }.take(10)


<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, May 12, 2023 at 8:27 PM James McMahon  wrote:

> Thank you for the response, Paul. I will integrate and try these
> suggestions within my Groovy code that runs in a nifi ExecuteScript
> processor. I'll be working on this once again tonight.
>
> The map topValuesMap is intended to capture this: for each key identified
> in the json, cross-tabulate for each value associated with that key how
> many times it occurs. After the json is fully processed for key, sort the
> resulting map and retain only the top ten values found in the json. If a
> set has a lastName key, the topValuesMap that results might look something
> like this after all keys have been cross-tabulated:
>
> ["lastName": ["Smith" : 1023, "Jones" : 976, "Chang": 899, "Doe": 511,
> ...],
>  "address.street": [.],
> .
> .
> .
> "a final key": [.]
> ]
>
> Each key would have ten values in its value map, unless it cross-tabulates
> to less than ten in total, in which case it will be sorted by count value
> and all values accepted.
> Again, many thanks.
> Jim
>
> On Fri, May 12, 2023 at 2:19 AM Paul King  wrote:
>
>> I am not 100% sure what you are trying to capture in topValuesMap but for
>> tallyMap you probably want something like:
>>
>> def tallyMap = [:].withDefault{ 0 }
>> def tally
>> tally = { Map json, String prefix ->
>> json.each { k, v ->
>> if (v instanceof List) {
>>   tallyMap[prefix + k] += 1
>>   v.each{ tally(it, "$prefix${k}.") }
>> } else if (v?.toString().trim()) {
>> tallyMap[prefix + k] += 1
>> if (v instanceof Map) tally(v, "$prefix${k}.")
>> }
>> }
>> }
>>
>> def root = new JsonSlurper().parse(inputStream)
>> def initialPrefix = ''
>> tally(root, initialPrefix)
>> println tallyMap
>>
>> Output:
>> [name:1, age:1, address:1, address.street:1, address.city:1,
>> address.state:1, address.zip:1, phoneNumbers:1, phoneNumbers.type:2,
>> phoneNumbers.number:2]
>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
>> Virus-free.www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
>> <#m_227840230113638997_m_3707991732434518544_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Fri, May 12, 2023 at 10:38 AM James McMahon 
>> wrote:
>>
>>> I have this incoming json: { "name": "John Doe", "age": 42, "address": {
>>> "street": "123 Main St", "city": "Anytown", "state": "CA", "zip": "12345"
>>> }, "phoneNumbers": [ { "type": "home", "number": "555-1234" }, { "type":
>>> "work", "number": "555-5678" } ] } I wish to tally all the keys in this
>>> json in a map that gives me the key name as its key, and a count of the
>>> number of times the key occurs in the json as its value. For this example,
>>> the keys I expect in my output should include name, age, address,
>>> address.street, address.city, address.state, address.zip, phoneNumbers,
>>> phoneNumbers.type, and phoneNumbers.number. But I do not get that. Instead,
>>> I get this for the list of fields: triage.json.fields
>>> name,age,address,phoneNum

Re: Unable to properly tally all keys in nested json

2023-05-12 Thread Paul King
I am not 100% sure what you are trying to capture in topValuesMap but for
tallyMap you probably want something like:

def tallyMap = [:].withDefault{ 0 }
def tally
tally = { Map json, String prefix ->
json.each { k, v ->
if (v instanceof List) {
  tallyMap[prefix + k] += 1
  v.each{ tally(it, "$prefix${k}.") }
} else if (v?.toString().trim()) {
tallyMap[prefix + k] += 1
if (v instanceof Map) tally(v, "$prefix${k}.")
}
}
}

def root = new JsonSlurper().parse(inputStream)
def initialPrefix = ''
tally(root, initialPrefix)
println tallyMap

Output:
[name:1, age:1, address:1, address.street:1, address.city:1,
address.state:1, address.zip:1, phoneNumbers:1, phoneNumbers.type:2,
phoneNumbers.number:2]



Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, May 12, 2023 at 10:38 AM James McMahon  wrote:

> I have this incoming json: { "name": "John Doe", "age": 42, "address": {
> "street": "123 Main St", "city": "Anytown", "state": "CA", "zip": "12345"
> }, "phoneNumbers": [ { "type": "home", "number": "555-1234" }, { "type":
> "work", "number": "555-5678" } ] } I wish to tally all the keys in this
> json in a map that gives me the key name as its key, and a count of the
> number of times the key occurs in the json as its value. For this example,
> the keys I expect in my output should include name, age, address,
> address.street, address.city, address.state, address.zip, phoneNumbers,
> phoneNumbers.type, and phoneNumbers.number. But I do not get that. Instead,
> I get this for the list of fields: triage.json.fields
> name,age,address,phoneNumbers And I get this for my tally count by key:
> triage.json.tallyMap [name:1, age:1, address:1, phoneNumbers:1]
>
> I am close, but not quite there. I don't capture all the keys. Here is my
> code. How must I modify this to get the result I require? import
> groovy.json.JsonSlurper import org.apache.commons.io.IOUtils import
> java.nio.charset.StandardCharsets def keys = [] def tallyMap = [:] def
> topValuesMap = [:] def ff = session.get() if (!ff) return try {
> session.read(ff, { inputStream -> def json = new
> JsonSlurper().parseText(IOUtils.toString(inputStream,
> StandardCharsets.UTF_8)) json.each { k, v -> if (v != null &&
> !v.toString().trim().isEmpty()) { tallyMap[k] = tallyMap.containsKey(k) ?
> tallyMap[k] + 1 : 1 if (topValuesMap.containsKey(k)) { def valuesMap =
> topValuesMap[k] valuesMap[v] = valuesMap.containsKey(v) ? valuesMap[v] + 1
> : 1 topValuesMap[k] = valuesMap } else { topValuesMap[k] = [:].withDefault{
> 0 }.plus([v: 1]) } } } } as InputStreamCallback) keys =
> tallyMap.keySet().toList() def tallyMapString = tallyMap.collectEntries {
> k, v -> [(k): v] }.toString() def topValuesMapString =
> topValuesMap.collectEntries { k, v -> [(k): v.sort{ -it.value }.take(10)]
> }.toString() ff = session.putAttribute(ff, 'triage.json.fields',
> keys.join(",")) ff = session.putAttribute(ff, 'triage.json.tallyMap',
> tallyMapString) ff = session.putAttribute(ff, 'triage.json.topValuesMap',
> topValuesMapString) session.transfer(ff, REL_SUCCESS) } catch (Exception e)
> { log.error('Error processing json fields', e) session.transfer(ff,
> REL_FAILURE) }
>


[ANNOUNCE] Apache Groovy 4.0.12 Released

2023-05-08 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.12 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 31 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353079

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: Extra linefeeds with groovy.xml.XmlUtil.serialize

2023-03-31 Thread Paul King
If you add ".normalize()", does that make any difference? I am trying to
determine is there are CR chars in the output. Perhaps piping to od or some
octal/hex dump program.

There are also various parser options/features that might be different on
different platforms.

Does XmlSlurper exhibit the same behavior?

Can you try trimWhitespace and keepIgnorableWhitespace on XmlParser?

There are also setFeature and setProperty methods on XmlParser. I don't
think they will help in your case but they have helped for other tricky XML
scenarios.

Cheers, Paul.


On Sat, Apr 1, 2023 at 1:24 AM Nelson, Erick 
wrote:

>
>
>
>
> *From: *Nelson, Erick 
> *Date: *Friday, March 31, 2023 at 7:53 AM
> *To: *users@groovy.apache.org 
> *Subject: *Re: Extra linefeeds with groovy.xml.XmlUtil.serialize
>
> This appears to be a Java problem, not a Groovy problem,  and possibly an
> OpenJDK issue.
>
> I’ve only been able to test this further on my Mac laptop as I cannot
> install different versions of Java*. Redhat ON LINUX*
>
> Java 8 works as expected
>
> I’ve tried Java 10, 11, 17, 18 and 19 and all appear to exhibit this
> behavior
>
>
>
> *From: *Nelson, Erick 
> *Date: *Tuesday, March 21, 2023 at 10:25 AM
> *To: *users@groovy.apache.org 
> *Subject: *Extra linefeeds with groovy.xml.XmlUtil.serialize
>
> I get extra line feeds on my mac when running identical code. Does
> anybody know why this would be?
>
>
>
> *On Linux… (expected output)*
>
>
>
> [tauser02@cfmips01ld0s work]$ groovy -v
> Groovy Version: 4.0.10 JVM: 1.8.0_362 Vendor: Red Hat, Inc. OS: Linux
> [tauser02@cfmips01ld0s work]$ cat test.groovy
> String xml = $/ attr1="value1" attr2="value2"/> attr2="value4"/>/$
> def doc = new groovy.xml.XmlParser().parseText(xml)
> println groovy.xml.XmlUtil.serialize(doc)
> [tauser02@cfmips01ld0s work]$ groovy test.groovy
> 
> 
> 
> 
>
>
>
>
>
>
>
> *On my MAC…(note extra line feeds output)*
>
>
>
> en032339@C02CJMZ8MD6M ~ % groovy -v
>
> Groovy Version: 4.0.10 JVM: 18.0.2.1 Vendor: Eclipse Adoptium OS: Mac OS X
>
> en032339@C02CJMZ8MD6M ~ % cat test.groovy
>
> String xml = $/ attr1="value1" attr2="value2"/> attr2="value4"/>/$
>
> def doc = new groovy.xml.XmlParser().parseText(xml)
>
> println groovy.xml.XmlUtil.serialize(doc)
>
> en032339@C02CJMZ8MD6M ~ % groovy test.groovy
>
> 
>
>
>
>   
>
>
>
>   
>
>
>
> 
>
>
>


[ANNOUNCE] Apache Groovy 4.0.11 Released

2023-03-30 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.11 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 11 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12353000

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 3.0.17 Released

2023-03-30 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.17 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 5 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352999

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 2.5.22 Released

2023-03-30 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 2.5.22 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_2_5_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 23 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352774

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: Planned release date for 2.5.22?

2023-03-21 Thread Paul King
The current plan is before the end of the month, probably next week. I
don't think there is much more planned for that branch before release but
we've only a handful of fixes on the 3_0_X and 4_0_X branches and we'll
likely want to make a few more changes to one of those. We normally release
a couple (sometimes 3) branches together.

Cheers, Paul.

On Tue, Mar 21, 2023 at 12:18 PM Jason Harris (UK) via users <
users@groovy.apache.org> wrote:

> Hi,
>
> Is there a planned release date for 2.5.22?
>
> We are affected by https://issues.apache.org/jira/browse/GROOVY-10918 and
> are unable to upgrade to Groovy 3+
>
> Thanks
>
> Jason
>
>
>  End of message text 
> The New Equation is our global strategy to address the challenges facing
> businesses and society. We take a human-led, tech-powered approach to
> building trust and delivering sustained outcomes. Find out more.
> 
> 
> This email is confidential and is intended for the addressee only. If you
> are not the addressee, please delete the email and do not use it in any way.
> PricewaterhouseCoopers LLP accepts no liability for any use of or reliance
> on this email by anyone, other than the intended addressee to the extent
> agreed in the relevant contract for the matter to which this email relates
> (if any).
> PricewaterhouseCoopers LLP is a limited liability partnership registered
> in England under registered number OC303525, with its registered address at
> 1 Embankment Place, London, WC2N 6RH. It is authorised and regulated by the
> Financial Conduct Authority for designated investment business and by the
> Solicitors Regulation Authority for regulated legal activities. For
> security purposes and other lawful business purposes, PwC monitors outgoing
> and incoming emails and may monitor other telecommunications on its email
> and telecommunications systems.
> 
> Visit our website http://www.pwc.com/uk and see our privacy statement for
> details of why and how we use personal data and your rights (including your
> right to object and to stop receiving direct marketing from us).
> 
>


[ANNOUNCE] Apache Groovy 4.0.10 Released

2023-03-12 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.10 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 18 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352914

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.



Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


[ANNOUNCE] Apache Groovy 3.0.16 Released

2023-03-11 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.16 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 15 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352913

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Virus-free.www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Groovy blogs relocation

2023-02-17 Thread Paul King
Hi folks,

The ASF infra team is encouraging folks to move away from the old roller
blogging system.

Groovy has moved our blog content into our website. You can find it here:

https://groovy.apache.org/blog/

All the old content should redirect automatically to the new system but do
let us know if you spot any glitches.

The new system uses Asciidoc like the rest of the Groovy website. The good
news is, it is now even easier for any folks in the Groovy ecosystem to add
content!

Simply create a PR for the groovy-website repo in the blog folder:

https://github.com/apache/groovy-website/tree/asf-site/site/src/site/blog

Have a look at the other Asciidoc files (.adoc) in that folder to see the
format.

You might want to also send an email to the dev list if you think any
discussion is needed.

Also, there is a preliminary atom feed file at the following location:

https://groovy.apache.org/blog/feed.atom

Please give us feedback if the current format doesn't suit your needs.

Cheers, Paul.


[ANNOUNCE] Apache Groovy 4.0.9 Released

2023-02-08 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.9 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.
OSGi Groovy 4 users should definitely upgrade to 4.0.9.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 9 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352775

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 3.0.15 Released

2023-02-08 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.15 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 15 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352706

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 4.0.8 Released

2023-01-22 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.8 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch and
the current recommended production version of Groovy.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 13 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352707

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 2.5.21 Released

2023-01-21 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 2.5.21 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_2_5_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 11 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352705

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 4.0.7 Released

2022-12-24 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.7 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 69 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352407

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 3.0.14 Released

2022-12-24 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.14 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 26 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352311

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 2.5.20 Released

2022-12-23 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 2.5.20 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_2_5_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 9 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352406

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: [ANNOUNCE] Groovy 2.5.19 and 4.0.6 Windows installers released

2022-10-27 Thread Paul King
The bug with the anonymous login on the Jfrog mirror should be fixed now! Yeah!

On Thu, Oct 20, 2022 at 3:32 PM Paul King  wrote:
>
> If folks are trying to download those links and are taken to a login
> page, just click on the (X) in the top right corner which will then do
> the normal anonymous login. There is a bug in jfrog UI which they are
> fixing as we speak but I am unsure how long before it hits their
> production system.
>
> Cheers, Paul.
>
> On Thu, Oct 20, 2022 at 3:30 PM Paul King  wrote:
> >
> > Thanks Keegan!
> >
> > On Thu, Oct 20, 2022 at 3:20 PM Keegan Witt  wrote:
> > >
> > > Windows installers for Groovy 2.5.19 and 4.0.6 are now available.
> > >
> > > 2.5.19: 
> > > https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-2.5.19/groovy-2.5.19.msi
> > >
> > > 4.0.6: 
> > > https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-4.0.6/groovy-4.0.6.msi
> > >
> > > -Keegan


Re: [ANNOUNCE] Groovy 2.5.19 and 4.0.6 Windows installers released

2022-10-19 Thread Paul King
If folks are trying to download those links and are taken to a login
page, just click on the (X) in the top right corner which will then do
the normal anonymous login. There is a bug in jfrog UI which they are
fixing as we speak but I am unsure how long before it hits their
production system.

Cheers, Paul.

On Thu, Oct 20, 2022 at 3:30 PM Paul King  wrote:
>
> Thanks Keegan!
>
> On Thu, Oct 20, 2022 at 3:20 PM Keegan Witt  wrote:
> >
> > Windows installers for Groovy 2.5.19 and 4.0.6 are now available.
> >
> > 2.5.19: 
> > https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-2.5.19/groovy-2.5.19.msi
> >
> > 4.0.6: 
> > https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-4.0.6/groovy-4.0.6.msi
> >
> > -Keegan


Re: [ANNOUNCE] Groovy 2.5.19 and 4.0.6 Windows installers released

2022-10-19 Thread Paul King
Thanks Keegan!

On Thu, Oct 20, 2022 at 3:20 PM Keegan Witt  wrote:
>
> Windows installers for Groovy 2.5.19 and 4.0.6 are now available.
>
> 2.5.19: 
> https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-2.5.19/groovy-2.5.19.msi
>
> 4.0.6: 
> https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-4.0.6/groovy-4.0.6.msi
>
> -Keegan


[ANNOUNCE] Apache Groovy 4.0.6 released

2022-10-16 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.6 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 14 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352278

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 2.5.19 released

2022-10-15 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 2.5.19 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_2_5_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 72 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352130

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 3.0.13 Released

2022-09-18 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.13 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 44 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352131

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 4.0.5 Released

2022-09-09 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.5 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 56 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12352126

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: Google search results for Groovy give status 403 Forbidden

2022-07-27 Thread Paul King
It would be nice if Google used "latest" rather than "next" if both
are found. That's the sort of thing that a robots.txt file might have
handled previously.
I think you are supposed to use a META TAG per page these days: .
But it isn't a case that we don't want it to follow the page for new
functionality. If anyone has knowledge in this area, please spread
the word or dive on in with a PR.

Cheers, Paul.

On Wed, Jul 27, 2022 at 7:20 PM Alexander Veit  wrote:
>
> Am 27.07.22 um 10:13 schrieb Paul King:
> > Should be fixed now. Thanks for spotting that.
>
> Works. However, I wonder why Google ranks unreleased version 5 highest.
>
> As an example search for "groovy define function".
>
>
> > On Wed, Jul 27, 2022 at 5:20 PM Alexander Veit  wrote:
> >>
> >> Hi,
> >>
> >> currently I receive lots of 403 errors when following links in Google 
> >> search results.
> >>
> >> E.g. https://docs.groovy-lang.org/docs/next/html/documentation/
> >>
> >> - Alex
>


Re: Google search results for Groovy give status 403 Forbidden

2022-07-27 Thread Paul King
Should be fixed now. Thanks for spotting that.

On Wed, Jul 27, 2022 at 5:20 PM Alexander Veit  wrote:
>
> Hi,
>
> currently I receive lots of 403 errors when following links in Google search 
> results.
>
> E.g. https://docs.groovy-lang.org/docs/next/html/documentation/
>
> - Alex


Re: Defining functions in text processed by the StreamingTemplateEngine

2022-07-23 Thread Paul King
The SimpleTemplateEngine supports methods (and imports and even local class
definitions):

def text = """\
<%
import java.time.LocalDate
import java.time.format.TextStyle

def now = LocalDate.now()

def dayName(theDate) {
theDate.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.default)
}
class Const {
  static days = 3
}
%>
# Hello

Today (<%= dayName(now) %>) is <%= now %>.

The weather in next <%= Const.days %> days will be:
<%
  def weather = [ "Sunny", "Rainy", "Cloudy", "Windy" ]
  Const.days.times {
out.println "- " + dayName(now + it) + ": " + weather.shuffled()[0]
  }
%>
""".stripIndent()

def engine = new groovy.text.SimpleTemplateEngine()
def template = engine.createTemplate(text)
println template.make()


Cheers, Paul.


On Sun, Jul 24, 2022 at 6:35 AM Per Nyfelt  wrote:

> I figured it out. although functions (methods) cannot be defined, a
> closure works fine:
>
> def text = """\<% def now = java.time.LocalDate.now() def dayName = { theDate 
> ->return 
> theDate.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, 
> java.util.Locale.getDefault())}%># HelloToday (<%= dayName(now) %>) is <%= 
> now %>.The weather in next 3 days will be:<%  def weather = [ "Sunny", 
> "Rainy", "Cloudy", "Windy" ]  for (i = 1; i < 4; i++) {def day = 
> now.plusDays(i)Collections.shuffle weatherout.println "- " + 
> dayName(day) + ": " + weather.first()  }%>""".stripIndent()def engine = new 
> StreamingTemplateEngine()def template = engine.createTemplate(text)println 
> template.make()
>
>
> On 7/23/22 19:59, Per Nyfelt wrote:
>
> Hi,
>
> I am trying to use the StreamingTemplateEngine to create dynamic markdown
> (similarly to the rmd (r markdown,
> https://rmarkdown.rstudio.com/authoring_quick_tour.html) but I've
> encountered a snag:
>
> Simple usage such as the following works fine using the
> StreamingTemplateEngine:
>
> def text = """\  <%   def now = java.time.LocalDate.now()   %>  # Hello  
> Today (<%= now.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, 
> java.util.Locale.getDefault()) %>) is <%= java.time.LocalDate.now() %>.  The 
> weather in next 3 days will be:  <%def weather = [ "Sunny", "Rainy", 
> "Cloudy", "Windy" ]for (i = 1; i < 4; i++) {  def day = 
> now.plusDays(i)  def dayName = 
> day.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, 
> java.util.Locale.getDefault())  Collections.shuffle weather  
> out.println "- " + dayName + ": " + weather.first()}  
> %>""".stripIndent()def engine = new StreamingTemplateEngine()def template = 
> engine.createTemplate(text)println template.make()
>
> But if if want to define a function to simplify the code e.g.
>
> def text = """\  <%   def now = java.time.LocalDate.now()   def 
> dayName(java.time.LocalDate theDate) {return 
> theDate.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, 
> java.util.Locale.getDefault())  }  %>  # Hello  Today (<%= dayName(now) %>) 
> is <%= now %>.  The weather in next 3 days will be:  <%def weather = [ 
> "Sunny", "Rainy", "Cloudy", "Windy" ]for (i = 1; i < 4; i++) {  def 
> day = now.plusDays(i)  Collections.shuffle weather  out.println "- " 
> + dayName(day) + ": " + weather.first()}  %>""".stripIndent()def engine = 
> new StreamingTemplateEngine()def template = 
> engine.createTemplate(text)println template.make()
>
> ...the StreamingTemplateEngine does not accept the function definition:
>
>
> Template parse error 'Unexpected input: '(' ' at line 4, column 12
>  3:
>  --> 4: def dayName(java.time.LocalDate theDate) {
>  5: return
> theDate.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL,
> java.util.Locale.getDefault())
>
> groovy.text.TemplateParseException: Template parse error 'Unexpected
> input: '(' ' at line 4, column 12
>  3:
>  --> 4: def dayName(java.time.LocalDate theDate) {
>  5: return
> theDate.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL,
> java.util.Locale.getDefault())
>
>
> If there a way to define function in the text processed that would work
> with the StreamingTemplateEngine?
>
>
> The code works fine "the other way around" i.e from Groovy code:
>
> def now = java.time.LocalDate.now()
>
> def dayName(java.time.LocalDate theDate) {
> return
> theDate.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL,
> java.util.Locale.getDefault())
> }
>
> println "# Hello"
>
> println "Today ${dayName(now)}) is ${now}."
>
> println "The weather in next 3 days will be:"
>
> def weather = [ "Sunny", "Rainy", "Cloudy", "Windy" ]
> for (i = 1; i < 4; i++) {
>   def day = now.plusDays(i)
>   Collections.shuffle weather
>   println "- " + dayName(day) + ": " + weather.first()
> }
>
> But I would like a "Markdown first" kind of experience rather than a
> "Groovy first" since in the "normal" case, the amount of text vastly
> outnumbers the amount of code.
>
>
> Best regards,
>
> Per
>
>
>


[ANNOUNCE] Apache Groovy 4.0.4 Released

2022-07-23 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.4 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 42 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12351811

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 3.0.12 Released

2022-07-22 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 3.0.12 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_3_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 21 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12351799

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


[ANNOUNCE] Apache Groovy 2.5.18 Released

2022-07-22 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 2.5.18 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_2_5_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 15 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12351798

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


Re: Using Groovy 4.0.1 and want to use Groovys JsonSlurper or whatever it might be called in version 4.

2022-07-10 Thread Paul King
On Mon, Jul 11, 2022 at 3:00 AM Guillaume Laforge  wrote:
>
> Which bug ticket are we talking about?
> (The ordering issue in lists)

I am not sure there was ever any issue raised in the Groovy's Jira.
Groovy's JsonSlurper is a port from project Boon. Here is the issue
and fix from project Boon:

https://github.com/boonproject/boon/issues/182
https://github.com/boonproject/boon/commit/fa4c64991609

Basically on JDK1.6 there is an inherent problem with LinkedHashMap
where it can be the subject of a DoS hash collision attack. In the
context of JsonSlurper, by using carefully crafted JSON payloads it is
possible in rare circumstances to implement a DoS attack. It is fixed
(wth a system property) on JDK1.7 and permanently fixed for JDK1.8 and
above. The Boon project decided to forgo map ordering on vulnerable
systems to eliminate the DoS problem. Groovy ported that change to
JsonSlurper. A map is a name-to-value container. The "also preserves
order" property can be thought of as a nice feature to have in
particular circumstances. The thinking I presume when Boon changed the
behavior was that security was more important than the "nice to have"
feature. Users should move to a non-vulnerable JDK version if they
want the nicer behavior.

The summary is that unless folks are stuck on JDK1.6, this shouldn't
affect them.

Here is a nice explanation of the problem explained using cats:

https://www.anchor.com.au/blog/2012/12/how-to-explain-hash-dos-to-your-parents-by-using-cats/


Cheers, Paul.

> Le dim. 10 juil. 2022, 18:49, MG  a écrit :
>>
>> Hi Tommy,
>>
>> I agree: We have often found that using well established Java libraries 
>> together with the power of the Groovy language works well & makes great 
>> sense (e.g. Ebean ORM & Vaadin web-GUI in our case).
>> Groovy's integrated support (for e.g. XML/JSON) is often very dynamic in 
>> nature, something which we often neither need nor want, and the small 
>> overhead of writing a thin, type/schema-safe wrapper around e.g. a generic 
>> Java XML SAX/DOM lib for a specific application case has always turned out 
>> to be well invested & makes the code better readable and easier to refactor.
>>
>> In addition these Java libs have often been debugged and performance 
>> optimized over the years in a way that Groovy finds hard to match, since it 
>> would spread its development manpower very thin.
>> The command-line parsing library coming with Groovy nowadays is a good 
>> example of an imho better suited hybrid approach: It supplies Groovy 
>> goodness over an excellent existing Java library (picocli) G-)
>>
>> Cheers,
>> mg
>>
>>
>>
>> On 10/07/2022 18:03, Tommy Svensson wrote:
>>
>> Hi Paul,
>>
>> Thanks, but after the warning that JSONSlurper can loose order in lists, a 
>> known bug, I decided to go with Jackson Jr, which also allows me to parse 
>> JSON into a Map structure. But since I'm coding entirely in Groovy using 
>> Groovys JSON support would make sense, but the pointed out bug scared me 
>> away :-). I have used Jackson Jr before, it works well.
>>
>> /Tommy
>>
>>
>> Från: Paul King 
>> Svara: users@groovy.apache.org , pa...@asert.com.au 
>> 
>> Datum: 10 juli 2022 at 16:20:43
>> Till: users@groovy.apache.org 
>> Ämne:  Re: Using Groovy 4.0.1 and want to use Groovys JsonSlurper or 
>> whatever it might be called in version 4.
>>
>> Hi Tommy,
>>
>> I wrote a little blog post that might have some of the information you
>> were missing:
>>
>> https://blogs.apache.org/groovy/entry/parsing-json-with-groovy
>>
>> Perhaps some more of that info belongs in the official documentation.
>>
>> Cheers, Paul.
>>
>> On Fri, Jul 8, 2022 at 9:10 PM Tommy Svensson  wrote:
>> >
>> > Hello Groovy people,
>> >
>> > I have code using org.apache.groovy:groovy:4.0.1 and it builds without any 
>> > problems.
>> >
>> > But now I want to use the JSONSlurper and it looks like there is a new 
>> > JSONParser also. That however requires groovy-all from googling. The 
>> > problem is that there seem to be not groovy-all for version 4.0.1. Maven 
>> > completely fails when I add "-all" to "groovy" in my poms. It will not 
>> > download the groovy-all file. I deleted ~/.m2/repository and built again 
>> > and it downloaded all but groovy-all.
>> >
>> > The JSON stuff is not available in the "groovy" artifact.
>> >
>> > So my question really is, I want to use Groovys JSON features, what do I 
>> > need to do to accomplish that ?
>> >
>> > I've completely failed top find any Groovy 4.0 related page other than the 
>> > release notes. Since there are big diffs between versions there must be 
>> > some page for each version I assume ?
>> >
>> > I found this: https://groovy-lang.org/processing-json.html but it is not 
>> > version specific and provides no information on how to get access to it.
>> >
>> > I'm frustrated. Something seemingly simple turned out to be the opposite!
>> >
>> > Any help is appreciated.
>> >
>> > Thanks,
>> > Tommy Svensson
>> >
>> >
>> >
>>
>>


Re: Using Groovy 4.0.1 and want to use Groovys JsonSlurper or whatever it might be called in version 4.

2022-07-10 Thread Paul King
That "bug" is relevant only to Java 1.6 which I am sure most folks
have moved on from. We aren't likely to release any new Groovy
versions supporting that version of Java, so there isn't really
anything to fix at this point.

Cheers, Paul.

On Mon, Jul 11, 2022 at 7:48 AM Owen Rubel  wrote:
>
> Paul,
>
> If you are interested in fixing the bug, here they are talking about it in 
> StackOverflow. 
> https://stackoverflow.com/questions/33018236/how-to-maintain-jsons-order-in-groovys-jsonslurper
>
> I stopped submitting issues as a result of past run-ins in the community but 
> have run into this issue myself which is why I stopped using JsonSlurper.
>
> I honestly switched to JSON.org because it has alot of functionality built 
> into the lib and is very stable lib; not FAST (for sure) but since I cache 
> the parse, don't really care :)
>
> Owen Rubel
> oru...@gmail.com
>
>
> On Sun, Jul 10, 2022 at 9:03 AM Tommy Svensson  wrote:
>>
>> Hi Paul,
>>
>> Thanks, but after the warning that JSONSlurper can loose order in lists, a 
>> known bug, I decided to go with Jackson Jr, which also allows me to parse 
>> JSON into a Map structure. But since I'm coding entirely in Groovy using 
>> Groovys JSON support would make sense, but the pointed out bug scared me 
>> away :-). I have used Jackson Jr before, it works well.
>>
>> /Tommy
>>
>>
>> Från: Paul King 
>> Svara: users@groovy.apache.org , pa...@asert.com.au 
>> 
>> Datum: 10 juli 2022 at 16:20:43
>> Till: users@groovy.apache.org 
>> Ämne:  Re: Using Groovy 4.0.1 and want to use Groovys JsonSlurper or 
>> whatever it might be called in version 4.
>>
>> Hi Tommy,
>>
>> I wrote a little blog post that might have some of the information you
>> were missing:
>>
>> https://blogs.apache.org/groovy/entry/parsing-json-with-groovy
>>
>> Perhaps some more of that info belongs in the official documentation.
>>
>> Cheers, Paul.
>>
>> On Fri, Jul 8, 2022 at 9:10 PM Tommy Svensson  wrote:
>> >
>> > Hello Groovy people,
>> >
>> > I have code using org.apache.groovy:groovy:4.0.1 and it builds without any 
>> > problems.
>> >
>> > But now I want to use the JSONSlurper and it looks like there is a new 
>> > JSONParser also. That however requires groovy-all from googling. The 
>> > problem is that there seem to be not groovy-all for version 4.0.1. Maven 
>> > completely fails when I add "-all" to "groovy" in my poms. It will not 
>> > download the groovy-all file. I deleted ~/.m2/repository and built again 
>> > and it downloaded all but groovy-all.
>> >
>> > The JSON stuff is not available in the "groovy" artifact.
>> >
>> > So my question really is, I want to use Groovys JSON features, what do I 
>> > need to do to accomplish that ?
>> >
>> > I've completely failed top find any Groovy 4.0 related page other than the 
>> > release notes. Since there are big diffs between versions there must be 
>> > some page for each version I assume ?
>> >
>> > I found this: https://groovy-lang.org/processing-json.html but it is not 
>> > version specific and provides no information on how to get access to it.
>> >
>> > I'm frustrated. Something seemingly simple turned out to be the opposite!
>> >
>> > Any help is appreciated.
>> >
>> > Thanks,
>> > Tommy Svensson
>> >
>> >
>> >


Re: Using Groovy 4.0.1 and want to use Groovys JsonSlurper or whatever it might be called in version 4.

2022-07-10 Thread Paul King
Hi Tommy,

I wrote a little blog post that might have some of the information you
were missing:

https://blogs.apache.org/groovy/entry/parsing-json-with-groovy

Perhaps some more of that info belongs in the official documentation.

Cheers, Paul.

On Fri, Jul 8, 2022 at 9:10 PM Tommy Svensson  wrote:
>
> Hello Groovy people,
>
> I have code using org.apache.groovy:groovy:4.0.1 and it builds without any 
> problems.
>
> But now I want to use the JSONSlurper and it looks like there is a new 
> JSONParser also. That however requires groovy-all from googling. The problem 
> is that there seem to be not groovy-all for version 4.0.1. Maven completely 
> fails when I add "-all" to "groovy" in my poms. It will not download the 
> groovy-all file. I deleted ~/.m2/repository and built again and it downloaded 
> all but groovy-all.
>
> The JSON stuff is not available in the "groovy" artifact.
>
> So my question really is, I want to use Groovys JSON features, what do I need 
> to do to accomplish that ?
>
> I've completely failed top find any Groovy 4.0 related page other than the 
> release notes. Since there are big diffs between versions there must be some 
> page for each version I assume ?
>
> I found this: https://groovy-lang.org/processing-json.html but it is not 
> version specific and provides no information on how to get access to it.
>
> I'm frustrated. Something seemingly simple turned out to be the opposite!
>
> Any help is appreciated.
>
> Thanks,
> Tommy Svensson
>
>
>


Re: Using Groovy 4.0.1 and want to use Groovys JsonSlurper or whatever it might be called in version 4.

2022-07-08 Thread Paul King
Just some points of clarification.
* JsonSlurper isn't a static class - no change with respect to its
definition has been made across Groovy3 and 4 apart from the package
renaming to comply with the JPMS split packaging requirements for
JDK9+.
* JsonSlurper doesn't parse into an org.json.JSONObject. It has its own LazyMap.
* The LazyMap is backed by an ordered map unless you are using JDK1.6
and earlier or 1.7 and don't have the "jdk.map.althashing.threshold"
property set. There were known inefficiencies in LinkedHashMap in
those old (> 10 yrs ago) JDKs.

Cheers, Paul.

On Sat, Jul 9, 2022 at 1:37 AM Owen Rubel  wrote:
>
> So JSONSlurper is now a static class but I would warn against using 
> JSONSlurper in some cases as it doesn't maintain ORDER in lists when parsing 
> JSON.
>
> This is a known BUG. But there is a simple solution; JSONSlurper parses into 
> a org.json.JSONObjectand as such, you can easily parse your JSON by simply 
> using JSONObject(text) to parse your text
>
> Owen Rubel
> oru...@gmail.com
>
>
> On Fri, Jul 8, 2022 at 4:10 AM Tommy Svensson  wrote:
>>
>> Hello Groovy people,
>>
>> I have code using org.apache.groovy:groovy:4.0.1 and it builds without any 
>> problems.
>>
>> But now I want to use the JSONSlurper and it looks like there is a new 
>> JSONParser also. That however requires groovy-all from googling. The problem 
>> is that there seem to be not groovy-all for version 4.0.1. Maven completely 
>> fails when I add "-all" to "groovy" in my poms. It will not download the 
>> groovy-all file. I deleted ~/.m2/repository and built again and it 
>> downloaded all but groovy-all.
>>
>> The JSON stuff is not available in the "groovy" artifact.
>>
>> So my question really is, I want to use Groovys JSON features, what do I 
>> need to do to accomplish that ?
>>
>> I've completely failed top find any Groovy 4.0 related page other than the 
>> release notes. Since there are big diffs between versions there must be some 
>> page for each version I assume ?
>>
>> I found this: https://groovy-lang.org/processing-json.html but it is not 
>> version specific and provides no information on how to get access to it.
>>
>> I'm frustrated. Something seemingly simple turned out to be the opposite!
>>
>> Any help is appreciated.
>>
>> Thanks,
>> Tommy Svensson
>>
>>
>>


Re: Using Groovy 4.0.1 and want to use Groovys JsonSlurper or whatever it might be called in version 4.

2022-07-08 Thread Paul King
Hi Tommy, if you add the groovy-json module to your dependencies, you
should be good to go.

The groovy-all dependency is a pom dependency. How to use a pom
dependency differs between build tools. Generally, just telling your
build tool it's a pom might be enough for things to start working
again for you.

There was an issue with differences between how Maven and Gradle
treated our early pom dependencies for Groovy 4 which has been fixed
in later versions. So, upgrading to 4.0.3 might also prove useful.

Cheers, Paul.

On Fri, Jul 8, 2022 at 9:10 PM Tommy Svensson  wrote:
>
> Hello Groovy people,
>
> I have code using org.apache.groovy:groovy:4.0.1 and it builds without any 
> problems.
>
> But now I want to use the JSONSlurper and it looks like there is a new 
> JSONParser also. That however requires groovy-all from googling. The problem 
> is that there seem to be not groovy-all for version 4.0.1. Maven completely 
> fails when I add "-all" to "groovy" in my poms. It will not download the 
> groovy-all file. I deleted ~/.m2/repository and built again and it downloaded 
> all but groovy-all.
>
> The JSON stuff is not available in the "groovy" artifact.
>
> So my question really is, I want to use Groovys JSON features, what do I need 
> to do to accomplish that ?
>
> I've completely failed top find any Groovy 4.0 related page other than the 
> release notes. Since there are big diffs between versions there must be some 
> page for each version I assume ?
>
> I found this: https://groovy-lang.org/processing-json.html but it is not 
> version specific and provides no information on how to get access to it.
>
> I'm frustrated. Something seemingly simple turned out to be the opposite!
>
> Any help is appreciated.
>
> Thanks,
> Tommy Svensson
>
>
>


Re: Type inference runtime error

2022-06-15 Thread Paul King
The key aspect for that example is in the preceding paragraph "When
code is annotated with @TypeChecked".

If you had those three lines in a script called Upper.groovy, you could try:

> groovy --compile-static Upper.groovy

Or in the groovyConsole, you could try something like this:

@groovy.transform.TypeChecked // or CompileStatic
static main(args) {
def message = 'Welcome to Groovy!'
println message.toUpperCase()
println message.upper()
}

You should see the compile time error. The runtime error is the
expected behavior without type checking in play.

Cheers, Paul.

On Thu, Jun 16, 2022 at 5:28 AM Henry <2000n...@gmx.net> wrote:
>
> Hi
>
> In the example of the documentation
> https://groovy-lang.org/semantics.html#type-inference the callout number
> 3 states 'calling |upper| will fail at compile time'. But when I run
> those three lines of code in GroovyConsole I get
> groovy.lang.MissingMethodException which is a runtime exception.
>
> So shouldn't it say '... will fail at runtime'?
>
> Thanks.
>
> Henry
>
>
>


Re: [ANNOUNCE] Groovy 2.5.17, 3.0.11, and 4.0.3 Windows installers released

2022-06-05 Thread Paul King
Nice work Keegan!

On Mon, Jun 6, 2022 at 8:51 AM Keegan Witt  wrote:
>
> Windows installers for Groovy 2.5.17, 3.0.11, and 4.0.3 are now available.
>
> 2.5.17: 
> https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-2.5.17/groovy-2.5.17.msi
> 3.0.11: 
> https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-3.0.11/groovy-3.0.11.msi
> 4.0.3: 
> https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-4.0.3/groovy-4.0.3.msi
>
> -Keegan


[ANNOUNCE] Apache Groovy 4.0.3 Released

2022-06-04 Thread Paul King
Dear community,

The Apache Groovy team is pleased to announce version 4.0.3 of Apache Groovy.
Apache Groovy is a multi-faceted programming language for the JVM.
Further details can be found at the https://groovy.apache.org website.

This release is a maintenance release of the GROOVY_4_0_X branch.
It is strongly encouraged that all users using prior
versions on this branch upgrade to this version.

This release includes 40 bug fixes/improvements as outlined in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123=12351650

Sources, convenience binaries, downloadable documentation and an SDK
bundle can be found at: https://groovy.apache.org/download.html
We recommend you verify your installation using the information on that page.

Jars are also available within the major binary repositories.

We welcome your help and feedback and in particular want
to thank everyone who contributed to this release.

For more information on how to report problems, and to get involved,
visit the project website at https://groovy.apache.org/

Best regards,

The Apache Groovy team.


  1   2   3   4   5   >