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

2024-05-20 Thread MG

Hi Paul,

1. I don't use Python and what you guys are saying is of course
   technically correct for Groovy, but I must admit I have run into the
   same mistake in the past, intuitively assuming that a list would be
   component-wise-comparable to another list in Groovy
1. (At least if teh lists have the same size, but one could
   potentially make the larger list win (i.e. +1 compare result) in
   case all existing elements are equal...)
2. We currently use our own comparable n-tuple class class that gives
   the expected behavior of comparing the 1st, 2nd, 3rd, etc tuple
   member until the result is != zero.
3. It might imho make sense to support this in Groovy directly, e.g.:
1. collectionOfFourVectors.sortByList { [ it.x0, it.x1, it.x2,
   it.x3 ] }
4. It would be even nicer if the standard sort method could be used
   like this, or even make collections component-wise-comparable in
   general, but that would evidently be a much bigger change with some
   breaking change potential.
1. (Although it might not be as bad as it looks, since the current
   behavior is pretty useseless in practice (?))

Cheers,
mg


On 20/05/2024 17:02, Paul King wrote:

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: AST Transformation in Groovy 4.0.x VS 3.0.x

2024-04-14 Thread MG
Just a long shot, but have you checked if this error might be due to a 
broken build or similar, i.e. class files being modified in parallel or 
source files having been modified while the build process was running ?
We see "ArrayIndexOutOfBoundsException: size==0" exceptions from time to 
time during IntelliJ Groovy builds, and the cause is typically as stated 
above. Building anew (sometimes rebuilding a module or the whole project 
is required) typically fixes these... (we had some which were actual 
bugs in the Groovy compiler, but these are very rare).


Cheers,
mg


On 14/04/2024 15:54, Adrien Guichard wrote:

Le dim. 14 avr. 2024 à 12:18, Paul King  a écrit :

Can you give us more of the stack trace where Groovy is failing for
the "size==0" error?

java.lang.ArrayIndexOutOfBoundsException: size==0
at 
org.codehaus.groovy.classgen.asm.OperandStack.ensureStackNotEmpty(OperandStack.java:279)
at org.codehaus.groovy.classgen.asm.OperandStack.replace(OperandStack.java:271)
at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitCastExpression(AsmClassGenerator.java:815)
at org.codehaus.groovy.ast.expr.CastExpression.visit(CastExpression.java:90)
at 
org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:615)
at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:682)
at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:73)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:138)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:111)
at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:462)
at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:409)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106)
at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:557)
at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1100)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1093)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:273)
at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:798)
at 
org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:943)
at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:672)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:636)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:611)
at 
org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:285)
at 
org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:67)
at 
org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:97)
at 
org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:76)
at 
org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
at 
org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at 
org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
at 
org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
at 
org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at 
org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
at 
org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
at 
org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
at 
org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:87)
at 
org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:56)
at 
org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
at 
org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
at 
org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at 
org.gradle.internal.dispatch.Reflect

Re: SQL enhancement request (GROOVY-11342)

2024-03-29 Thread MG
That would be eachRowWithIndex, which would imho be nice to have here, 
as well as for collect (i.e. collectWithIndex)... ;-)


Cheers,
mg


On 29/03/2024 19:17, steve.etchel...@gmail.com wrote:

Basically there's no way to get eachRow() to provide a counter...


Re: Cannot process zip file with Groovy

2024-02-16 Thread MG
I agree, would also recommend using Apache libs, we use e.g. the ZIP 
classes that come with the ant lib in the Groovy distribution 
(org.apache.tools.zip.*):


Here is a quickly sanitzed version of our code (disclaimer: Not 
compiled/tested; Zip64Mode.Always is important if you expect larger files):


InputStream zipInputStream(String compressedFilename) {
    final zipFile = new ZipFile(new File(compressedFilename))
    final zipEntry = (ZipEntry) zipFile.entries.nextElement()
    if(zipEntry === null) { throw new Exception("${zipFile.name} has no 
entries") }

    final zis = zipFile.getInputStream(zipEntry)
    return zis
}

OutputStream zipOutputStream(String filename, String 
compressedFileExtension = "zip") {
    final fos = new FileOutputStream(filename + '.' + 
compressedFileExtension)

    final zos = new ZipOutputStream(fos)
    zos.useZip64 = Zip64Mode.Always // To avoid 
org.apache.tools.zip.Zip64RequiredException: ... exceeds the limit of 
4GByte.
    final zipFileName = 
org.apache.commons.io.FilenameUtils.getName(filename)

    final zipEntry = new ZipEntry(zipFileName)
    zos.putNextEntry(zipEntry)
    return zos
}

Cheers,
mg



On 17/02/2024 00:52, Bob Brown wrote:


MY first thought was “are you SURE it is a kosher Zip file?”

Sometimes one gets ‘odd’ gzip files masquerading as plain zip files.

Also, apparently “java.util.Zip does not support DEFLATE64 compression 
method.” : 
https://www.ibm.com/support/pages/zip-file-fails-route-invalid-compression-method-error


IF this is the case, you may need to use: 
https://commons.apache.org/proper/commons-compress/zip.html


(maybe worth looking at the “Known Interoperability Problems” section 
of the above doc)


May be helpful: https://stackoverflow.com/a/76321625

HTH

BOB

*From:*James McMahon 
*Sent:* Saturday, February 17, 2024 4:20 AM
*To:* users@groovy.apache.org
*Subject:* Re: Cannot process zip file with Groovy

Hello Paul, and thanks again for taking a moment to look at this. I 
tried as you suggested:


- - - - - - - - - -

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()
        }
*outputStream = inputStream*
    } as StreamCallback)

    session.transfer(ff, REL_SUCCESS)
} catch (Exception e) {
    log.error('Error occurred processing FlowFile', e)
    session.transfer(ff, REL_FAILURE)
}

- - - - - - - - - -

Once again it threw this error and failed:

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
It bears repeating: I am able to list and unzip the file at the linux 
command line, but cannot get it to work from the script.
What is interesting (and a little frustrating) is that the NiFi 
UnpackContent /will /successfully unzip the zip file. However, the 
reason I am trying to do it in Groovy is that UnpackContent exposes 
the file metadata for each file in a tar archive - lastModifiedDate, 
for example - but it does /not/ do so for files extracted from zips. 
And I need that metadata. So here I be.
Can I explicitly set my (de)compression in the Groovy script? Where 
would I do that, and what values does one typically encounter for zip 
compression?

Jim

On Thu, Feb 15, 2024 at 9:26 PM Paul King  wrote:

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.


<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>>
Virus-free.www.avast.com <http://Virus-free.www.avast.com>

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>>
<#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 

Re: Displaying the entered command-line options as parsed by clibuilder

2024-01-16 Thread MG

Hi Merlin,

thanks for sharing G-)

Cheers,
mg

On 16/01/2024 16:42, Merlin Beedell wrote:


I thought this might be useful… I wanted an easy way to print the 
parameters passed to groovy CliBuilder.


Unlike the usage() method that prints the ‘how to use’ 
(header/parameter options/footer), I just wanted to print the final 
parsed value set.


(Perhaps something like this could be incorporated into CliBuilder’s 
OptionAccessor - a pretty print method?)
It turns out to be a one liner [for basic single args] and 1 more for 
additional args.  For example…


def cli = new CliBuilder(usage:'''Cryoserver Export to PST''', footer:'''

V1.0 MGB Jul 2020.''')

cli.i(longOpt:'input', args:1, required: true, argName:'filepath', 
type:File, 'a directory containing Cryoserver Export zip files')


cli.o(longOpt:'output', args:1, required: true, argName:'filepath', 
type:File, 'output into this directory')


cli.d(longOpt:'depth',args:1, required: false, argName:'number', 
type:int, defaultValue: '1', 'levels of subdirectories to traverse. 
Default 1.')


cli.m(longOpt:'max',args:1, required: false, argName:'number', 
type:int, defaultValue: '5', 'Max num mails per pst. Default 5.')


cli.t(longOpt:'threads',args:1, required: false, argName:'number', 
type:int, defaultValue: '4', 'number of threads. Default 4.')


cli.w(longOpt:'wrapped', args:0, required: false, defaultValue:false, 
'Include Wrapper? Default = false (strip any wrapper)')


cli.x(longOpt:'filefilter', args:1, required: false, argName:'regex', 
defaultValue: fileMatch, "a regex to select required export files. 
default = $fileMatch")


cli.'?'(longOpt:'help', 'help')

def opts = cli.parse(['-i','b','-o','c', 'plus', 'more'])

if (!opts) { //if invalid opts then it prints usage by default

return

}

*cli.options.options.each {println "-$it.option(${it.longOpt}) = 
${opts[(it.option)]}"}*


*if (opts.arguments()) {println opts.arguments()}*

prints (note – args are in the same order as defined):

-i(input) = b

-o(output) = c

-d(depth) = 1

-m(max) = 5

-t(threads) = 4

-w(wrapped) = false

-x(filefilter) = .*

-?(help) = false

[Plus, more]

Merlin Beedell



Re: Small survey on the usage of the metaclass system and MOP

2024-01-09 Thread MG

Hi Jochen,

we do not use any of these Groovy features - why is that information 
relevant to you ?
If you are gauging if you can remove some potentially unused features 
from Groovy, it might be best to state so - nothing to get people to 
take the time to reply, than to tell them an important feature of their 
language might be cut (or trimmed)... ;-)


Cheers,
mg


On 08/01/2024 16:10, Jochen Theodorou wrote:

Hi all,

I would like to know from users on this list mostly if they are using
specific features of the meta class system and MOP, but especially 
what for.



(1) categories

https://blog.mrhaki.com/2009/09/groovy-goodness-use-categories-to-add.html 


shows an example. Basically you have

use (CategoryClass) {
  // some code and callstack here influenced by CategoryClass
}

I am especially interested in knowing if you try to add a method to code
that is not part if the use-block here.


(2) per instance meta classes

https://groovy-lang.org/metaprogramming.html#_per_instance_metaclass
shows examples here

Anyone using that?

(3) Custom meta class

Anyway trying to force the usage of something else then MetaClassImpl
for the meta class? If you do not understand the question at all, then
the answer would be no.


bye Jochen




Re: Static typing question

2024-01-02 Thread MG

In a sense, yes, but (from the top of my head*):

1. Even in the statically compiled domain with some things missing
1. e.g. many AST-transformation annotations, such as
   @InheritConstructors comes to mind, which we use all the time.
2. Or macros.
2. And also with a syntax (taken from Javascript) imho not well suited
   for a strongly typed language (name : type = value, instead of the
   much more readable type name = value as in all C-like languages).

Cheers,
mg

*Caveat: I only look at Kotlin from time to time, so some of what I say 
may be outdated.





>  @CompileStatic predecessor Groovy++ (which later afaik gave birth 
to Kotlin).


I totally agree here. In a sense Kotlin is a statically-typed Groovy.


--
Dr. Vasileios Anagnostopoulos (MSc,PhD)
Researcher/Developer


Re: Static typing question

2024-01-01 Thread MG

Hi Jochen,

that would actually be great, proceeding into 2024 with fingers crossed G-)

Cheers,
mg


On 01/01/2024 14:46, Jochen Theodorou wrote:

On 01.01.24 00:57, MG wrote:
[...]

**Alas that is not the case for JVM invoke dynamic, which is much slower
when generating a really large number of objects, which recently
required us to make a part of our SQL generation code less user
friendly, to make Groovy 3/4 with invoke dynamic as fast as the old
Groovy-specifc code which did not rely on invoke dynamic...


I think I can give a teaser here... I am currently working on a
prototype that will hopefully solve that issue.

bye Jochen





Re: Static typing question

2023-12-31 Thread MG

Hi Vasileios,

we use our own Groovy framework to develop an in-house multi part web 
application and accompanying SQL & PL/SQL generation framework, and have 
been using Groovy for 10 years, including some dabbling in the 
@CompileStatic predecessor Groovy++ (which later afaik gave birth to 
Kotlin).


Contrary to many ppl here I love static compilation checks - in my book 
there is nothing more annoying than to get an incompatible-type-RTE, and 
it also makes code more readable to use explicit types & easier to 
refactor automatically (e.g. through IntelliJ). And no, I do not have 
time to write a test or execute a Selenium test (suite) before every 
rollout during development, to catch any potential errors of that kind, 
so I would much rather have the compiler catch those, thank you ver 
much* :-)


Having said that, I have come to realize what I actually want to use in 
Groovy 99% of the time is @TypeChecked, not @CompileStatic, and the 
reason for this is simple: Dynamic call site selection. Dynamic call 
site selection is a feature I have already seen people request for 
Kotlin, which e.g. allows one to easily add polymorphic method support 
for newly introduced sub-types, without any refactoring effort (while 
still keeping type safety, i.e. in fully @TypeChecked code).


On the other hand in practice there is most of the time very little to 
nothing to be gained from using @CompileStatic, even in low level code, 
because a) dynamic code execution is highly optimized in Groovy** so 
there is no relevant speed difference, and b) in most cases even that 
would not matter, since performance of business applications is mostly 
bound by database and network performance.


Cheers & a Happy 2024,
mg

*@TypeChecked is not yet perfect here, it on occasion lets code slip 
through, which later leads to a RTE, while sometimes complaining about 
code which is actually valid (most of the time when using generics), but 
it still is of great value, and one can of course always make a method 
fully dynamic as a workaround in these cases (a bit counterintuitively 
not by using @CompileDynamic, but @TypeChecked with TypeCheckingMode.SKIP).


**Alas that is not the case for JVM invoke dynamic, which is much slower 
when generating a really large number of objects, which recently 
required us to make a part of our SQL generation code less user 
friendly, to make Groovy 3/4 with invoke dynamic as fast as the old 
Groovy-specifc code which did not rely on invoke dynamic...



On 30/12/2023 19:17, Agile Developer wrote:

Hi,

I was a  4 years user of Grails/Groovy (last year mostly Python). With 
the general trend of people moving to static languages, is there any 
reason that Groovy needs to stay dynamic?


I see Python having the mypy approach, I see gradle moving to Kotlin 
and FE mostly on Typescript.


I understand that the @CompileStatic is the supported method, but 
having true static typing (with the Script-Like enhancements other 
Languages added, would be beneficial).


Is there still a reason to keep it dynamic? What is the benefit?

--
Dr. Vasileios Anagnostopoulos (MSc,PhD)
Researcher/Developer


Re: [ANNOUNCE] Genetic Programming with Groovy (MirComp 1.0.0-beta.1 Released)

2023-11-05 Thread MG

Hi Mirco,

that sounds really cool, I will forward this to a friend who is into 
composing music & toying with new sounds G-)


Cheers,
mg


On 05/11/2023 18:39, Mirco Colletta wrote:

Hi Apache Groovy community,
I have the pleasure to announce the release of the first beta version 
of MirComp, the framework for algorithmic and assisted music composition:

https://mcolletta.github.io/mircomp/
MirComp is developed in Groovy (currently v4.0.15 with STC by default) 
and can now run as a self-contained application with OpenJdk 21 and 
OpenJfx 21.
This new version contains lots of bug fixes and improvements but the 
main highlights of this release are:


MirGene: a Grammatical Evolution (GE) library.
One of the most interesting things about this library is its powerful 
context sensitive grammars that I've designed for musical purposes. A 
MirGram (as I named it) is stochastic, weighted and adaptable (i.e. it 
can add new rules during the derivation using the results from 
previous NonTerminals). Moreover, it can control the length of the 
results through arithmetic attributes and guards.

https://github.com/mcolletta/mircomp/tree/main/mirgene

MircOracle: a machine learning library that implements dictionary 
based predictors and factor oracles (similar to variable order markov 
models).

https://github.com/mcolletta/mircomp/tree/main/mircoracle

Note: These two libraries are general enough to be used outside 
musical contexts. For example in the source of MirGene you can find 
"symbolic regression" tests.


MirSynth: a library for sound synthesis.
With few lines of code it is possible to create MIDI "virtual" 
instruments like Double Frequency Modulation (DFM), Additive and 
Subtractive Synthesis.


Solfeggio syllables and Roman numerals for universal key composition 
in MirChord.


MusicXml Reader: lead sheets music in MusicXml format can now be read 
and processed by the system.


I've tested the software only on Ubuntu (20.04 and 22.04) so if you 
try the software on other platforms and encounter issues please let me 
know.


Enjoy groovy music and machine learning... in Groovy!

Mirco




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

2022-07-11 Thread MG

Hi Paul,

thanks for clearing that up :-)

(I did not refer to this evident water-under-the-bridge problem (which I 
had never heard of before) in my post, but just wanted to confirm that 
Groovy plays very well with & can easily be used to enhance established 
Java frameworks, and people therefore should not feel the need to use 
functionality that comes bundled with Groovy, if they are familiar with 
or prefer another framework G-) )


Cheers,
mg


On 11/07/2022 05:15, Paul King wrote:

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://gro

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 MG

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  <mailto:pa...@asert.com.au>
Svara: users@groovy.apache.org  
<mailto:users@groovy.apache.org>, pa...@asert.com.au 
 <mailto:pa...@asert.com.au>

Datum: 10 juli 2022 at 16:20:43
Till: users@groovy.apache.org  
<mailto: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: [SPAM] How to use Groovy with Latest Intellij Idea?

2022-05-12 Thread MG
I don't know what the best/official answer here is, but as a workaround: 
If I remember correctly it was still included in the Groovy 3 binaries, 
so you can use that...

Cheers,
mg

On 12/05/2022 22:26, Richard Heintze wrote:
I'm trying to follow these instructions so I can write groovy scripts: 
Getting started with Groovy and Java 11 project | IntelliJ IDEA 
(jetbrains.com) 
<https://www.jetbrains.com/help/idea/getting-started-with-groovy-java-9-project.html#272d161f>


Are these instructions out-of-date? I downloaded the Groovy 4.0.2 
binary and then the Groovy 4.0.2 SDK and I could not find this 
directory called "extras-jaxb"...


Is this supposed to be in the Groovy SDK? Where is it?

How do I run groovy with Idea?

Thanks

Siegfried


Re: STEM applications of Groovy?

2021-11-12 Thread MG

Hi Rick,

never mind, others already took your question to mean what I suggested, 
and I think you already got some good answers :-)


Cheers,
mg

PS: I might just add that Python is imho the hot language by means of 
hype, not by merit of the language itself ;-)



On 12/11/2021 10:50, Rick Van Camp wrote:

Hi mg,

I understand your point. Your wording may be preferred. My point is I 
know Groovy is more powerful than Java yet, Python is the hot language 
in science and engineering. Where does Groovy fit in this range of 
scripting languages?


Does this help?

Rick

On Fri, Nov 12, 2021 at 4:27 PM MG  wrote:

Hi Rick,

should
"but it was only calling operations which performed the
manipulations I am interested in learning if Groovy can perform."
read
"but it was only calling operations which performed the
manipulations. I am interested in learning if Groovy can perform." ?

Or more generally: Could you elaborate what exactly your question
is (and maybe why you are asking it) ?-)

Cheers,
mg


On 12/11/2021 10:14, Rick Van Camp wrote:

Hello,

I joined the list to learn if STEM applications exist for Groovy?
I read through several months of archives but did not see much
involving issues I am interested in such as computation,
simulations, approximations, etc. I used Groovy briefly in an
image processing application but it was only calling operations
which performed the manipulations I am interested in learning if
Groovy can perform.

Thank you,

Rick




Re: STEM applications of Groovy?

2021-11-12 Thread MG

Hi Rick,

should
"but it was only calling operations which performed the manipulations I 
am interested in learning if Groovy can perform."

read
"but it was only calling operations which performed the manipulations. I 
am interested in learning if Groovy can perform." ?


Or more generally: Could you elaborate what exactly your question is 
(and maybe why you are asking it) ?-)


Cheers,
mg


On 12/11/2021 10:14, Rick Van Camp wrote:

Hello,

I joined the list to learn if STEM applications exist for Groovy? I 
read through several months of archives but did not see much involving 
issues I am interested in such as computation, simulations, 
approximations, etc. I used Groovy briefly in an image processing 
application but it was only calling operations which performed the 
manipulations I am interested in learning if Groovy can perform.


Thank you,

Rick


Re: Checking directory state using Groovy

2021-10-20 Thread MG
Don't know if you already know this, but using Groovy property syntax 
makes code even more readable, e.g.:


println "${it}: ${it.getOwner()} ${it.getPosixFilePermissions()}"

can be written as:

println "$it: $it.owner $it.posixFilePermissions"

In general:
1. Any getter can be accessed without the "get" prefix with a lowercase 
first char
2. A simplified string interpolation syntax without the enclosing curly 
braces can be used in these cases

(same goes for setters)

Cheers,
mg


On 20/10/2021 12:14, James McMahon wrote:
Many thanks to each of you who offered guidance. Redirecting back to 
this today, anticipating success given your advice. Still getting a 
feel for Groovy so this helps quite a bit.

Cheers,
-Jim

On Fri, Oct 15, 2021 at 11:22 AM Søren Berg Glasius 
 wrote:


@Rachel Rudnick <mailto:rac...@cirrusidentity.com> that is a very
clever use of *use* - good call!

Best regards / Med venlig hilsen,
Søren Berg Glasius

Hedevej 1, Gl. Rye, 8680 Ry, Denmark
Mobile: +45 40 44 91 88, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.


Den fre. 15. okt. 2021 kl. 17.12 skrev Rachel Greenham
:

Looks like you could pretty much use Files as an extension
module and/or category for Path...

Hang on, does it work?

groovy> import java.nio.file.*
groovy> use (Files) {
groovy>     Path p = Path.of("src/groovy")
groovy>     println "is directory? ${p.isDirectory()}"
groovy>     p.list().each { println "${it}: ${it.getOwner()}
${it.getPosixFilePermissions()}" }
groovy> }

is directory? true
src/groovy/benchmark: rachel [OWNER_WRITE, OTHERS_READ,
OWNER_EXECUTE, GROUP_READ, GROUP_EXECUTE, OTHERS_EXECUTE,
OWNER_READ]
src/groovy/xdocs: rachel [OWNER_WRITE, OTHERS_READ,
OWNER_EXECUTE, GROUP_READ, GROUP_EXECUTE, OTHERS_EXECUTE,
OWNER_READ]
src/groovy/bootstrap: rachel [OWNER_WRITE, OTHERS_READ,
OWNER_EXECUTE, GROUP_READ, GROUP_EXECUTE, OTHERS_EXECUTE,
OWNER_READ]
src/groovy/LICENSE: rachel [OWNER_WRITE, OTHERS_READ,
GROUP_READ, OWNER_READ]
...

oh yeah that works 😉

-- 
Rachel Greenham

rac...@merus.eu

> On 15 Oct 2021, at 15:57, Nelson, Erick
 wrote:
>
> import java.nio.file.Path
> import java.nio.file.Files
>
> File f = new File('test')
> Path p = f.toPath()
> Files.isReadable(p) // boolean
> Files.isWritable(p) // boolean
> Files.isExecutable(p) // boolean
> Files.isDirectory(p) // boolean
> Files.isRegularFile(p) // boolean
>
>
> From: James McMahon 
> Date: Friday, October 15, 2021 at 4:50 AM
> To: users@groovy.apache.org 
> Subject: Checking directory state using Groovy
>
> Hello. I am trying to convert an existing script from python
to Groovy. It executes a number of os.path and os.access
commands, which I've not yet been able to find examples of
that are written in Groovy. I have found similar
implementations that employ "add on" Jenkins libraries for
Groovy, but I will not have access to such libraries.Here is a
brief excerpt from what I now do in python. Has anyone done
similarly in Groovy? Can I impose for an example?
>
> Thanks very much in advance. Here is my python:
>
> if ( os.path.exists(result['thisURL']) and
os.path.isfile(result['thisURL']) ) :
>      if ( os.access(result['thisURL'], os.F_OK)
>           and os.access(result['thisURL'], os.R_OK)
>           and os.access(thisDri, os.W_OK)
>           and os.access(thisDir, os.X_OK) ) :
>           # do some stuff
>       else :
>           # dir and file not accessible, do some different stuff



Re: Update the Groovy color used on github.

2021-06-15 Thread MG

+1

Given that the currently used color is a very unattractive darker 
yellow, the "corporate identity blue" is definitely an upgrade G-)


On 11/06/2021 07:24, Michael Bailey wrote:
I opened a PR to get the Groovy color on Github updated to the blue 
from the logo.
See https://github.com/github/linguist/pull/5418 



If you would like to see Github use the color from the Groovy logo, 
please reply with a +1 to this thread and give a thumbs up on this PR 
-> https://github.com/github/linguist/pull/5418 



The plus one on this thread will help show community support.




Groovy @AnnotationCollector with JUnit 5 => IncompatibleClassChangeError: Foo and Foo$CollectorHelper disagree on InnerClasses attribute

2021-05-18 Thread MG

Hi guys,

I wanted to check if anyone has encountered the following problem and 
has some more insight or a solution, before I create a Groovy ticket:


In short, my code contains some simple @AnnotationCollector|ed 
interfaces, the simplest looking like:


import groovy.transform.AnnotationCollector
import groovy.transform.InheritConstructors

@AnnotationCollector([InheritConstructors])
public @interface Foo{}


Switching to JUnit 5 the following exception now blocks the execution of 
any pattern- or selective-based test suite in IntelliJ under Groovy 
3.0.8 / OpenJDK11U-jdk_x64_windows_hotspot_11.0.9.1_1:


org.junit.platform.commons.JUnitException: TestEngine with ID 
'junit-vintage' failed to discover tests
Caused by: java.lang.IncompatibleClassChangeError: Foo and 
Foo$CollectorHelper disagree on InnerClasses attribute


Some more info:

1. The exception is thrown during the test discovery phase, i.e. before
   any tests get executed.
2. The exception had already occured for some time in a specific test
   under JUnit 4, but it only failed that particular test, and the
   error disappeared when rerunning the test (so I never invested the
   time to investigate further).
3. I am not actually using junit-vintage, but earlier I had the same
   exception two times, one for junit and one for junit-vintage, so I
   do not assume it is actually tied to the junit-vintage, but that in
   this case IntelliJ or JUnit just hides the other exception or such.

Cheers,
mg

PS: I found this similar looking: ticket 
https://issues.apache.org/jira/browse/GROOVY-9405, which was fixed in 
3.0.4 ...








groovy-3.0.7 build error: StringIndexOutOfBoundsException: String index out of range: -1

2021-03-04 Thread MG
...that must have been the weirdest bug I ever tracked down (did not 
help that it was smack in the middle of a big class inside our largest 
module):


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

Issue 9966 feels like a fitting number for this one; fortunately error 
conditions are so special (feels like a quantum superposition), that it 
is really easy to work around, once found... ;-)


Cheers,
mg


 Forwarded Message 
Subject: 	Re: groovy-3.0.7 & groovy-2.5.14 IntelliJ build => Groovyc: 
Internal groovyc error: code 1 ?

Date:   Wed, 3 Mar 2021 01:07:00 +0100
From:   MG 
Reply-To:   users@groovy.apache.org
To: users@groovy.apache.org, Paul King 



Hi Paul,

that did solve the problem, thank you - but it would be nice if an 
oversight like that would not lead to a "no information" internal 
compiler error for us poor no Maven/Gradle build people :-)


Besides some solvable/trivial ones, I encountered another surprising one 
in StaticImportVisitor#getAccessorName (stacktrace below) - maybe coming 
from the NV/NVL macro stubs, or static Table class members...


Cheers,
mg

Error:Groovyc: While compiling groovysql: 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1

        at java.base/java.lang.String.substring(String.java:1841)
        at org.apache.groovy.util.BeanUtils.capitalize(BeanUtils.java:54)
        at 
org.codehaus.groovy.control.StaticImportVisitor.getAccessorName(StaticImportVisitor.java:519)
        at 
org.codehaus.groovy.control.StaticImportVisitor.findStaticPropertyAccessor(StaticImportVisitor.java:528)
        at 
org.codehaus.groovy.control.StaticImportVisitor.findStaticPropertyAccessorGivenArgs(StaticImportVisitor.java:524)
        at 
org.codehaus.groovy.control.StaticImportVisitor.findStaticMethodImportFromModule(StaticImportVisitor.java:505)
        at 
org.codehaus.groovy.control.StaticImportVisitor.transformPropertyExpression(StaticImportVisitor.java:384)
        at 
org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:130)
        at 
org.codehaus.groovy.ast.expr.CastExpression.transformExpression(CastExpression.java:95)
        at 
org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:169)
        at 
org.codehaus.groovy.ast.expr.DeclarationExpression.transformExpression(DeclarationExpression.java:183)
        at 
org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:169)
        at 
org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:108)
        at 
org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
        at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
        at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:164)
        at 
org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
        at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitTryCatchFinally(CodeVisitorSupport.java:133)
        at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitTryCatchFinally(ClassCodeVisitorSupport.java:242)
        at 
org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:47)
        at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
        at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:164)
        at 
org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
        at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:138)
        at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:111)
        at 
org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:66)
        at 
org.codehaus.groovy.control.StaticImportVisitor.visitConstructorOrMethod(StaticImportVisitor.java:108)
        at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106)
        at 
org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1099)
        at 
org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1092)
        at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
        at 
org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$3(CompilationUnit.java:209)
        at 
org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:942)
        at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
        at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
        at 
org.jetbrains.groovy.compiler.rt.GroovyCompil

Re: groovy-3.0.7 & groovy-2.5.14 IntelliJ build => Groovyc: Internal groovyc error: code 1 ?

2021-03-02 Thread MG

Hi Paul,

that did solve the problem, thank you - but it would be nice if an 
oversight like that would not lead to a "no information" internal 
compiler error for us poor no Maven/Gradle build people :-)


Besides some solvable/trivial ones, I encountered another surprising one 
in StaticImportVisitor#getAccessorName (stacktrace below) - maybe coming 
from the NV/NVL macro stubs, or static Table class members...


Cheers,
mg

Error:Groovyc: While compiling groovysql: 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1

    at java.base/java.lang.String.substring(String.java:1841)
    at org.apache.groovy.util.BeanUtils.capitalize(BeanUtils.java:54)
    at 
org.codehaus.groovy.control.StaticImportVisitor.getAccessorName(StaticImportVisitor.java:519)
    at 
org.codehaus.groovy.control.StaticImportVisitor.findStaticPropertyAccessor(StaticImportVisitor.java:528)
    at 
org.codehaus.groovy.control.StaticImportVisitor.findStaticPropertyAccessorGivenArgs(StaticImportVisitor.java:524)
    at 
org.codehaus.groovy.control.StaticImportVisitor.findStaticMethodImportFromModule(StaticImportVisitor.java:505)
    at 
org.codehaus.groovy.control.StaticImportVisitor.transformPropertyExpression(StaticImportVisitor.java:384)
    at 
org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:130)
    at 
org.codehaus.groovy.ast.expr.CastExpression.transformExpression(CastExpression.java:95)
    at 
org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:169)
    at 
org.codehaus.groovy.ast.expr.DeclarationExpression.transformExpression(DeclarationExpression.java:183)
    at 
org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:169)
    at 
org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:108)
    at 
org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
    at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:164)
    at 
org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
    at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitTryCatchFinally(CodeVisitorSupport.java:133)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitTryCatchFinally(ClassCodeVisitorSupport.java:242)
    at 
org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:47)
    at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:164)
    at 
org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:138)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:111)
    at 
org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:66)
    at 
org.codehaus.groovy.control.StaticImportVisitor.visitConstructorOrMethod(StaticImportVisitor.java:108)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106)

    at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1099)
    at 
org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1092)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
    at 
org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$3(CompilationUnit.java:209)
    at 
org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:942)
    at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
    at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
    at 
org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:62)
    at 
org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:107)
    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)

    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at 
org.jetbrains.groovy.compiler.rt.GroovycRunner.intMain2(GroovycRunner.java:90)
    at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
    at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at 

groovy-3.0.7 & groovy-2.5.14 IntelliJ build => Groovyc: Internal groovyc error: code 1 ?

2021-03-01 Thread MG

Hi,

I tried to do a spike to switch the (large) IntelliJ build-based* Groovy 
project I am working on to from Groovy 2.5.10 to the current Groovy 3 
release (3.0.7) today, but immediately got a "Groovyc: Internal groovyc 
error: code 1" that (contrary to previous times I encountered that 
error) did not go away through a rebuild of the current module or the 
whole project.


The same problem then occurred with the current Groovy 2.5 release (2.5.14).

I have now created a minimal IntelliJ Groovy project, that contains a 
single test that outputs the Groovy version - and to my surprise this 
still gives "Groovyc: Internal groovyc error: code 1" in the 'Builder 
"Groovy stub generator" requested rebuild of module chunk 
"GroovyMinimal"' phase...
The minimal project builds & runs without problems when switching back 
to Groovy 2.5.10.


My complete build environment is:
IntellliJ 2020.2.3
AdoptOpenJDK jdk-11.0.10.9-hotspot (same behavior when using 11.0.10.5)
Windows 10 Pro 64-bit (build 19041.804)
Groovy 2.5.10 (works) / 2.5.14 (fails) / 3.0.7 (fails) respectively
(Hardware: Intel i5 CPU, 32GB RAM, 2TB SSD)

The project consists only of the (non-global) respective Groovy library 
dependency, and the following Groovy test file (for simplicity I use the 
JUnit that comes with this particular IntelliJ version in the minimal 
project):


package minimal.groovy

import org.junit.Ignore import org.junit.Test class MinimalTest {
 @Test @Ignore void test() {
  println"Grooovy: ${GroovySystem.version}" }
}


Is this a known problem ? If not, feedback from other Groovy users would 
be appreciated. I am evidently trying to find a solution to this 
problem, but also to discern the extent of it: E.g. does it also occur 
when using Maven or Gradle as a build system (which would surprise me, 
since that is what most people use) ? If your build works fine with 
Groovy 2.5.14 / 3.0.7, what is your build environment ?


Thanks, cheers,
mg

*Since the question typically pops up: The environment I work in does 
not allow access to build repositories on the internet, and it is not 
possible to automatically mirror repositories locally, and we have no 
complicated build steps, so using Gradle (or Maven) would have no real 
advantage for us, so we use the build system that is best integrated 
with our IDE and has good (apart from some minor hickups) minimal 
rebuild support, etc, i.e. an IntelliJ build.










Re: recognise empty closure?

2021-02-17 Thread MG
Is telling the user that the Closure cannot be empty the only 
application for this ? If yes, given that a user can easily pass a 
non-empty but non-meaningful closure anyway I would question whether it 
is worth the effort.


Cheers,
mg

PS: Also wondering whether we could achieve the same thing through the 
Closure return type, e.g.:


@Test @Ignore void closureFooTest() {
 println closureFoo {}
 println closureFoo{ "abc" } }

def closureFoo(Closure cls) {
 return "the string is: ${cls()}" }

Should imho fail to compile, since an empty Closure should have return 
type void.
Currently it does compile and run though (under 2.5.x) , even with 
@CompileStatic, since the empty closure implicitely returns null (imho 
one of the few bad design decisions in Groovy (whether in closures or 
somewhere else)), but at least IntelliJ marks it as invalid...




On 17/02/2021 19:51, Daniel Sun wrote:

Groovy does not support checking empty closure at runtime AFAIK, but we could 
check and set some property to closure while compiling, then get the property 
at runtime. It will be an new improvement, not sure if others like it or not.

Cheers,
Daniel Sun

On 2021/02/17 15:06:47, OCsite  wrote:

Hi there,

is it possible to reliably recognise an empty closure, i.e., „{}“, 
programmatically?

def foo(Closure bar) {
   if (?bar-is-empty?) throw new Exception('The closure cannot be empty!')
   else bar()
}
foo { println "ok" } // OK
foo { 1 } // OK
foo { } // throws

Thanks!
OC




Re: GraalVM native image for Groovy apps

2021-02-01 Thread MG

Hi Damir,

great work, and another step towards putting (statically compiled) 
Groovy on the map as a OS level scripting language with startup times as 
fast as Python, Perl, Ruby, ...


My feedback would be:

1. Give changes in resulting image size also as a percentage.
2. Supply an "if you are mainly interested in the results"
   link/reference to a results section at the end of the article.
3. Add download links and a reference section to the end of the article.

With regards to giving relative image sizes: Knowing what the maximum 
improvement from the "include all" approach would be is particulary 
helpful. Knowing that one would get a (if I calculated correctly) 13% 
reduction in size will help to decide whether investing time/resources 
into this makes sense on a case by case basis :-)


Do you already know where the article will be published ?-)
Cheers,
mg


On 30/01/2021 18:28, Damir Murat wrote:

Hi,

I'm writing an article exploring the options for creating GraalVM 
native images for
Groovy/Micronaut/picocli CLI applications. Although the article is 
content complete,

I'm still considering it as a draft, and I'm looking for feedback.

If somebody is interested, the article is here:
https://github.com/croz-ltd/klokwrk-project/blob/master/support/documentation/article/groovy-graalvm-native-image/groovy-graalvm-native-image.md 
<https://github.com/croz-ltd/klokwrk-project/blob/master/support/documentation/article/groovy-graalvm-native-image/groovy-graalvm-native-image.md>


Tnx,
Damir Murat




Re: Default values for parameters in interface methods

2021-01-05 Thread MG
Yes, sorry, indeed there is Jochen: I overlooked that the reply was by 
you and not the initial poster ;-)


Since we use Groovy only, I have no experience how Groovy traits behave 
for Java cross-compilation, but supporting default parameters in 
interfaces sounds like a good idea in principle regardless, since it is 
one of those "why would that _not_ be supported here ?" scenarios...


Cheers,
mg


On 05/01/2021 17:30, Jochen Theodorou wrote:


I think there is a misunderstanding...





Re: Default values for parameters in interface methods

2021-01-05 Thread MG
Maybe merging interface with trait could be possible in the future, but 
would using the "trait" keyword instead of "interface" have any negative 
effects in your scenario ?
I only use trait where I need the added functionality, but technically 
it behaves just like a suped up interface afaiaao...


Cheers,
mg

On 05/01/2021 17:14, Jochen Theodorou wrote:

Hi Paul,

wouldn't it be possible to implement the default parameter now with
default methods?

On 05.01.21 05:39, Paul King wrote:

You could potentially use a trait?

trait MyTrait {
     abstract myFunction(String parameter1 = "1234")
}

class MyClass implements MyTrait {
     def myFunction(String parameter1) {
         parameter1.reverse()
     }
}

assert new MyClass().myFunction() == '4321'


On Tue, Jan 5, 2021 at 1:22 PM Saravanan Palanichamy mailto:chava...@gmail.com>> wrote:

    Hello

    Are there plans to support default parameters in interface methods

    interface MyClass {
     def myFunction(String parameter1 = "1234")
    }

    the error I get is Cannot specify default value for method parameter
    inside an interface

    regards
    Saravanan







Re: Marking call() method of generated closures with @Generated?

2020-12-12 Thread MG

Hi Damir,

the question you posed might have been asked before on 
d...@groovy.apache.org, not entirely sure, in any case it seems more 
suited for the developer ML, so you might check the archives or try 
reposting it there.


Cheers,
mg

On 12/12/2020 17:53, Damir Murat wrote:

Any thought on this?

I can see that many false negatives from my code could disappear from 
a code coverage report. But I might be missing something.


Tnx




Re: IDE support for multi assignment statements

2020-12-12 Thread MG

Upvoted G-)
(I have thought about this, and in certain situations being able to have 
(Intellisense supported) multi-assignment would be beneficial in our 
framework, so it would definitely be good to have this)


Cheers,
mg

On 11/12/2020 23:47, Saravanan Palanichamy wrote:

Thank you MG, I raised this ticket

https://youtrack.jetbrains.com/issue/IDEA-257580 
<https://youtrack.jetbrains.com/issue/IDEA-257580>


regards
Saravanan

On Fri, Dec 11, 2020 at 8:59 PM MG <mailto:mg...@arscreat.com>> wrote:


You could try the newest version (2020.3), but if that does not
help, I would guess JetBrains might possibly not even be aware
that Groovy 3.x supports that feature. In that case creating a
ticket is imho your best option (there are people from Jetbrains
reading this ML, but they need a ticket to work on the issue*) - I
would recommend posting the ticket URL here, so people can upvote
- I sure will G-)

    Cheers,
mg

*I would also recommend closely following the ticket guidelines,
i.e. describe current (erronous) state, and the expected behavior
- in short you want to make it easy for them to work on this.


On 11/12/2020 15:40, Saravanan Palanichamy wrote:

Hi MG

I am using Intellij  IntelliJ IDEA 2020.2.3 (Community Edition)
Build #IC-202.7660.26, built on October 6, 2020

I have attached the error as a picture. The intellij web page
says 3.0 is supported. I am not sure what to make of it though.
The code runs cleanly and as expected

https://www.jetbrains.com/help/idea/groovy.html
<https://www.jetbrains.com/help/idea/groovy.html>

regards
Saravanan

On Fri, Dec 11, 2020 at 2:59 PM MG mailto:mg...@arscreat.com>> wrote:

Hi Saravanan,

what IntelliJ version are you using ? We are not using multiple
assignments in our code, but from my personal experience,
IntelliJ can
unfortunately sometimes be more than 2 years behind current
Groovy
features. If the newest IntelliJ version does not support
what you need,
opening a ticket did help in the past (see e.g.
https://youtrack.jetbrains.com/issue/IDEA-193168
<https://youtrack.jetbrains.com/issue/IDEA-193168>), but you
have to be
prepared to wait some time before seeing improvements.
In addition to that, IntelliJ sometimes marks valid Groovy
code as
invalid, but reconsiders if one comments out the "offending"
line(s),
and then comments it in again (I assume doing this triggers a
new
Intellisense parser pass).

Interestingly afaik (disclaimer: I have not checked this
recently, and
we are still on Groovy 2.5.x), Groovy will treat e.g.
var x = new Foo()
and
final x = new Foo()
as x having type Object - it is just IntelliJ Intellisense
that deduces
x to be of type Foo*, thereby enabling auto completion, etc
    on x ;-)

Cheers,
mg

*In all but the most obscure cases


On 11/12/2020 06:54, Saravanan Palanichamy wrote:
> Hello
>
> I am using Groovy 3.0.5 and it supports multiple assignment
statements from tuples when using static compile
>
>      def(var1, var2) = Tuple.tuple("a", 1)
>
> but it looks like the Intellij IDE still calls this out as
a compile error. Also it defaults to identifying var1 and
var2 as objects. This hinders code completion in subsequent
code. Is this an issue for anyone else? or do I just have to
upgrade my IDE?







Re: IDE support for multi assignment statements

2020-12-11 Thread MG
You could try the newest version (2020.3), but if that does not help, I 
would guess JetBrains might possibly not even be aware that Groovy 3.x 
supports that feature. In that case creating a ticket is imho your best 
option (there are people from Jetbrains reading this ML, but they need a 
ticket to work on the issue*) - I would recommend posting the ticket URL 
here, so people can upvote - I sure will G-)


Cheers,
mg

*I would also recommend closely following the ticket guidelines, i.e. 
describe current (erronous) state, and the expected behavior - in short 
you want to make it easy for them to work on this.



On 11/12/2020 15:40, Saravanan Palanichamy wrote:

Hi MG

I am using Intellij  IntelliJ IDEA 2020.2.3 (Community Edition)
Build #IC-202.7660.26, built on October 6, 2020

I have attached the error as a picture. The intellij web page says 3.0 
is supported. I am not sure what to make of it though. The code runs 
cleanly and as expected


https://www.jetbrains.com/help/idea/groovy.html 
<https://www.jetbrains.com/help/idea/groovy.html>


regards
Saravanan

On Fri, Dec 11, 2020 at 2:59 PM MG <mailto:mg...@arscreat.com>> wrote:


Hi Saravanan,

what IntelliJ version are you using ? We are not using multiple
assignments in our code, but from my personal experience, IntelliJ
can
unfortunately sometimes be more than 2 years behind current Groovy
features. If the newest IntelliJ version does not support what you
need,
opening a ticket did help in the past (see e.g.
https://youtrack.jetbrains.com/issue/IDEA-193168
<https://youtrack.jetbrains.com/issue/IDEA-193168>), but you have
to be
prepared to wait some time before seeing improvements.
In addition to that, IntelliJ sometimes marks valid Groovy code as
invalid, but reconsiders if one comments out the "offending" line(s),
and then comments it in again (I assume doing this triggers a new
Intellisense parser pass).

Interestingly afaik (disclaimer: I have not checked this recently,
and
we are still on Groovy 2.5.x), Groovy will treat e.g.
var x = new Foo()
and
final x = new Foo()
as x having type Object - it is just IntelliJ Intellisense that
deduces
x to be of type Foo*, thereby enabling auto completion, etc on x ;-)

Cheers,
mg

*In all but the most obscure cases


On 11/12/2020 06:54, Saravanan Palanichamy wrote:
> Hello
>
> I am using Groovy 3.0.5 and it supports multiple assignment
statements from tuples when using static compile
>
>      def(var1, var2) = Tuple.tuple("a", 1)
>
> but it looks like the Intellij IDE still calls this out as a
compile error. Also it defaults to identifying var1 and var2 as
objects. This hinders code completion in subsequent code. Is this
an issue for anyone else? or do I just have to upgrade my IDE?





Re: IDE support for multi assignment statements

2020-12-11 Thread MG
I don't know about RubyMine, but for IntelliJ Groovy support, uhm, yea, 
obviously, as you can see in the umbrella ticket I referenced: I created 
several tickets, asked people to upvote them if they cared about the 
issue, and over (an alas elongated period of) time things did get fixed G-)


On 11/12/2020 10:41, Dirk Heinrichs wrote:

Am Freitag, den 11.12.2020, 10:29 +0100 schrieb MG:


If the newest IntelliJ version does not support what you need,
opening a ticket did help in the past


Really? I have a RubyMine ticket open for more than 2 years now with 
nothing happening... :-(


Bye...

Dirk
--
*Dirk Heinrichs*
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
*Phone*: +49 2226 15966 18
*Email*: dhein...@opentext.com <mailto:dhein...@opentext.com>
*Website*: www.recommind.de 
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu 
Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, 
Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If 
you are not the intended recipient (or have received this e-mail in 
error) please notify the sender immediately and destroy this e-mail. 
Any unauthorized copying, disclosure or distribution of the material 
in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte 
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese 
E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den 
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie 
die unbefugte Weitergabe dieser Mail sind nicht gestattet.




Re: IDE support for multi assignment statements

2020-12-11 Thread MG

Hi Saravanan,

what IntelliJ version are you using ? We are not using multiple 
assignments in our code, but from my personal experience, IntelliJ can 
unfortunately sometimes be more than 2 years behind current Groovy 
features. If the newest IntelliJ version does not support what you need, 
opening a ticket did help in the past (see e.g. 
https://youtrack.jetbrains.com/issue/IDEA-193168), but you have to be 
prepared to wait some time before seeing improvements.
In addition to that, IntelliJ sometimes marks valid Groovy code as 
invalid, but reconsiders if one comments out the "offending" line(s), 
and then comments it in again (I assume doing this triggers a new 
Intellisense parser pass).


Interestingly afaik (disclaimer: I have not checked this recently, and 
we are still on Groovy 2.5.x), Groovy will treat e.g.

var x = new Foo()
and
final x = new Foo()
as x having type Object - it is just IntelliJ Intellisense that deduces 
x to be of type Foo*, thereby enabling auto completion, etc on x ;-)


Cheers,
mg

*In all but the most obscure cases


On 11/12/2020 06:54, Saravanan Palanichamy wrote:

Hello

I am using Groovy 3.0.5 and it supports multiple assignment statements from 
tuples when using static compile

 def(var1, var2) = Tuple.tuple("a", 1)

but it looks like the Intellij IDE still calls this out as a compile error. 
Also it defaults to identifying var1 and var2 as objects. This hinders code 
completion in subsequent code. Is this an issue for anyone else? or do I just 
have to upgrade my IDE?




Re: Defining a global variable

2020-10-21 Thread MG

Hi Merlin,

I don't know how your reply pertains to what I said, but generally 
speaking having implicit variables is imho generally a very poor design 
choice, as anyone who has experienced them in e.g. a Basic dialect will 
be able to confirm, simply because one innocuous typo can introduce a 
hard to track bug into your code, by implicitly defining a new variable 
instead of modifying an existing one.


Cheers,
mg


On 21/10/2020 17:46, Merlin Beedell wrote:

I thought that implicit variables would overcome this.  Not an elegant solution 
- as you are simply declaring variables on the fly without an explicit data 
type or even a 'def'.
Having said, it is generally safer to explicitly list the parameters used in a 
method when used in this context (e.g. in a script without an explicit class 
declaration to mop up this case).
And as for 'global' - I sure wish the word 'global' was used instead of 
'static'.  It just kinda makes more sense to me!
//===
test=''  //implicit declaration of a variable
void func()
{
   println(test)
}
test = 'hello'
func()
//===

Or just

//===
void func()
{
   println(test)
}
test = 'hello'
    func()
//===

Merlin Beedell
-Original Message-
From: MG 
Sent: 15 October 2020 6:21 PM
To: users@groovy.apache.org; Jochen Theodorou 
Subject: Re: Defining a global variable

On 15/10/2020 18:27, Jochen Theodorou wrote:

well.. even scripts are first compiled into a class before the class
is then executed. Groovy has no interpreter

Which, I think, is a lesser known fact, and quite surprising to people who perceive 
Groovy just under its "script language" aspect ;-)






Re: problem during calling method from closure

2020-10-15 Thread MG

Hi Anton,

could you please point out to me the concepts you mention in a private 
email ?
It still seems to me that what I said was right, see for instance: 
https://wiki.c2.com/?AlanKaysDefinitionOfObjectOriented


Cheers,
mg

(Many of these topics are quite old, and things which are no big deal 
now definitely were back then, such as the fact that C++ is not a TRUE 
OO language, since calls are only virtual if the method carries that 
explicit keyword  - a useless design decision from my experience, yes (I 
remember trying to find a case where non-virtual calls actually gave a 
performance advantage in my C++ game engine back in 2000, and just could 
not construct a real world example), but at the same time not that big a 
deal in practice (why the much younger language of  C# uses the same 
concept remains puzzling, though.))



On 15/10/2020 20:16, Anton Shepelev wrote:

MG about Alan Kay's "message passing":


It is not an approach per se, but just terminology.

Lest I annoy the list administrators by continuing this off-
topic disussion, I will confine my reply to the remark that
Kay's concept of message passing is not mere terminology. It
is also more that just an approach -- it is a full-fledged
paradigm, alghough OCsite may not have meant it that way
when he mentioned it. Thanks for sympathy.





Re: Defining a global variable

2020-10-15 Thread MG

On 15/10/2020 18:27, Jochen Theodorou wrote:

well.. even scripts are first compiled into a class before the class is
then executed. Groovy has no interpreter


Which, I think, is a lesser known fact, and quite surprising to people 
who perceive Groovy just under its "script language" aspect ;-)





Re: problem during calling method from closure

2020-10-15 Thread MG

On 15/10/2020 13:03, Anton Shepelev wrote:




we definitely should have sticked with Alan Kay's
"message-sending", and there would be much less
misunderstandings and problems today.

I fear this message-passing approach even further from
normal proceudural prgramming that conventinal OO languages
and would therefore be even more confusing and unintuitive.



It is not an approach per se, but just terminology.

And when coming from Assembler/C/C++, like I do, it is a very confusing 
one: At the end of the day, it is always just about pushing the 
arguments on the stack and picking the subroutine address to which the 
CPU shall branch, whether that address selection is static (and can 
therefore be done at compile time), virtual (i.e. based on the object 
the function is called for, which requires a (quick and simple) virtual 
function table lookup for the object's class at runtime), dynamic (i.e. 
based on the object and the argument types on the stack, like Groovy 
does), or completely custom implemented in the language itself (as can 
be done in Groovy).


It is never about passing messages from one object to the other, which 
to me implies creating messaging objects, which are being put into a 
queue for asynchronous processing by the receiving object (possibly with 
prioritization, ...), and maybe being sent over a network connection, 
etc. So a much more heavy & slower mechanism than what actually takes place.


Of course one often times finds logical/natural what one first 
encountered, but keeping that in mind, from what lies underneath it, 
calling it a method call with passed arguments still makes the most 
sense to me.


Cheers,
mg






Re: Help with adding Groovy to Programming-Idioms

2020-10-10 Thread MG

Hi Valentin,

glad to give some feedback, especially if it is so well received - 
evidently you have already put a lot of thought into this and your 
decisions are conscious ones, which is refreshing, especially when it 
comes to web & usability design :-)
I see your points, especially on the voting system, and have added my 
vote for side-by-side cheatsheet support.


Cheers,
mg

On 09/10/2020 18:59, Valentin Deleplace wrote:
Hi MG, thank you so much for this thorough feedback, this is extremely 
valuable.
I'll answer your suggestions, keeping in mind that I have to deal with 
conflicting concerns and the end result will not be perfect in every 
aspect:


0. "Groovy"+"Groovy (Static)": though this would be the "exact thing" 
to do, I hope that most of the language is the same in the two cases.  
If something works only in one of the two, please mention it in the 
comment box on the right. Ideally, add a new separate 
implementation+comment box to achieve the same goal in the other case.


a1. Amazing! Looking forward to the good stuff ahead.

a2. Thanks for the link, I didn't know it yet.

b1. It is by design that several implementations for the same language 
are accepted, and 2 or more can be regarded as idiomatic. The quality 
of the contents is uneven, sometimes a contribution is clearly 
inferior. This is a problem that we should ideally address by 
curating, provided we have the proper skills, and time to invest.


b2. A voting system is implemented but disabled for now. It is at odds 
with the current design in which you don't need to authenticate with 
an account. This favors immediate frictionless contribution which is 
cool, but also means there is no effective way to tell apart legit 
votes from abusive votes. The current tradeoff is to not open the 
pandora box of votes, and instead let any user "flag" the content if 
they consider it problematic for any reason. A snippet being mediocre 
is a valid reason for a user to flag the snippet.


b3. Fair enough! Let's track this in issue #128 
<https://github.com/Deleplace/programming-idioms/issues/128>


b4. There is no categorization for now. You may open an issue if you 
feel it's missing. The current design favors the "search by keywords" 
navigation, and the "related idioms" link in the right bar. Also, each 
idiom has a list of "keywords" that make it more surfaceable by text 
search. I suspect that adding tags or categories would be redundant, 
though I can also understand that grouping is desirable.


b6. Indeed a side-by-side cheatsheet would be cool, please add your 
vote to the existing issue #101 
<https://github.com/Deleplace/programming-idioms/issues/101>


7. Yes all implementations have their own ID and a canonical URL, e.g. 
impl 1449 
<https://programming-idioms.org/idiom/28/sort-by-a-property/1449/scala>. 
The language list in the top box of an idiom (on the right of the 
idiom title) contains all its specific implementation links.


Valentin
Happy path engineer
Google Cloud Platform
Twitter : @val_deleplace


On Fri, 9 Oct 2020 at 18:07, MG <mailto:mg...@arscreat.com>> wrote:


Hi Valentin,

    with Groovy maybe one should consider doing a "Groovy" and
"Groovy (Static)", since not all dynamic solutions a valid for the
@CompilStatic case ?

Additional points:

 1. I might contribute, as time allows.
 2. Havig said that: Just go to
https://mrhaki.blogspot.com/search/label/Groovy, copy & link
back to Mr. Hubert A. Klein Ikkink's site and you should be
all set ;-)
 3. I had to laugh so hard when I saw the Cobol version of what is
"s.startsWith(prefix)" in pretty much any other language -
thank god I am young enough to have missed that :-)

Some general site feedback:

 1. I found it confusing that there can be more than one tab per
language (e.g. for C++), especially if one idiom is clearly
inferior to the other
 2. If multiple versions were allowed, a voting system might be
the way to go - or someone curating each language...
 3. I would have expected the landing page to not only display a
search box, but also an (categorized) idiom list. I know the
current web design meta is "as simple/barren as humanly
possible", but the small link icon at the bottom that leads to
a menu, where you can then get this infromation under "All
idioms" or "Language coverage"  is easy to miss.
 4. Speaking of "categorized idiom list": To be able to quickly
filter after idioms relating to e.g. "threads" or "strings"
would imho generally be helpful
 5. On the other hand like the cheat sheet feature (though I find
the name misleading), since oftent

Re: Help with adding Groovy to Programming-Idioms

2020-10-09 Thread MG

Hi Valentin,

    with Groovy maybe one should consider doing a "Groovy" and "Groovy 
(Static)", since not all dynamic solutions a valid for the @CompilStatic 
case ?


Additional points:

1. I might contribute, as time allows.
2. Havig said that: Just go to
   https://mrhaki.blogspot.com/search/label/Groovy, copy & link back to
   Mr. Hubert A. Klein Ikkink's site and you should be all set ;-)
3. I had to laugh so hard when I saw the Cobol version of what is
   "s.startsWith(prefix)" in pretty much any other language - thank god
   I am young enough to have missed that :-)

Some general site feedback:

1. I found it confusing that there can be more than one tab per
   language (e.g. for C++), especially if one idiom is clearly inferior
   to the other
2. If multiple versions were allowed, a voting system might be the way
   to go - or someone curating each language...
3. I would have expected the landing page to not only display a search
   box, but also an (categorized) idiom list. I know the current web
   design meta is "as simple/barren as humanly possible", but the small
   link icon at the bottom that leads to a menu, where you can then get
   this infromation under "All idioms" or "Language coverage"  is easy
   to miss.
4. Speaking of "categorized idiom list": To be able to quickly filter
   after idioms relating to e.g. "threads" or "strings" would imho
   generally be helpful
5. On the other hand like the cheat sheet feature (though I find the
   name misleading), since oftentimes being able to just search/browse
   in a complete result set in the browser can imho be a good way to
   find what you are looking for (and maybe discover something you were
   not looking for*) :-)
6. Being able to have two languages displayed side by side in the
   "cheat sheet" view would be great for comparing languages

Cheers,
mg

*In the category of "So close, but not Groovy" I stumbled upon the fact 
that it seems Kotlin still does not have a list/map literal syntax: 
https://programming-idioms.org/idiom/8/initialize-a-new-map-associative-array 
**; the Java-like solution looks to be the best of the 3 solutions 
offered, but it comes with a "use only if performance isn't critical" 
caveat...
(see also https://github.com/Kotlin/KEEP/pull/112 ; 
https://kotlinlang.org/docs/reference/constructing-collections.html)


**Is it possible to link directly to a specific language version of an 
idiom ?



On 09/10/2020 12:06, Valentin Deleplace wrote:

Hello folks
I admin https://programming-idioms.org/about and I'd like to add 
Groovy to the list of available languages. The website is a collection 
of "how to do X in language Y".
My friend Guillaume Laforge advised me to ask this mailing list for 
help! The goal is to encourage contribution of quality contents so it 
can actually be helpful to a beginner or seasoned groovyist visitor.


A quality contribution is a snippet that is correct, concise, having 
an explanation, a link to the official docs, and ideally a link to an 
online demo. For example at 
https://programming-idioms.org/idiom/96/check-string-prefix some 
implementations are high-quality, but not all of them.


Writing a correct snippet takes about 3mn, while writing a 
high-quality contribution easily takes over 15mn.
Before I open the gates by adding Groovy in the system, I'd like to 
know if some of you would be willing to contribute and curate some 
contents?


Thank you in advance
Valentin


Valentin
Happy path engineer
Google Cloud Platform
Twitter : @val_deleplace




Re: 2020 Groovy Ecosystem Usage Report - I need your help

2020-08-28 Thread MG

Hi Szymon,

happy to participate, it literally took me under 30 seconds to do this.

Just one question: I was not sure whether "Other" strictly meant "other 
Groovy based frameworks", so I put "Vaadin, Ebean" there, which are of 
course both not using Groovy, but which we use all the time with Groovy, 
and have found to play well with it*, especially when wrapped in a 
little Groovy closure magic :-)


Cheers,
mg

*with the only exception of Ebean not seeing Groovy trait added class 
properties - not a big deal for me, and might work in a newer Ebean 
version than the one we use...



On 28/08/2020 18:36, Szymon Stępniak wrote:

Hello everyone!

I want to ask you for help. I run into an idea today to research and 
collect information about the usage of various frameworks, libraries, 
and tools in the Groovy ecosystem in 2020. I create a one-question 
survey (multiple choice) and I would like to invite you to participate 
in this research. The survey is anonymous and it will take you less 
than a minute to fill it out. Here's the link:


https://bit.ly/2020-groovy-ecosystem-usage-report

In about a week or two, I will publish raw results as well as a short 
blog post that summarizes it.


I will be grateful if you can help me.

Thanks in advance, have a great weekend!
Szymon




Re: Omitting parentheses on .size() ?

2020-08-05 Thread MG
Thank you, Jochen - that's actually a Groovy feature that has been 
around for a long time, that I completely forgot about :-)


https://groovy-lang.org/metaprogramming.html#_extension_modules
https://mrhaki.blogspot.com/2013/01/groovy-goodness-adding-extra-methods.html

Do you know if:

1. This works for interfaces (e.g. List and Map) ?
2. Whether IntelliJ picks up those extension methods (i.e. will
   Intellisense know that e.g. List now has a getSize() method) ?

Cheers,
mg


On 05/08/2020 09:34, Jochen Theodorou wrote:

On 04.08.20 16:13, MG wrote:

On 04/08/2020 15:16, Basurita wrote:

On 8/1/20 14:41, MG wrote:

Hmmm, I am for consistency, but at least I use very few maps as
compared to lists, and rarely ever output the size of a map, but
constantly for
lists, so having getSize() on List would still be beneficial.

You're free to add whatever you want to your metaClass :-)


In dynamic Groovy, yes, but I am an IntelliJ / @CompileStatic Groovy
user so afaiaao there is no way to make this work in my case...


for @CompileStatic this can be done via extension methods.

Afaik it is still the case, that the classes containing extension
methods must be compiled before their use in a separate compilation so
the compiler can pick them up as part of the compilation once you want
to use them.


bye Jochen




Re: Omitting parentheses on .size() ?

2020-08-04 Thread MG

On 04/08/2020 16:22, OCsite wrote:




Having too many operators is like having too many annotations: People don't 
know about them, and therefore do not use them, or are confused if they do 
encounter them
(see also e.g. Scala as an example of a language where people can define their 
own operators, and to what problems that can lead...).

Do please correct me if I am wrong, but I do believe user-defined operators 
would not lead to such a mess as language-defined ones by far; you would simply 
use your own ones and would not get bitten in your tender parts by those 
defined by others.


Herin exactly lies the problem: In the end people start to define their 
own language, which at some point becomes impossible to read/parse by 
other devs. Just google Scala and operator overloading. While I am not 
for trying desperately to block developers from doing stupid things, 
this is alas evidently one of those features that can very easily be 
abused, so having a fixed, standardized set of operators in a language 
is imho the better choice. I use operator overloading in my framework, 
e.g. by adding the capability to add together Column objects to form a 
Columns object, but I have never felt the need to define a completely 
new operator like "**!".


Of course one could argue that one can define ones own language in 
Groovy anyway, by using its DSL features, but in practice that takes 
much more effort, and is a more concious decision than simply defining 
your own custom operator here, and here, and here...


Of course your opinion may vary, but I that is my reason why I currently 
would be -1 on arbitrary custom operators in Groovy - sometimes with too 
much power comes too much responsibility (and too little advantage imho) :-)

Cheers,
mg

*with the special behavior that a column will not be added if it already 
exists in the Columns obj, so one can write e.g. p.AGE.val(33) + 
p.ID.val(newId()) + p.LAST_NAME.val('Muster') + p.allColumns and always 
get all the p(erson)'s columns








Re: Omitting parentheses on .size() ?

2020-08-04 Thread MG

On 04/08/2020 15:16, Basurita wrote:

On 8/1/20 14:41, MG wrote:

Hmmm, I am for consistency, but at least I use very few maps as compared to 
lists, and rarely ever output the size of a map, but constantly for
lists, so having getSize() on List would still be beneficial.

You're free to add whatever you want to your metaClass :-)


In dynamic Groovy, yes, but I am an IntelliJ / @CompileStatic Groovy 
user so afaiaao there is no way to make this work in my case...





This has of course been discussed many times before - maybe a "size" operator:

#list // list.size()
#map // map.size()
#string // string.length

Now, this is not a completely bad idea.
I spent a few years programming in Lua, and that's what the # operator does for 
strings and tables (arrays)


I was not aware of that, "#" just seemed like a workable choice since is 
already used as an abbreviation for "how many / number of" in English.



i think the # symbol is not being used in Groovy anywhere but I may be mistaken.
They would need to change the language's grammar, though.


The hard part would be a) agreeing whether the operator makes sense in 
principle (I just put the idea out there, since I feel 
Collection#getSize() might never happen), and then b) agreeing on a 
symbol for it.

Implementing the change would be straightforward in comparison ;-)


I'm all for using symbols for syntactic sugar.
And why limit ourselves to ASCII-7 when we have the whole Unicode set to choose 
from!! :-)


Having too many operators is like having too many annotations: People 
don't know about them, and therefore do not use them, or are confused if 
they do encounter them
(see also e.g. Scala as an example of a language where people can define 
their own operators, and to what problems that can lead...).


Cheers,
mg







GContracts Overview

2020-08-03 Thread MG
Since there is currently a proposal on the dev mailing list whether to 
include the design-by-contract GContracts library 
(https://github.com/andresteingress/gcontracts/) into Groovy,  for 
everyone who has never used GContracts (or design-by-contract), and 
since most of the "info"-links on the GitHub seem to be broken, here are 
some links on the topic:


https://jaxenter.com/tutorial-gcontracts-a-design-by-contract-extension-for-groovy-104751.html
https://en.wikipedia.org/wiki/Design_by_contract


The final example in the overview article gives a good idea on how the 
design-by-contract mechanisms of pre-/postconditions 
(@Requires/@Ensures) and invariants (@Invariant) works in GConract 
(Note: The RocketAPI interface is not necessary, annotations could also 
reside directly on Rocket class methods):


import org.gcontracts.annotations.*

interface RocketAPI {
  def start()
  boolean isStarted()
  int getSpeed()

  @Requires({ started })
  @Ensures({ result - old.speed == 5 })
  def accelerate()

  @Requires({ started })
  @Ensures({ old.speed - speed == 5 })
  def brake()
}

@Invariant({ speed >= 0 && speed <= Integer.MAX_VALUE - 5 })
class Rocket implements RocketAPI  {

    int speed
    private boolean started

    def start() { started = true }
    boolean isStarted() { started }

    def accelerate()  {
    speed = speed + 5
    return speed
    }

    def brake() {
    speed = speed - 5
    }
}

def rocket = new Rocket()
rocket.accelerate()


Cheers,
mg


On 03/08/2020 07:57, Paul King wrote:


Hi everyone,

The GContracts project (design-by-contract extension for Groovy) has 
been archived:


https://github.com/andresteingress/gcontracts/

I believe there is sufficient merit in the functionality it offers for 
us to consider taking up support of the codebase, and the project 
owner, Andre Steingress, is happy for that transition to take place.


We could try to re-invigorate GContracts outside the ASF but I think 
our community where a larger pool of folks can contribute when they 
have availability makes more sense than another single person trying 
to take it over and then potentially running out of steam down the track.


We could give it it's own repo and have it as a subproject but for now 
I think it is easiest just to have it as an optional module in the 
core repo (targeting Groovy 4). In the PR, I have marked the main 
annotations as @Incubating for the time being. For further details, 
see here:


https://github.com/apache/groovy/pull/1337
https://issues.apache.org/jira/browse/GROOVY-9671

Let me know if you have any objections or alternate thoughts.

Thanks, Paul.





Re: Omitting parentheses on .size() ?

2020-08-01 Thread MG

On 01/08/2020 20:55, Jochen Theodorou wrote:

On 01.08.20 19:41, MG wrote:


This has of course been discussed many times before - maybe a "size"
operator:

#list // list.size()
#map // map.size()
#string // string.length


a size() method is the way of consistency we did go for. It exists on
collection, string, array and map. We added it to string and array so
you do not to have to remember using length or length()


I know, and that was and is a good idea imho. Just still feels 
non-Groovy to always have to write "${p.size()}" instead of just 
"$p.size"* :-)


("$#p" would need to be supported for this to be helpful in this case, 
evidently)





which people could override (e.g. sizeOf() method) and which unifies all
kinds of "how many elements do I hold / how big am I" concepts (if its
not a collection holding items) ?-)


why sizeOf() if there is already size()?


Because it would be the method corresponding to the operator, and while 
I would make sizeOf() default to size() on maps, collections, etc, it 
would allow for sizeOf to be different from size() (the developer would 
have to check if this violates least surprise).


I  just threw the idea out there, but the "#"-operator could e.g. be 
used by someone to return how many children a abstract node or a 
concrete person has, if that made sense in his framework.


Cheers,
mg

PS: If there is further discussion on this, we should probably move it 
to dev...












Re: Omitting parentheses on .size() ?

2020-08-01 Thread MG
Hmmm, I am for consistency, but at least I use very few maps as compared 
to lists, and rarely ever output the size of a map, but constantly for 
lists, so having getSize() on List would still be beneficial.


This has of course been discussed many times before - maybe a "size" 
operator:


#list // list.size()
#map // map.size()
#string // string.length

which people could override (e.g. sizeOf() method) and which unifies all 
kinds of "how many elements do I hold / how big am I" concepts (if its 
not a collection holding items) ?-)


Cheers,
mg


On 01/08/2020 18:08, OCsite wrote:

MG,

On 1 Aug 2020, at 14:59, MG <mailto:mg...@arscreat.com>> wrote:

What was the reason again Groovy does not add getSize() here... ?-)


Consistency I guess. Having a List.size would lead to a request to add 
Map.size, which alas would clash with Map['size'].


All the best,
OC


On 01/08/2020 04:06, Paul King wrote:
What Daniel said is correct. Also if there was an accessible 
getSize() method, you could use just ".size".


Cheers, Paul.

On Sat, Aug 1, 2020 at 11:19 AM Daniel Sun <mailto:sun...@apache.org>> wrote:



The parentheses of methods without parameters could not be ommitted.

`[1, 2, 3].size` is accessing the private field `size` of
`ArrayList`, so illegal reflective access warning will be thrown.

Cheers,
Daniel Sun
On 2020/08/01 00:49:54, paul mailto:pl.grue...@gmail.com>> wrote:
> Hi all,
>
> (on latest groovy 3.0.5 and OpenJDK 14) omitting the empty
parentheses to the .size() call works, but throws an illegal
reflective access warning:
>
> ```
> groovy:000> [1,2,3].size
> WARNING: An illegal reflective access operation has occurred
> WARNING: Illegal reflective access by
org.codehaus.groovy.reflection.ReflectionUtils
(file:/home/paul/.sdkman/candidates/groovy/3.0.5/lib/groovy-3.0.5.jar)
to field java.util.ArrayList.size
> WARNING: Please consider reporting this to the maintainers of
org.codehaus.groovy.reflection.ReflectionUtils
> WARNING: Use --illegal-access=warn to enable warnings of
further illegal reflective access operations
> WARNING: All illegal access operations will be denied in a
future release
> ===> 3
> ```
>
> Curiously, the size() method seems to be the only
parameter-less method where I can
> omit the empty parentheses – all others throw a
MissingPropertyException (as expected).
>
> What is the desired behaviour, and why is it even working
(albeit with warnings) with .size ?
>
>
> best
> paul
> --
> typed with Neo 2 -- an ergonomically optimized keyboard layout
> for German, English, programming, and science
> ❤ http://neo-layout.org <http://neo-layout.org/>
> ❤ https://useplaintext.email <https://useplaintext.email/>
> ❤ YY-MM-DD dates (ISO 8601/RFC 3339)
> � UTF-8 encoding
>









Re: Omitting parentheses on .size() ?

2020-08-01 Thread MG

What was the reason again Groovy does not add getSize() here... ?-)
Cheers,
mg

On 01/08/2020 04:06, Paul King wrote:
What Daniel said is correct. Also if there was an accessible getSize() 
method, you could use just ".size".


Cheers, Paul.

On Sat, Aug 1, 2020 at 11:19 AM Daniel Sun <mailto:sun...@apache.org>> wrote:



The parentheses of methods without parameters could not be ommitted.

`[1, 2, 3].size` is accessing the private field `size` of
`ArrayList`, so illegal reflective access warning will be thrown.

Cheers,
Daniel Sun
On 2020/08/01 00:49:54, paul mailto:pl.grue...@gmail.com>> wrote:
> Hi all,
>
> (on latest groovy 3.0.5 and OpenJDK 14) omitting the empty
parentheses to the .size() call works, but throws an illegal
reflective access warning:
>
> ```
> groovy:000> [1,2,3].size
> WARNING: An illegal reflective access operation has occurred
> WARNING: Illegal reflective access by
org.codehaus.groovy.reflection.ReflectionUtils
(file:/home/paul/.sdkman/candidates/groovy/3.0.5/lib/groovy-3.0.5.jar)
to field java.util.ArrayList.size
> WARNING: Please consider reporting this to the maintainers of
org.codehaus.groovy.reflection.ReflectionUtils
> WARNING: Use --illegal-access=warn to enable warnings of further
illegal reflective access operations
> WARNING: All illegal access operations will be denied in a
future release
> ===> 3
> ```
>
> Curiously, the size() method seems to be the only parameter-less
method where I can
> omit the empty parentheses – all others throw a
MissingPropertyException (as expected).
>
> What is the desired behaviour, and why is it even working
(albeit with warnings) with .size ?
>
>
> best
> paul
> --
> typed with Neo 2 -- an ergonomically optimized keyboard layout
> for German, English, programming, and science
> ❤ http://neo-layout.org
> ❤ https://useplaintext.email
> ❤ YY-MM-DD dates (ISO 8601/RFC 3339)
> � UTF-8 encoding
>





Re: What projects use Groovy as its main development language ?

2020-07-12 Thread MG

Thank you to everyone who replied so far G-)
Cheers,
mg

On 02/07/2020 09:15, Alessio Stalla wrote:
Projects built with Portofino (https://portofino.manydesigns.com) all 
use Groovy as their main implementation language (alongside 
JavaScript/TypeScript and maybe some Java).
I've worked on several such projects, but they're all closed-source. A 
couple of publicly accessible ones are two applications that we (my 
former employer) did for the local University. One is a platform for 
running online recruitment procedures 
(https://concorsi.unige.it/home/?__language=en), the other, which is 
Italian only I think, is a platform to match high-school students with 
work experiences at the University 
(https://alternanza-scuola-lavoro.unige.it/welcome).
They're both a few years old and built with Portofino 4 and (I think) 
Groovy 2.4. So they're MVC web applications.
We've since released Portofino 5 that is REST +  Angular instead of 
MVC, but it hasn't gained much traction so far.


On Thu, 2 Jul 2020 at 08:32, Kostas Saidis <mailto:sai...@gmail.com>> wrote:


Groovy has been my language of choice for some time now (replacing
Java)
and I use it extensively in as many projects as I can.

The two most significant ones are the following.

1. Groovy lies at the heart and soul of the Clyze packaging tool for
Android apps (clyze.com <http://clyze.com>); the Clyze core
contains about 25K SLOC of Groovy.
The tool aims to make the management of ProGuard / R8
configurations as
easy as possible for Android teams and it is currently in an early
access state (we have only announced it on local groups here in
Greece,
so it is really coming to life as we speak). We have been
developing it
at the PLaST lab of the University of Athens for some time now,
where I
provide service as a visiting lecturer in Software Engineering, while
the whole Clyze effort is lead by Yannis Smaragdakis (the lab
director,
Professor @ UoA and a well-known PL -and especially static analysis-
researcher in top-notch events like SPLASH, PLDI, etc). BTW, if
you' re
into Android, we currently look forward to collecting as much
feedback
as possible for the tool, so feel free to experiment with it and
contact
me for any comments, thoughts or insights!

2. Groovy drives the back-end of Butterfly, the digital repository
product we have developed at Niovity, a company that offers digital
library / institutional repository solutions, mainly. Butterfly
contains
about 40K SLOC of Groovy.

    Cheers,
Kostas

On 27/6/2020 1:24 π.μ., MG wrote:
> A quick survey: Who on this mailing list works on or knows of a
> project where Groovy is the main language of development, i.e.
it is
> not used as "just" a script or DSL language in addition to e.g.
Java ?
> If possible name the company/country/project and give some
impression
> of the size of the project (lines of code, # of people working
on it,
> etc), timeframe of development, and whether it is os or
commercial (or
> both) G-)
>
> Thanks in advance,
> cheers,
> mg
>
>
>





Re: What projects use Groovy as its main development language ?

2020-06-26 Thread MG

Hi Edmond,

thanks for that - can you give some metrics regarding the code size ?-)

@Context of question: Didn't want my initial post to be too long, just 
thought I'd ask people to share if they wanted to - but in a nutshell: 
Groovy is putting a lot of emphasis/effort on Java compatibility, up to 
code copy & paste compatibility. This sometimes leads to solutions which 
cannot be as clear/consistent/least-surprise as one would hope for*, so 
I was wondering how many people actually use Groovy as a Java 
replacement / equal partner (I assume quite a few, but in my 
organization we are the only team that uses Groovy that way, i.e. not as 
a script language only).


Cheers,
mg

*The current example on the dev mailing list is the behavior of this.x / 
super.x under different conditions.



On 27/06/2020 02:04, Edmond Kemokai wrote:

Hi MG,

Not sure of the context for the question but I am the developer of 
Solvent (codesolvent.com <http://codesolvent.com>), it is a platform 
for doing web development via JSR-223 with Groovy being the primary 
language. The solvent developer environment is itself a web 
application (Java) with a back-end built entirely in Groovy via the 
JSR-223 Groovy scripting engine.


It is a commercial product, granted that part is still a work in progress.

I chose Groovy primarily because I am a Java developer so I didn't 
have to learn anything new, I do use the occasional Groovy language 
feature but otherwise have mostly stuck to Java syntax.


The product ships with the source code ready to edit, thus you can 
modify the IDE itself directly.  Feel free to sign-up and try it, 
there is free trial once you log in.


-Edmond

On Fri, Jun 26, 2020 at 7:40 PM MG <mailto:mg...@arscreat.com>> wrote:


Hi Paul,

I was looking for something more concrete, so maybe someone on
this projects could post here :-)

What I meant by "just" a script language or DSL (both valid Groovy
uses, of course) was, if 99% of the code is Java, and Groovy is
used for e.g. a small DSL for customers to use, or for some
internal/rollout/... scripting tasks.
I assume most Grails projects will be written mostly in Groovy, so
they naturally would qualify R6-)

Cheers,
mg


On 27/06/2020 01:20, Paul King wrote:

I have worked on numerous such projects in Australia in the past
but aren't in contact with those teams at the moment. Also, many
Grails projects fall under that category although by your
definition I am not sure whether you would call that usage "just"
a DSL.

On Sat, Jun 27, 2020 at 8:24 AM MG mailto:mg...@arscreat.com>> wrote:

A quick survey: Who on this mailing list works on or knows of
a project
where Groovy is the main language of development, i.e. it is
not used as
"just" a script or DSL language in addition to e.g. Java ?
If possible name the company/country/project and give some
impression of
the size of the project (lines of code, # of people working
on it, etc),
timeframe of development, and whether it is os or commercial
    (or both) G-)

Thanks in advance,
cheers,
mg











Re: What projects use Groovy as its main development language ?

2020-06-26 Thread MG

Hi Paul,

I was looking for something more concrete, so maybe someone on this 
projects could post here :-)


What I meant by "just" a script language or DSL (both valid Groovy uses, 
of course) was, if 99% of the code is Java, and Groovy is used for e.g. 
a small DSL for customers to use, or for some internal/rollout/... 
scripting tasks.
I assume most Grails projects will be written mostly in Groovy, so they 
naturally would qualify R6-)


Cheers,
mg


On 27/06/2020 01:20, Paul King wrote:
I have worked on numerous such projects in Australia in the past but 
aren't in contact with those teams at the moment. Also, many Grails 
projects fall under that category although by your definition I am not 
sure whether you would call that usage "just" a DSL.


On Sat, Jun 27, 2020 at 8:24 AM MG <mailto:mg...@arscreat.com>> wrote:


A quick survey: Who on this mailing list works on or knows of a
project
where Groovy is the main language of development, i.e. it is not
used as
"just" a script or DSL language in addition to e.g. Java ?
If possible name the company/country/project and give some
impression of
the size of the project (lines of code, # of people working on it,
etc),
timeframe of development, and whether it is os or commercial (or
both) G-)

Thanks in advance,
cheers,
mg







What projects use Groovy as its main development language ?

2020-06-26 Thread MG
A quick survey: Who on this mailing list works on or knows of a project 
where Groovy is the main language of development, i.e. it is not used as 
"just" a script or DSL language in addition to e.g. Java ?
If possible name the company/country/project and give some impression of 
the size of the project (lines of code, # of people working on it, etc), 
timeframe of development, and whether it is os or commercial (or both) G-)


Thanks in advance,
cheers,
mg





IntelliJ IDEA 2020.1.2 - @Newify(pattern=...) supported :-)

2020-06-14 Thread MG

Hi Groovy users,

just had time to check this out: The most current  IntelliJ build 
(Version: 2020.1.2, Build: 201.7846.76) from the 3rd of June finally 
contains support for the @Newify pattern parameter, which allows 
instance creation without the need for the new keyword, such as e.g. in 
Python G-)


Thank you again to everyone who upvoted, and to the people at Jetbrains 
who greenlighted/implemented this :-)


Cheers,
mg


Sample code:

@Newify(pattern=/[A-Z][A-Za-z0-9_]*/)// Instances of classes whose name conforms to the given regex pattern 
can be created without the need for the "new"-operator. @CompileStatic 
// works under static and dynamic compilation class NewifyTest {


@Canonical static class A {String a }
@Canonical class AB {String a;String b }
@Canonical class ABC {String a;String b;String c }

//@CompileStatic List createClassList() {
listToResultList( [
A('2018-04-08'),
StringBuilder('*lol*'),
AB("I am","class AB"),
ABC("A","B","C"),
Object(),

Reference(),Binding(),Double(123.456d),Integer(987),BigInteger('987654321',10),
BigDecimal('1234.5678')
])
}

List> listToResultList(List l) {
[ l.collect{ it.getClass().getName()}, l.collect{ 
it.toString().replaceAll(/@[a-f0-9]+\b/,'')} ]
}


@Test void newifyCheck() {
final List> resultList = createClassList()
println"resultList=$resultList" final String result0 
=resultList[0].join('\n')
final String result1 =resultList[1].join('\n')

final String fullyQualifiedThisPrefix 
="${this.getClass().canonicalName}\$" final String expected0 = [
"${fullyQualifiedThisPrefix}A",
'java.lang.StringBuilder',
"${fullyQualifiedThisPrefix}AB",
"${fullyQualifiedThisPrefix}ABC",
'java.lang.Object',

'groovy.lang.Reference','groovy.lang.Binding','java.lang.Double','java.lang.Integer','java.math.BigInteger',
'java.math.BigDecimal' ].join('\n')

final expected1 = [
"${fullyQualifiedThisPrefix}A(2018-04-08)",
'*lol*',
"${fullyQualifiedThisPrefix}AB(I am, class AB)",
"${fullyQualifiedThisPrefix}ABC(A, B, C)",
'java.lang.Object',

'groovy.lang.Reference','groovy.lang.Binding','123.456','987','987654321',
'1234.5678' ].join('\n')

assertEquals(result0,expected0)
assertEquals(result1,expected1)
}
}




Re: Congratulations to our newest committer Mikko Värri

2020-06-08 Thread MG

Hi Mikko,

also welcome from me & great that you are helping improve Groovy 
documentation G-)


Cheers,
mg

On 08/06/2020 12:37, Mikko Värri wrote:

Thank you all!  I'm honored and looking forward to spending more time on Groovy!

I'm not sure if it's customary to write a short introduction but I'll do it anyway: I'm 
from Finland, I've been into Groovy for almost 10 years I think, my twitter bio says 
"sneaking Groovy into customer systems" and that's what I've been doing all 
those years ;D

Yes, I tend to care about documentation, so fixing glitches in groovydoc has 
been an interest of mine.

-mikko



On 8. Jun 2020, at 3.06, 孙 岚  wrote:

Congratulations to Mikko Värri who is now an Apache Groovy committer:

https://projects.apache.org/committee.html?groovy
http://people.apache.org/phonebook.html?unix=groovy

Mikko has been mostly working on the groovydoc, which is important to Groovy 
users and developers.

Keep on your great work, Mikko.

Cheers,
Daniel Sun




Re: ASTT to convert positional to named?

2020-06-01 Thread MG

1. I don't seem to have gotten my own reply from the mailing list (also
   not in Junk/SPAM) - strange...
2. Yes, treating null as nil would alas prohibit any usage of null as a
   parameter value. That is a long standing problem in many
   languages... - I wish there were support for more NULL-like
   constants (de facto there is room for at least 4, using memory
   adress values 1 to 3 in addition to 0 = NULL), such as NIL or EMPTY,
   to be able to distinguish these cases.
3. I agree with the issue, it would be great if further improved named
   parameter support would be high on the agenda :-)

Cheers,
mg



On 01/06/2020 12:55, Mikko Värri wrote:



On 1. Jun 2020, at 2.46, MG  wrote:

@MapConstructor

On 31/05/2020 20:22, o...@ocs.cz wrote:



On 31. 5. 2020, at 6:37 PM, MG  wrote:
@NamedVariant

Thanks, will test the thing, probably it's precisely what I wanted to do.


On 31/05/2020 12:45, OCsite wrote:


@Named foo(bar,int bax=666,List baz) {
   ... whatever ...
}

turned to something like

foo(Map __map=null) {
   def bar=__map?.bar
   int bax=__map?.bax==null?666:__map?.bax
   List baz=__map?.baz
   ... whatever ...
}


One thing it doesn't cover, afaik, is default values for the args.  But I don't think a 
simple null check will do: you can't pass "bar: null" to the method, then.

There's at least one issue open for this: 
https://issues.apache.org/jira/browse/GROOVY-9532

-mikko





Re: ASTT to convert positional to named?

2020-05-31 Thread MG
Np, with the number of annotations in Groovy it's easy to overlook one - 
see if this one (or e.g. @MapConstructor 
http://docs.groovy-lang.org/2.5.0/html/gapi/index.html?groovy/transform/MapConstructor.html) 
does everything that you had in mind...

Cheers,
mg

On 31/05/2020 20:22, o...@ocs.cz wrote:

MG,

On 31. 5. 2020, at 6:37 PM, MG <mailto:mg...@arscreat.com>> wrote:
Inhowfar would that differ from the existing map based argument 
support, like @NamedVariant etc 
(http://docs.groovy-lang.org/2.5.0/html/gapi/groovy/transform/NamedVariant.html) 
<http://docs.groovy-lang.org/2.5.0/html/gapi/groovy/transform/NamedVariant.html>, 
respectively what is your intention here ?


Ha, I must be completely blind and dumb, too — I did check, but 
somehow, I completely overlooked that ASTT!


Thanks, will test the thing, probably it's precisely what I wanted to do.

All the best,
OC


On 31/05/2020 12:45, OCsite wrote:

Hi there,

for both convenience and considerably improved source readability 
and robustness, I am considering an ASTT which would convert 
positional arguments to named ones, i.e., something like


@Named foo(bar,int bax=666,List baz) {
  ... whatever ...
}

turned to something like

foo(Map __map=null) {
  def bar=__map?.bar
  int bax=__map?.bax==null?666:__map?.bax
  List baz=__map?.baz
  ... whatever ...
}

In farther future with my own typechecking script it might even 
allow to typecheck named arguments, though that might prove a bit at 
the difficult side — but technically possible.


Has anybody tried something like that before? If so, bumped into 
some hidden pitfalls perhaps?


Thanks,
OC









Re: ASTT to convert positional to named?

2020-05-31 Thread MG
Inhowfar would that differ from the existing map based argument support, 
like @NamedVariant etc 
(http://docs.groovy-lang.org/2.5.0/html/gapi/groovy/transform/NamedVariant.html) 
<http://docs.groovy-lang.org/2.5.0/html/gapi/groovy/transform/NamedVariant.html>, 
respectively what is your intention here ?

Cheers,
mg

On 31/05/2020 12:45, OCsite wrote:

Hi there,

for both convenience and considerably improved source readability and 
robustness, I am considering an ASTT which would convert positional 
arguments to named ones, i.e., something like


@Named foo(bar,int bax=666,List baz) {
  ... whatever ...
}

turned to something like

foo(Map __map=null) {
  def bar=__map?.bar
  int bax=__map?.bax==null?666:__map?.bax
  List baz=__map?.baz
  ... whatever ...
}

In farther future with my own typechecking script it might even allow 
to typecheck named arguments, though that might prove a bit at the 
difficult side — but technically possible.


Has anybody tried something like that before? If so, bumped into some 
hidden pitfalls perhaps?


Thanks,
OC





Re: How to test and deploy without groovy-all?

2020-05-20 Thread MG

Hi Mauro,

I think I can shed some light at where OC is coming from. Basically, if 
you have a project with very few dependencies and therefore few JARs, it 
is without any doubt convenient to have just a single 
groovy-all- JAR: You can check with one glance what Groovy 
version you are using, and upgrading to another Groovy version is 
deleting or moving away the existing groovy-all JAR and replacing it 
with the new one. It does not get any easier than that.


Now if you have an automated build process with dependency resolution, 
plus a corresponding fully automated deployment, then all of the above 
makes little to no sense. If, like in my case, automatic dependency 
resolution is a dream (secure network, no access to any Maven server), 
and deployment is only semi-automated, then it is not. Due to no 
automatic dependency resolution, I deploy all the Groovy JARs, and those 
are quite a lot (I have run into (small) problems since there were two 
different Groovy versions deployed in my JAR dir, and I overlooked one 
JAR when cleaning up manually).


It is no big deal, but if "all you want to do" is quickly (meaning: 
download one JAR and replace in build & (maybe multiple) deployment 
dirs) check out a new Groovy version, because you have a million other 
things to do (if I had spare time for stuff like that, I would much 
rather spend it on refactoring several years old, way-too-dynamic Groovy 
code and make it @CompileStatic, improve my core framework, etc), then 
the suggestion to set up a Gradle project just for that does sound a bit 
absurd (even if it might pay dividend later on - I personally don't like 
the fact that Gradle's minimal rebuidl capabilities (the last time I 
checked), still seemed to lag quite a bit behind using IntelliJ native 
builds) :-)


So while we all understand that Groovy being modular is the what is 
required / here to stay, for all non-fully-automated people, asking 
where groovy-all went is a very obvious question - and the answer "just 
build it yourself" is quite confusing at first glance, since if I can 
build it myself, why can't the Groovy project supply it in the first 
place* ? G-)


Cheers,
mg

*To which the answer is: Since only your project knows all its 
dependencies and can therefore avoid the problems Paul mentioned - but 
in a world where Java 8 is still going strong (we are on Java 11, but as 
we use Groovy exclusively, I am not sure if we would miss much/anything 
if we would still use 8, security issues aside) that is still new 
thinking to many people.



On 19/05/2020 09:02, Mauro Molinari wrote:

Il 18/05/20 18:47, OCsite ha scritto:
To write and maintain my own launch script takes about one thousandth 
time and effort as compared with learning a whole new ecosystem which 
I do not need at all (well, perhaps now for the first time and for 
the one and one sole thing, i.e., creating my own groovy-all, which 
/should/ be part of the distro).


IMHO Learning Gradle to build a simple Groovy project does not imply 
learning "a whole ecosystem".


By the way: by using Gradle I think I've never used groovy-all even 
when on 2.4.x. Never needed to bring it all with my application. ;-)


If you embed all libraries and each your app is a multigigabyte 
monster, then of course. If I embedded complete groovy/lib to my 
application, I would not need groovy-all in my Extension folder 
either; but that would be one terribly wrong engineering, as detailed 
above.


"multigigabyte monster" is a hyperbole ;-)

Some tens of megabytes for complex webapps with ~120 dependencies 
(either direct or transitive) is reality. I don't think this is a huge 
problem nowadays, it of course depends on what you're targeting.


In any case I can hardly follow you. You say you don't want to embed 
all your dependencies into a fat JAR or into a lib directory for each 
of your applications, because you have many dependencies and you don't 
want to duplicate them among your applications. But at the same time 
you're complaining because you'll now need I guess 2 or 3 small Groovy 
JARs rather than one fat JAR. It sounds like a contradiction to me. I 
can't understand what is stopping you from treating Groovy just like 
any other dependency of your project, like the mentioned fop, or 
xmlgraphics-commons, or any logging library you may use, or a JDBC 
driver, or whatsoever...


If the problem is "how do I know which Groovy JARs I need", perhaps 
you may again use Gradle to build the mentioned ZIP file, then look 
into the lib directory of that JAR and you'll discover all the JARs 
(including Groovy ones) that your application actually depends on, 
either directly or transitively. Then you can take what you need to 
adjust your deploy and share JARs among all your applications if you 
need to follow this route.


Mauro





Applying @AutoFinal to whole project

2020-05-02 Thread MG
Since I just did this, I wanted to quickly share how to apply @AutoFinal 
to all project files (effectively making all method/closure parameters 
final) using a Groovy configuration file. Due to a current restriction 
in the AutoFinal implementation, we have to explictly exclude interfaces 
from having the annotation applied.

Here is the relevant code:

// groovycConfig.groovy import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer import org.codehaus.groovy.control.customizers.CompilationCustomizer import org.codehaus.groovy.control.customizers.SourceAwareCustomizer import org.codehaus.groovy.ast.ClassNode import groovy.transform.AutoFinal import org.codehaus.groovy.transform.trait.Traits //configuration.addCompilationCustomizers(new 
ASTTransformationCustomizer(AutoFinal)) // Does not worrk: Groovyc: 
Error processing interface 
'at.gv.bmlv.groovyutil.compare.IdentityValuesToDebugStringTrait'. 
@AutoFinal only allowed for classes. final autoFinal =new SourceAwareCustomizer(new ASTTransformationCustomizer(AutoFinal))

autoFinal.setClassValidator{ ClassNode n-> !n.isInterface()} 
configuration.addCompilationCustomizers(autoFinal)
// groovycConfig.groovy - END


If you do not already have a Groovy configuration in your project: Just 
save as groovycConfig.groovy (e.g. in the project root), and e.g. in 
IntelliJ do
File\Settings\Groovy Compiler\Path to configscript: groovycConfig.groovy file here>

and rebuild your project.

Cheers,
mg




Re: Strategy for optionally excluding a named method parameter?

2020-04-25 Thread MG

Hi David,

since, as was mentioned, named parameters are implemented as a map 
underneath in Groovy, you should be able to remove the map entry of the 
parameter you do not want to pass, though I did not try this myself...


Cheers,
mg


On 25/04/2020 20:57, David Karr wrote:



On Sat, Apr 25, 2020 at 2:00 AM Rathinavelu <mailto:rathinav...@gmail.com>> wrote:


Named parameters are not available in Groovy, say, as in Python.,
though they say it is. Groovy has only mapped parameters. The
earlier mail works for a single ‘named’ parameter; if there are
more parameters Groovy does not work as ‘expected’; it treats them
only as positional parameters.

Kindly mail me an use-case.

T.Rathinavelu


The code sample looks something like this:

    functionName param1: value,
    param2: value,
    param3: value,
    param4: value,
    ...
    param25: value

For instance, we need to make either the previous call or the following:

    functionName param1: value,
    param2: value,
    param3: value,
    ...
    param25: value

Where the "param4" key and value are not provided. Presently, we have 
an "if" checking for a condition, followed by the "true" block with 
the first version of the function call with 25 parameters, followed by 
the "else" and the "false" block with the second version, which has 24 
parameters, all the same values as in the first block, except for the 
one key and value not provided in the second version.


Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
for Windows 10

*From: *David Karr <mailto:davidmichaelk...@gmail.com>
*Sent: *Saturday, April 25, 2020 1:48 AM
*To: *users@groovy.apache.org <mailto:users@groovy.apache.org>
*Subject: *Strategy for optionally excluding a named method parameter?

Lately my only Groovy work is scripted pipelines in Jenkins,
version 2.89.4 .

I'm working with an api that is somewhat dumb in one respect.  The
method we call takes ~25 parameters.  We send them as named
parameters. One of the parameters is of boolean type.  What we've
discovered from testing is that if we send a value as either
"true" or "false", it acts as if we sent "true".  If we construct
the call without that parameter entirely, it acts as if we sent
"false". I tried making it send null, but that just causes it to
fail at runtime.  We presently have an "if" for that one flag,
with two calls to the method, one taking 25 parameters, the other
taking 24.  It is really obnoxious.

Obviously, the proper fix is to change their api so that it works
correctly. The reality is, that's not going to happen any time
soon in geological terms.

Is there a concise groovy syntax we could use that would
optionally include or exclude a single parameter to the method?





Re: IntelliJ IDEA Groovy 2.5/3.0 - IntelliJ 2020.1

2020-04-15 Thread MG

Hi Daniil,

as far as I could see people have been voting on the child issues (only) 
for some time now, but thank you for clarifying that (it is what I meant 
by "please keep upvoting them") G-)


Cheers,
mg


On 15/04/2020 13:57, Daniil Ovchinnikov wrote:

Hi all,

There is actually little to no sense in upvoting the umbrella issue, but 
upvotes on particular features greatly help us to prioritize them, e.g. 
@MapConstructor will be done next.

Daniil Ovchinnikov
JetBrains


On 14 Apr 2020, at 11:19, MG  wrote:

Hi ,

IntelliJ 2020.1 was released a few days ago, but it does not seem to include 
any new features with regards to 
https://youtrack.jetbrains.com/issue/IDEA-193168 .

(The one feature that has been done (@Newify pattern support, i.e. global ctor 
call support without new keyword), says Fixed in builds 202.1095, and the 
newest IntelliJ is build 201.6668.121 .)

According to Youtrack, other Groovy features are not being worked on, so please 
keep upvoting them G-)

Cheers,
mg








IntelliJ IDEA Groovy 2.5/3.0 - IntelliJ 2020.1.1

2020-04-15 Thread MG
Quick update: According to a post by Konstantin Nisht from Jetbrains on 
Youtrack, @Newify pattern support will be in IntelliJ 2020.1.1. G-)

Cheers,
mg




IntelliJ IDEA Groovy 2.5/3.0 - IntelliJ 2020.1

2020-04-14 Thread MG

Hi ,

IntelliJ 2020.1 was released a few days ago, but it does not seem to 
include any new features with regards to 
https://youtrack.jetbrains.com/issue/IDEA-193168 .


(The one feature that has been done (@Newify pattern support, i.e. 
global ctor call support without new keyword), says Fixed in builds 
202.1095, and the newest IntelliJ is build 201.6668.121 .)


According to Youtrack, other Groovy features are not being worked on, so 
please keep upvoting them G-)


Cheers,
mg






IntelliJ IDEA Groovy 2.5/3.0 Feature Support - @AutoFinal/@NamedParam/@NamedDelegate

2020-03-19 Thread MG

Hi Groovy users,

added @AutoFinal* ticket & extended @NamedVariant to include @NamedParam 
and @NamedDelegate: https://youtrack.jetbrains.com/issue/IDEA-193168


Plz vote,
Cheers,
mg


*If you (like me) basically never reassign method/closure/ctor 
parameters inside methods/..., they are effectively final and should 
carry that modifier, for documentation purposes and to catch if a 
programmer does try to reassign.
 Alas that massively clutters the method signature - Groovy's 
@AutoFinal takes care of that for you, telling Groovy to assume every 
method/closure/ctor parameter inside an annotated class carries the 
final modifier (you can exclude a method/... again by annotating it 
with  @AutoFinal(enabled = false) )  G-)






IntelliJ IDEA Groovy 2.5/3.0 Feature Support - @Newify(pattern=...) - Update

2020-03-18 Thread MG

Hi Groovy users,

according to the JetBrains issue tracker, the @Newify(pattern=...) issue 
(https://youtrack.jetbrains.com/issue/IDEA-234806) 
<https://youtrack.jetbrains.com/issue/IDEA-234806> has been set to 
"fixed" by Konstantin Nisht about 3 hours ago (To be sure I checked, and 
it is not included in the current IntelliJ release (2019.3.4), which is 
not suprising, since that was released yesterday).


If you are reading this mailing list, welcome Konstantin & thank you :-)

Also thank you to everyone who voted, please keep voting, I hope to be 
able to put up the remaining Groovy 2.5 feature-child-tickets this week G-)


Cheers,
mg





Fwd: [YouTrack, Voted] Issue IDEA-193168: Fully Support Groovy 2.5 Features

2020-03-12 Thread MG
For anyone who might have missed that: You can coveniently vote for each 
child issue from the umbrella issue 
(https://youtrack.jetbrains.com/issue/IDEA-193168) by clicking on the 
thumbs up icon right next to the child issue's name G-)


Cheers,
mg


 Forwarded Message 
Subject: 	[YouTrack, Voted] Issue IDEA-193168: Fully Support Groovy 2.5 
Features

Date:   Thu, 12 Mar 2020 20:55:58 +
From:   Mikhail Stepura 
To: M G 



Feature was updated by Mikhail Stepura in project IntelliJ IDEA at 12 
Mar 2020 23:53.
	IDEA-193168 
<https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FIDEA-193168> 
Fully Support Groovy 2.5 Features 
<https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FIDEA-193168> 
Created by you


Votes   +1 (Mikhail Stepura). Total votes: 44

This message was sent by YouTrack <https://jetbrains.com/youtrack>, an 
issue tracker by JetBrains. You (*nahgeh*) received this message because 
you subscribe to notification events for the *Reported by me* saved 
search. To unsubscribe, you can mute notifications for this issue 
<https://youtrack.jetbrains.com/api/unsubscribe?token=MTU4NjU2MzIwMDAwMHwxMS0zNzMzMDV8MjUtMjAwOTc5OHxqZ0NLeWpONmVhalQ5b3MyUGhyZC04%0D%0ASHUxUWlZa1pDY2p5YlR1b1pkbzI0DQo%0D%0A> 
or edit your notification preferences 
<https://youtrack.jetbrains.com/oauth?state=%2Fusers%2F0d5f7108-2302-45ea-b002-9b0e7fb93f58%3Ftab%3Dnotifications>. 
[search: Reported by me] YouTrack 2019.3.67768


IntelliJ IDEA Groovy 2.5/3.0 Feature Support - @NamedVariant - Plz vote

2020-03-12 Thread MG

@NamedVariant issue is up: https://youtrack.jetbrains.com/issue/IDEA-235133

As always please vote,
Cheers,
mg

*Right now we have 9 and 8 votes for the existing individual child 
issues - thank to everyone who took the time - but we have 43 votes for 
the umbrella task...












Re: IntelliJ IDEA Groovy 2.5/3.0 - Vote for Indiviudal Issues

2020-03-12 Thread MG
@IntelliJ's build system: We use IntelliJ Groovy build, and have very 
vanilla requirements with regards to building our projects (basically 
it's just a larger number of interdependent modules with a bunch of 
artifacts), but alas even that does not work without a hitch: The 
"build-repeatedly-magically-fails"-problem I described here a while ago 
has (after years) thankfully disappeared, just to be replaced by a more 
benign one, where any change in one of a couple of our central Groovy 
modules makes the regular minimal rebuild fail, and we always have to 
rebuild the failing module in its entirety in that case. We can only 
live with it since those modules are relatively stable.*


Also Intellisense in the IntelliJ version we are currently using 
(2019.3.1) gets confused after a short while, and will mark correct code 
as invalid (as a weird workaround, one can comment out the "invalid" 
part of the line, and when commenting it back in, IntelliJ will be back 
on track most of the time).*


Which brings me to:
@"Another thing that comes to mind, JetBrains produces Kotlin, and 
Kotlin competes with Groovy - figure that one out!"
Alas, yes. As I have said here back when the discussion about Gradle 
Groovy vs Kotlin happened, there is an obvious conflict of interests 
here  - ideally you would want your IDE supplier to be as language 
agnostic as possible, which, due to the introduction of and ongoing 
investment in Kotlin, for Jetbrains is no longer the case.
I am still giving them the benefit of the doubt, but thinking back, 
IntelliJ Groovy support used to be top notch, and nowadays it is 
incomplete and suffers from quite a bit of problems. Hmmm...


In any case, even though the Groovy ecosystem is large & strong, in the 
end we are small fry, since it seems obvious to me their actual goal is 
not to replace Groovy, but over time to replace Java.
Then the #1 IDE and the #1 JVM language would come from one company in 
Prague. Not my dream scenario, for sure, after Java and the JVM 
landscape finally made big strides to being completely open source & 
much more community driven... (if I wanted MS (i.e. Visual Studio** & 
C#), I would not have returned to the JVM world from .NET in 2008)


Cheers,
mg

*None of that can be fixed by clearing the IntelliJ caches btw, we do 
that on a regular basis.
**Ironically enough, ReSharper by Jetbrains, at least back then, used to 
be the quintessential Visual Studio refactoring plugin back in 2008.




On 11/03/2020 19:36, Blake McBride wrote:

Hi MG,

The issues I've had with IntelliJ/JetBrains are general. IntelliJ is 
probably the best IDE out there but rather than make it even better 
they seem comfortable just staying a notch above the competition.  I 
guess they don't have to do better.


I've had issues with IntelliJ that are utterly and clearly wrong but 
they say it is a "feature".


Other times I spend hours trying to get IntelliJ to do something that 
ends up hidden deep in the bowels of IntelliJ rather than putting them 
where someone would look for them. This causes hours of wasted time, 
immense frustration, and needless contact with their support.


While their support is very responsive, they're too quick to 
dismiss nearly every issue.


Often a clear bug is discovered but their attitude is that not enough 
people use that feature so we're not going to fix it.  This attitude 
has been a big problem and might also be a factor in the Groovy issue.


Another thing that comes to mind, JetBrains produces Kotlin, and 
Kotlin competes with Groovy - figure that one out!


I've always thought that NetBeans was the most intuitive IDE.  Anytime 
I want to do something I guess at where it is and - boom - there it 
is!  I also see they're really making an effort to upgrade it.  I'll 
be watching them.


IntelliJ, like most build systems, has a convention over configuration 
attitude.  While this works really really well when you are building a 
conventional app, with either, when you try to drift the 
slightest from the convention (with good reason!) a five-minute setup 
can turn into weeks and constant headaches!!  In order to get around 
IntelliJ's and other build system's (Maven, Gradle, etc.) conventions, 
I ended up writing my own build system.  Problem is, I still need an 
IDE for developing and debugging.  I try not to use them for builds.


With regard to eclipse, personally, I've never worked with a worse IDE 
than eclipse.  eclipse:


1. the most unintuitive IDE I've ever used
2. the most buggy IDE I've ever used
3. the most out-of-date IDE I've ever used
4. the least supported IDE I've ever used

I've had a lot better luck with NetBeans!

A number of years ago I embarked, with a team, on a large Java 
project.  We started with eclipse.  We had endless memory issues and 
crashes.  We then switched to NetBeans 

Re: IntelliJ IDEA Groovy 2.5/3.0 - Vote for Indiviudal Issues

2020-03-12 Thread MG

Hi Blake,

thanks for sharing your experience, I am also not the biggest Eclipse 
fan, though I found it not too bad as a Java IDE a while back.


It is funny that you should mention Netbeans - I had nearly forgotten 
about it*, but I actually had the same as experience as you did with 
Netbeans: It was very intuitive, besides Java (and C++) had great 
Javascript support out of the box (whereas Eclipse sucked at this, 
whatever plugin I tried), and in general the fact that it did not put 
you in plugin hell and was not based on a "generic editor for 
everything" base appealed to me. Alas Groovy support was severly 
outdated/lacking a few years back when I evaluated our IDE options - 
does anyone have any recent experiences on what the status of Netbeans 
is with regards to Groovy support ?


Cheers,
mg

*Partially because other (Java only) teams in my organization are using 
Eclipse, and it is always like "Why do you guys need IntelliJ then ?" - 
to which the answer of course used to be "Because it has unparalleled 
Groovy support"



On 11/03/2020 19:36, Blake McBride wrote:

Hi MG,

The issues I've had with IntelliJ/JetBrains are general. IntelliJ is 
probably the best IDE out there but rather than make it even better 
they seem comfortable just staying a notch above the competition.  I 
guess they don't have to do better.


I've had issues with IntelliJ that are utterly and clearly wrong but 
they say it is a "feature".


Other times I spend hours trying to get IntelliJ to do something that 
ends up hidden deep in the bowels of IntelliJ rather than putting them 
where someone would look for them. This causes hours of wasted time, 
immense frustration, and needless contact with their support.


While their support is very responsive, they're too quick to 
dismiss nearly every issue.


Often a clear bug is discovered but their attitude is that not enough 
people use that feature so we're not going to fix it.  This attitude 
has been a big problem and might also be a factor in the Groovy issue.


Another thing that comes to mind, JetBrains produces Kotlin, and 
Kotlin competes with Groovy - figure that one out!


I've always thought that NetBeans was the most intuitive IDE.  Anytime 
I want to do something I guess at where it is and - boom - there it 
is!  I also see they're really making an effort to upgrade it.  I'll 
be watching them.


IntelliJ, like most build systems, has a convention over configuration 
attitude.  While this works really really well when you are building a 
conventional app, with either, when you try to drift the 
slightest from the convention (with good reason!) a five-minute setup 
can turn into weeks and constant headaches!!  In order to get around 
IntelliJ's and other build system's (Maven, Gradle, etc.) conventions, 
I ended up writing my own build system.  Problem is, I still need an 
IDE for developing and debugging.  I try not to use them for builds.


With regard to eclipse, personally, I've never worked with a worse IDE 
than eclipse.  eclipse:


1. the most unintuitive IDE I've ever used
2. the most buggy IDE I've ever used
3. the most out-of-date IDE I've ever used
4. the least supported IDE I've ever used

I've had a lot better luck with NetBeans!

A number of years ago I embarked, with a team, on a large Java 
project.  We started with eclipse.  We had endless memory issues and 
crashes.  We then switched to NetBeans and used it without 
incident for years.  I eventually switched to IntelliJ because of a 
promised feature.  I spent a lot of time moving this project (10,000 
classes!) to IntelliJ only to find that the promised feature is 
extremely buggy.  When I reported the problems JetBrains told me that 
not enough people used the feature and they are no longer supporting it.


While IntelliJ's support of Kotlin will no doubt remain first-class, 
my inclination is that Groovy will experience declining support by 
JetBrains for the above reasons.  Moving forward, you may have better 
luck with NetBeans.


[rant over]

Thanks.

Blake

On Wed, Mar 11, 2020 at 12:33 PM MG <mailto:mg...@arscreat.com>> wrote:


Hi Blake,

first of all thank you, and all who voted since my post, for
taking the time, appreciated.

Second: Is your IntelliJ/Jetbrains experience directly tied to
Groovy or to issues in general ? The guy responsible for Groovy in
IntelliJ, Daniil Ovchinnikov, seems to need community created,
upvoted child tasks:
see for instance his comment on the "Support for Groovy 3 syntax"
issue on  5 Dec 2018 17:07:
"@Pradeep Bhardwaj don't worry, the work is in progress. Most of
Groovy 3 features are already supported, please see child tasks
and vote for some (or all) of them."

In any case upvoting is the only thing we can easily do. If this
has no effec

IntelliJ IDEA Groovy 2.5/3.0 Feature Support - @MapConstructor

2020-03-11 Thread MG
I have checked @AutoImplement, and that seems to be working; existing 
closed issue has just been linked to umbrella task by Daniil.


Please vote for the @MapConstructor issue I just created: 
https://youtrack.jetbrains.com/issue/IDEA-235059


Cheers,
mg







Re: IntelliJ IDEA Groovy 2.5/3.0 - Vote for Indiviudal Issues

2020-03-11 Thread MG

Hi Blake,

first of all thank you, and all who voted since my post, for taking the 
time, appreciated.


Second: Is your IntelliJ/Jetbrains experience directly tied to Groovy or 
to issues in general ? The guy responsible for Groovy in IntelliJ, 
Daniil Ovchinnikov, seems to need community created, upvoted child tasks:
see for instance his comment on the "Support for Groovy 3 syntax" issue 
on  5 Dec 2018 17:07:
"@Pradeep Bhardwaj don't worry, the work is in progress. Most of Groovy 
3 features are already supported, please see child tasks and vote for 
some (or all) of them."


In any case upvoting is the only thing we can easily do. If this has no 
effect, my team will have to look into the Eclipse option again - great, 
after we convinced management that paying for IntelliJ was the way to go :-/

mg


On 11/03/2020 17:50, Blake McBride wrote:
Although I will vote up the Groovy issue you detail, being a long-time 
IntelliJ user, I can tell you first hand that upvoting an issue at 
JetBrains has no effect I am aware of.  I have seen critical issues 
get hundreds of votes and remain untouched for years.  They do what, 
when, and how they like.


On Wed, Mar 11, 2020 at 11:27 AM MG <mailto:mg...@arscreat.com>> wrote:


Hi guys,

up to this point, the first issue I created two days ago (see
previous
post for link) has gotten zero votes - if no one is voting for these
issues, then it makes no sense for me to put them up, so please do
not
only vote for the umbrella issue (which just got vote 37 - still
incredibly low given the large number of Groovy users out there), but
for each individual issue as well.

Consider to not only vote for the features you yourself would
immediately use - all of these features were included after some
discussion, because they were considederd to make Groovy a better
language, and some things need time to establish themselves, but
there
is no chance of that happening, if the most prevalent Groovy IDE
marks
the code as invalid and accordingly offers no
Intellisense/refactoring/etc support*.

Cheers,
mg

*I keep wondering what people new to Groovy think, if they try to
use a
feature introduced nearly 2 years ago, but their IDE marks it as
invalid
code...









IntelliJ IDEA Groovy 2.5/3.0 - Vote for Indiviudal Issues

2020-03-11 Thread MG

Hi guys,

up to this point, the first issue I created two days ago (see previous 
post for link) has gotten zero votes - if no one is voting for these 
issues, then it makes no sense for me to put them up, so please do not 
only vote for the umbrella issue (which just got vote 37 - still 
incredibly low given the large number of Groovy users out there), but 
for each individual issue as well.


Consider to not only vote for the features you yourself would 
immediately use - all of these features were included after some 
discussion, because they were considederd to make Groovy a better 
language, and some things need time to establish themselves, but there 
is no chance of that happening, if the most prevalent Groovy IDE marks 
the code as invalid and accordingly offers no 
Intellisense/refactoring/etc support*.


Cheers,
mg

*I keep wondering what people new to Groovy think, if they try to use a 
feature introduced nearly 2 years ago, but their IDE marks it as invalid 
code...








Re: IntelliJ IDEA Groovy 2.5/3.0 Feature Support - @Newify(pattern=...)

2020-03-08 Thread MG
In my personal opinion we should fade out the older solutions that do 
not support final class fields, have no type safety, etc, so I would not 
push Jetbrains to put effort into supporting this.
If one wants instance creation without new in Groovy, I expect he 
typically will put @Newify(pattern = /[A-Z].*/) into his Groovy 
configscript, to have it active in every class, so it would not matter 
that the older, more restricted version works without any annotation.


Cheers,
mg


On 09/03/2020 01:36, Paul King wrote:
The named argument shorthand, which doesn't require @Newify, displays 
errors too (currently won't work with your Foo example since it relies 
on a no-arg constructor and setters):

image.png
Cheers, Paul.

On Mon, Mar 9, 2020 at 10:00 AM MG <mailto:mg...@arscreat.com>> wrote:


Hi Groovy users,

the current IntelliJ IDEA (2019.3.3, built on February 11th 2020)
still
does not support all Groovy features introduced with Groovy 2.5.4
in mid
2018 (http://groovy-lang.org/releasenotes/groovy-2.5.html). I have
created an umbrella issue for this back then
(https://youtrack.jetbrains.com/issue/IDEA-193168), but it seems to
never have been fleshed out / worked on.

To help remedy this, I am planning to create indiviudal issues,
starting
with support for creating class instances without requiring the
use of
the new keyword:
https://youtrack.jetbrains.com/issue/IDEA-234806.

Groovy is all about being as concise and elegant as possible, so
it did
away with the needless Java semicolon at the end of lines, supports
string interpolation and multiline strings, etc. Creating class
instances / calling constructors without a new keyword is
something that
has existed in Python and Kotlin forever, so it is high time IntelliJ
IDEA supported this Groovy feature.

Please vote for these issues as I report them G-)
Cheers,
mg








IntelliJ IDEA Groovy 2.5/3.0 Feature Support - @Newify(pattern=...)

2020-03-08 Thread MG

Hi Groovy users,

the current IntelliJ IDEA (2019.3.3, built on February 11th 2020) still 
does not support all Groovy features introduced with Groovy 2.5.4 in mid 
2018 (http://groovy-lang.org/releasenotes/groovy-2.5.html). I have 
created an umbrella issue for this back then 
(https://youtrack.jetbrains.com/issue/IDEA-193168), but it seems to 
never have been fleshed out / worked on.


To help remedy this, I am planning to create indiviudal issues, starting 
with support for creating class instances without requiring the use of 
the new keyword:

https://youtrack.jetbrains.com/issue/IDEA-234806.

Groovy is all about being as concise and elegant as possible, so it did 
away with the needless Java semicolon at the end of lines, supports 
string interpolation and multiline strings, etc. Creating class 
instances / calling constructors without a new keyword is something that 
has existed in Python and Kotlin forever, so it is high time IntelliJ 
IDEA supported this Groovy feature.


Please vote for these issues as I report them G-)
Cheers,
mg






Re: please help : GroovyCastException: why ? - introduce @ClassName annotation ?

2020-02-28 Thread MG

Glad the community could help you & things look Groovy now G-)

Cheers,

mg



On 28/02/2020 09:02, Mickaël SALMON wrote:

Thank you very much for your support.
Except this tricky use case for which I'm sure  will find a solution 
for refactoring the existing scripts, Groovy integration in my Java 
application is OK Now.


Chers, Mickael.



*From:* Jochen Theodorou 
*Sent:* Thursday, February 27, 2020 16:39
*To:* Mickaël SALMON 
*Subject:* Re: please help : GroovyCastException: why ?


Am 27.02.20 um 16:16 schrieb Mickaël SALMON:
> Okay.
>
> In fact, I don't understand which this code works in Java but not in
> Groovy (even if naming a variable with a class name, not in camel case,
> is weird ...).


That is because Groovy has an overlap of variable names and class names
Java does not have.

In Java a=b is clearely assigning the value of variable b to a. If a is
a class instead it will fail compilation. If there is a variable b and b
class a, then the variable will be taken. To ensure you do mean the
class, you have to write a=b.class

In Groovy a=b is different.here b could be also a class b. if there is
no local variable b, then b might be still a class or (dynamic)
property. Thus the compiler will first check if it is a class and then
proceed to make it a (dynamic) property access. In dynamic Groovy this
expression def a=b may never fail compilation, because even if there is
no class b and no local variable b and no static property b, there is
still a possibly dynamic property b. If it then does not exist at
runtime, you will get a MissingPropertyException. But this mechanism
proofed to be problematic for the users. It turned out to be a problem
for the performance. Which is why we said, that if the name b follows
the class naming conventions of upper-case and camel-case, it must be a
class name and otherwise not.

bye Jochen




Re: please help : GroovyCastException: why ?

2020-02-24 Thread MG

Article articleTmp = (Article) Article;

in Groovy is the same as

Article articleTmp = (Article) Article.getClass();

in Java.

Article.getClass()

is of type Class, so casting it to Article will fail - what you 
want to do ist pass an Article instance, not the class, I presume...


hth,
mg


On 24/02/2020 18:24, Mickaël SALMON wrote:

Hello,

I'm using last Groovy version (3.0.1) in my Java application to run 
user defined scripts (Java based).

Here is how a script is executed (sorry for the formatting) :

   public Object eval(String scriptName, String script, MapObject> mapVariable)

                   throws CochiseException {
       groovy.lang.Script groovyScript = this.scriptCache.get(scriptName);
       if (groovyScript == null) {
           groovyScript = new GroovyShell().parse(script);
 this.scriptCache.put(scriptName, groovyScript);
       }
 groovyScript.setBinding(new Binding(mapVariable));
       return groovyScript.run();
   }

I have the following exception when I pass the object "Article" of 
class "com.sylob.cochise.dm1.ejb.entite.article.Article" in the Map of 
variables :


org.codehaus.groovy.runtime.typehandling.GroovyCastException:
Cannot cast object 'interface
com.sylob.cochise.dm1.ejb.entite.article.Article' with class
'java.lang.Class' to class
'com.sylob.cochise.dm1.ejb.entite.article.Article'


Here is the script :

import com.sylob.cochise.dm1.ejb.entite.article.Article;

println "CL import Article : " +  Article.class.getClassLoader()
println "CL var Article: " + Article.getClass().getClassLoader()

Article articleTmp = (Article) Article;
// ... some stuff


This not seem to be a classLoader problem, because same class loader 
is used to load both com.sylob.cochise.dm1.ejb.entite.article.Article 
class in the script and "Article" object in the calling application.

Also tested with 2.5.9, same error.

What's wrong here ?

Thanks.





Re: [ANNOUNCE] Apache Groovy 3.0.0 released

2020-02-10 Thread MG




G-)reat job Groovy team, congrats & much appreciated !

mg



On 10/02/2020 14:05, Paul King wrote:

Dear community,

The Apache Groovy team is pleased to announce version 3.0.0 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.

We are sure you'll enjoy the features in this new version of Groovy.
Your feedback on any unintentional glitches is welcome.

This release includes 15 bug fixes/improvements since RC3 as outlined
in the changelog:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123&version=12345566
(There are over 500 new features, improvements and bug fixes since Groovy 2.5!)

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. We value all forms of
contribution from our contributors past and present but special
mention for this release should be made to Daniel Sun for his
instrumental contributions to the Parrot parser and Eric Milles for
his recent improvements to Groovy's static compiler.

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: Ubuntu Snaps

2019-06-28 Thread MG

@scripting: G-)

@linuxbrew: Thnx for the info. What I meant was that alas neither our 
servers nor clients are connected to the internet, so all these nice 
services (including Maven repositories *sigh*) do not work...



On 28/06/2019 17:20, Tamás Cservenák wrote:

Same here re scripting...

But just FYI, groovy is available from linuxbrew as well (macOS know 
what Homebrew is, this is linux flavor that is now merged into 
official Homebrew).
Along with adoptopenjdk and groovy (and rest of tools brew offers), 
for me, it is the simplest way to keep up to date with these tools.


Thanks and happy brewing!
Tamas

On Fri, Jun 28, 2019 at 5:12 PM MG <mailto:mg...@arscreat.com>> wrote:


I'm always pushing to use Groovy instead of Unix scripting or Python,
Perl, ... fors scripting on our servers, so even if we cannot use
such
services in our environment, that is a good development :-)





Re: Ubuntu Snaps

2019-06-28 Thread MG
I'm always pushing to use Groovy instead of Unix scripting or Python, 
Perl, ... fors scripting on our servers, so even if we cannot use such 
services in our environment, that is a good development :-)


On 28/06/2019 11:14, Paul King wrote:


Hi everyone,

Linux users can now get Groovy via the Snap Store:

https://snapcraft.io/groovy

Full instructions for many common distros are available from that 
site. It will normally involve running:


> snap install groovy --classic

... once you have Snap installed (if you don't already). Or if you 
have the Snap Store graphical desktop application, you can simply 
browse to Apache Groovy and click Install.


For Linux users, Snaps complement the other ways of getting Groovy. Enjoy!

Cheers, Paul.





Re: requesting your advice on picocli modules

2019-05-31 Thread MG

Hi Remko,

I agree option 1) is the cleanest, as well as it being the direction all 
of Groovy seems to be moving.


Cheers,
mg


On 30/05/2019 14:50, Remko Popma wrote:

Hi,

I maintain the picocli library for creating command line applications 
in Groovy, Java, and other JVM languages.

I have a question for the Groovy community (both users and developers):

Currently, the picocli main jar contains both the core `picocli` 
package and a `picocli.groovy` package with classes that make it easy 
for Groovy scripts to use picocli annotations. I'm considering 
splitting up this jar.


In an upcoming major release of the library I plan to provide a Java 9 
JPMS modular jar containing just the core `picocli` package and 
additionally a `module-info.class` to make this jar a full-fledged 
Java module.


The question is what to do with the picocli.groovy package. I see two 
options:
1) have a `picocli-groovy` jar containing _only_ the picocli.groovy 
package - this jar would require (have a dependency on) the core 
picocli jar (the JPMS modular jar). Ideally this `picocli-groovy` jar 
would also be a JPMS module, but not sure if that's possible.
2) have a `picocli-legacy?` (name TBD) jar containing both the core 
picocli package and the picocli.groovy package - similar to the 
current picocli-3.9.x jar


I believe the first option may be cleanest. Scripts would need to 
change their grape module from @Grab('info.picocli:picocli:$version') 
to @Grab('info.picocli:picocli-groovy:4.0.0') and that would bring in 
the transitive dependency on 'info.picocli:picocli:4.0.0', if my 
understanding is correct.


Can anyone see any drawbacks with this approach?
Would there be any point in additionally providing a `picocli-legacy` 
(name TBD) jar containing both the core picocli package and the 
picocli.groovy package, similar to the current picocli-3.9.x jar?


On a side-note, has anyone had any issues with putting the 
`module-info.class` in the root of the modular jar versus putting it 
in META-INF/versions/9/ in the jar?
Some people <https://github.com/moditect/moditect/issues/67> use 
META-INF/versions/9/ as a way to (hopefully) avoid issues with older 
tools unable to cope with the `module-info.class`. Does anyone have 
any experience with this?


Remko





Re: new GroovyCliBuilder

2019-05-24 Thread MG

Thanks Remko, I will switch the import & yes I do :-)

On 24/05/2019 19:39, Remko Popma wrote:
The new CliBuilder annotations API works well for both the Commons CLI 
and the picocli implementation.
(And I agree that the annotations API has some advantages over the 
previous DSL style, but that may be a matter of taste.)


Note that you can swap the implementation from Commons CLI to picocli 
by changing the import

from
import groovy.cli.commons.CliBuilder
to
import groovy.cli.picocli.CliBuilder
With the latter the usage help will show ANSI colors and gives some 
other features like the `cliBuilder.usageMessage 
<http://docs.groovy-lang.org/latest/html/gapi/groovy/cli/picocli/CliBuilder.html>` 
property to customize the usage help message.


Glad you like it! :-)


On Sat, May 25, 2019 at 2:11 AM MG <mailto:mg...@arscreat.com>> wrote:


Hi guys,

just wanted to say that I recently had to revisit some older Groovy script 
code in my project, and I took the opportunity to switch the old CliBuilder 
implementation to the new Picocli based one 
(http://docs.groovy-lang.org/latest/html/gapi/groovy/cli/commons/CliBuilder.html
) - and I can just say that it is an absolute joy to work with: Concise, 
elegant, and type safe G-)


import groovy.cli.commons.CliBuilder
import groovy.cli.Option
import groovy.cli.Unparsed

// Alternative is to use an interface and let Groovy instantiate a class 
instance from it
class MyOptions {
  boolean isTestRun
  @Option(shortName='h', description='output help info') Boolean help
  @Option(shortName='r', description='process regular entries') Boolean 
regular
  // etc (for supported types outside of Boolean see URL above)
  @Unparsed List remaining // all additional options given

  MyScriptOptions(boolean isTestRun) { this.isTestRun = isTestRun }
}
  


final cli = new CliBuilder(usage:'my_powerful_groovy_script')
def opts = new MyOptions(true)
cli.parseFromInstance(opts, args.split())  // From now on all cmd
line params can be accessed in a type safe manner

if(opts.help) {
  println cli.usage()
  System.exit(0)
}

if(opts.regular) {
  ...
}

Cheers,
mg









new GroovyCliBuilder

2019-05-24 Thread MG

Hi guys,

just wanted to say that I recently had to revisit some older Groovy script code 
in my project, and I took the opportunity to switch the old CliBuilder 
implementation to the new Picocli based one 
(http://docs.groovy-lang.org/latest/html/gapi/groovy/cli/commons/CliBuilder.html
) - and I can just say that it is an absolute joy to work with: Concise, 
elegant, and type safe G-)


import groovy.cli.commons.CliBuilder
import groovy.cli.Option
import groovy.cli.Unparsed

// Alternative is to use an interface and let Groovy instantiate a class 
instance from it
class MyOptions {
 boolean isTestRun
 @Option(shortName='h', description='output help info') Boolean help
 @Option(shortName='r', description='process regular entries') Boolean regular
 // etc (for supported types outside of Boolean see URL above)
 @Unparsed List remaining // all additional options given

 MyScriptOptions(boolean isTestRun) { this.isTestRun = isTestRun }
}
 


final cli = new CliBuilder(usage:'my_powerful_groovy_script')
def opts = new MyOptions(true)
cli.parseFromInstance(opts, args.split())  // From now on all cmd line 
params can be accessed in a type safe manner


if(opts.help) {
  println cli.usage()
  System.exit(0)
}

if(opts.regular) {
  ...
}

Cheers,
mg







Re: Static imports seem to win over a method in closure's delegate

2019-04-12 Thread MG

See http://mrhaki.blogspot.com/2009/10/groovy-goodness-static-imports.html

For Web GUI programming we use Groovy together with Vaadin, and I 
recently had some cases, where e.g. an anonymous class method calls a 
Groovy closure which calls a Groovy closure which calls a method of the 
orginal containing class. In these cases it can become hard to have the 
expected method get called, and I also found that (depending on the 
situation) either using import aliasing or introducing a uniquely named 
helper method in the right class can clear things up quick & easy.


Cheers,
mg


On 12/04/2019 23:14, Paul King wrote:

Using import aliases can be a good workaround for such a case.

On Sat, Apr 13, 2019 at 4:58 AM Jochen Theodorou <mailto:blackd...@gmx.org>> wrote:


On 10.04.19 16:05, Herrendorf Johannes wrote:
> Hi Groovy users,
>
> I’m currently building a DSL in groovy and found some strange
behaviour
> I have no explanation for: If a method pointer with name
"myMethod" is
> imported as static import and a closure has a delegate with a method
> "myMethod" and it's delegation strategy is set to
"DELEGATION_ONLY", the
> imported method is always called inside the closure - the delegate
> property seems to be ignored.

two things to always remember:
* closure delegation is a runtime mechanism, it has no influence on
static compiled features
* static imports are compiled statically

The later is not because we want this, but because we have to more or
less. And it is painful. I can imagine a system where this is not
required, but that is far from easy or efficient.

[...]
> import static mailinglist.SomeOtherClass.myMethod
[...]
>           // dispatched to SomeOtherClass.myMethod; correct
>          myMethod "Hello"
>          closureStuff {
>              // dispatched to SomeOtherClass.myMethod, but I
expected that
>                       // it's dispatched to
ClosureDelegate.myMethod instead
>              myMethod "Good Morning"
>          }
[...]
> Am I missing something or is this a bug? Thanks for your help in
advance!

In short it is a limitation. I am not sure we can really do something
against that.

bye Jochen





Re: Become a Groovy Ant GA-)

2019-04-01 Thread MG

Hi Daniel,

On 01/04/2019 02:55, Daniel.Sun wrote:

Thanks a lot for your donating to Friends of Groovy Open Collective,
every little helps.


Spot on - as Tesco has known since 1993 ;-)
https://www.creativereview.co.uk/every-little-helps/


Up to now, the fund can sponsor about 4.5 man-day work according to
the average salary of Java Developer:
https://www.indeed.com/salaries/Java-Developer-Salaries


Thank you for pointing that out. My idea, as I've said, is that the 
large number of Groovy users out there each give a little, so that the 
small number of people who do the actual work can be supported and 
Groovy thrives !
An ocean is made of a myriad of tiny droplets - so please spread the 
word GA-)


Cheers,
mg








Become a Groovy Ant GA-)

2019-03-31 Thread MG

Hi Groovy users,

I have recently decided to back the "Friends of Apache Groovy" Patreon

https://opencollective.com/friends-of-groovy

on the lowest ($5) level.

Here is why: It was clear to me that backing it on the $100 level did 
not feel compatible with our family income (and in turn the Missus ;-) 
), and that my max conceivable level would be in the $50 area. There are 
individuals that back at both these levels, and while I am grateful for 
that, I do not expect that a large number of people will do so. I also 
felt slightly intimitated by their willingness to invest so much money 
every month into a single open source project: Given that I pay 14 EUR 
per month for Netflix for my whole family, or 15 EUR for all of us for 
Spotify, or give 10 EUR per month to the WWF, or 3 EUR to avaaz, at 
least to me it felt slightly off.


So I am calling for everyone to become a Groovy Ant, spread the word, 
and fund this great language on a level that does not personally hurt, 
so that it might live long and prosper GA-)


Cheers,
mg

PS: Alas Patreon does not support backing on a regular basis through 
Paypal, which also threw me off at first (they claim technical 
difficulties). If you prefer to use Paypal, you might consider donating 
$50 for the year (2 months off ;-) ).








Re: Groovy file associations on Windows

2019-02-11 Thread MG
Just a general reminder: Not every company using Groovy has unrestricted 
internet access... :-)

Cheers,
mg

On 11/02/2019 14:11, Keegan Witt wrote:
Do folks using it really need it to be in the lib directory with all 
the other jars? Or could they just use Grapes/Grab?


If it's truly helpful, I can keep it.  I'm just wondering if it's 
overkill.


On Mon, Feb 11, 2019, 2:19 AM Paul King <mailto:pa...@asert.com.au> wrote:


I'd be inclined to keep GPars in the mix for now. It isn't
actively maintained but is still very useful in its current form
and I hope to put some time into it at some stage.

Cheers, Paul.


On Mon, Feb 11, 2019 at 12:24 PM Keegan Witt mailto:keeganw...@gmail.com>> wrote:

In addition to removing projects that are no longer developed
from the Groovy Windows installer (Gpars, Gaelyk, Scriptom,
EasyB, Gant, GMock), I'm considering removing the exe files
from groovy-native-launcher
<https://github.com/groovy/groovy-native-launcher>. These
haven't been compiled in quite a while and are just another
thing to maintain.  As I see it, there are two primary
benefits these provide.

 1. Provide a way to create file associations so you can
double click a Groovy file, or run myFile.groovy instead
of groovy myFile.groovy.
 2. Hide the command window when launching GroovyConsole.

For #2, I can work around this with a VBScript file (or
NirCmd).  #1 doesn't have a good way to solve other than the
current native binary solution since Launch4J doesn't support
variable expansion
<https://sourceforge.net/p/launch4j/bugs/162/>.  My question
is, do many folks need this functionality? It's something I've
never personally used.  Please weigh in with your thoughts.

-Keegan





Re: [PROPOSAL]About creating open collective for Groovy programming language in the name of Groovy Community

2019-01-08 Thread MG



Am 08.01.2019 um 11:54 schrieb Paul King:


> (4) While sponsorship is below what we'd like and below what it
has been
> at some previous points in Groovy life, it isn't 0. We have several
> existing sponsors, e.g. OCI. The wording about the collective
should take
> that into consideration.

     Yep. OCI is a great company for Groovy! We always appreciate its
sponsorship.

      Let's imagine that would be really great if more people
involve into
developing Groovy, more big features(e.g. MOP2, async/await) are
completed
and hard issues(e.g. generics of STC) are fixed every year :-)


Totally agree with you, just suggesting the wording used is sensitive 
to existing players. I can help craft wording if needed.




Might be worth thinking about whether existing sponsors would consider 
giving their donation through the same channel ? Could have different 
tiers of sponsorship (gold, silver, etc), with respective logo sizes, 
etc to differentiate. Would lead to a greater exposure for them...
I guess it would also not be too hard to integrate a sponsor names or 
logos into e.g. Groovy console (if Apache allows that)...


Cheers,
mg





Re: What is the best replacement for running scripts using groovy-all?

2018-12-19 Thread MG

Hi,

out of curiosity (and because having a fat jar again might be 
conventient at some point in the future in my work environment (also no 
internet access)):


This solution proposed by Keith does not work
https://github.com/gradle/gradle-groovy-all
?

Cheers,
mg



Am 19.12.2018 um 23:33 schrieb Paul Moore:

On Wed, 19 Dec 2018 at 21:23, James Kleeh  wrote:

Paul,

The best solution is to use Maven or Gradle to create an all-in-one (fat) jar 
that you can ship and run with java -jar

Gradle has a shadow plugin and Maven has a shade plugin to do just that.

Thanks. I'd come to the conclusion that Gradle was likely the solution
I should be looking at, and I've spent the evening trying to set up a
basic Gradle script that does what I want. After a lot of
experimentation, I came up with the following, which seems to do what
I want:

-- start build.gradle --

version = "0.1"

configurations {
 deploy
}

dependencies {
 deploy 'org.codehaus.groovy:groovy-all:2.5.4'
}

repositories {
 jcenter()
}

task copyDeps(type:Copy, group: "Custom", description: "Copies project
dependencies") {
 from configurations.deploy.collect { it.absolutePath }
 into "dest/lib"
}

task copy(type: Copy, group: "Custom", description: "Copies sources to
the dest directory") {
 from "src"
 include "*.groovy"
 into "dest"
}

task deploy(type:Zip, group: "Custom", description: "Build a deployment zip") {
 dependsOn copyDeps
 dependsOn copy
 from "dest"
 setArchiveName "${project.name}-${project.version}.zip"
}

-- end build.gradle --

It doesn't create a fat jar yet, but I can look into setting that up.
The various existing plugins seem to be dependent upon the
infrastructure set up by the java plugin, which I don't really
understand (or need, as far as I can tell) so they may not be of much
help. But I'm not sure what I need to do yet to write my own.
Something simple like

task customFatJar(type: Jar) {
 dependsOn copyDeps
 baseName = 'all-in-one-jar'
 from "dest/lib"
}

gives me an "all-in-one-jar.jar" that contains the dependency jars
directly included, rather than being unpacked. So there's more I need
to do here...

Paul





Re: Long String concatenation failed

2018-09-25 Thread mg
I don't know if your specific case might be improved in the future, but in 
general Groovy supports e.g. operator overloading as well as DSL creation, 
which in turn means that it cannot always be 100% Java copy & paste compatible, 
even if it strives to do so as much as possible.
In any case it should not take long to refactor your code...
 Ursprüngliche Nachricht Von: Jmeter Tea  
Datum: 25.09.18  15:47  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: 
Long String concatenation failed 
mg: Yes, I saw that it's working, but still,
groovy should add sugar to java instead of removing support of working code in 
java as:String text= "0"+"1" +"2" +"3";
Which I'm getting error:javax.script.ScriptException: 
groovy.lang.MissingMethodException: No signature of method: 
java.lang.String.positive() is applicable for argument types: () values: 
[]Possible solutions: notify(), tokenize(), size(), size()
Can I open a bug in groovy for this?
On Tue, Sep 25, 2018 at 4:04 PM, mg  wrote:
You can have new lines, just move the "<<" oi the end of the previous line, so 
Groovy knows there is more coming (Groovy does not need end-of-line semicolons 
btw):
String text ="" <" << vars["id2"] << ""
 Ursprüngliche Nachricht Von: Jmeter Tea  
Datum: 25.09.18  14:54  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: 
Long String concatenation failed 
Thank for your answers, I still have some comments:mg: I don't want to have a 
huge line with 20 parameters that can't be seen on screen so I need new lines 
between parameters

Nelson, Erick: I don't need XML as the article suggest "
builder classes to create XML "

On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick  
wrote:








No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
 
 

Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523

 
 

From: mg 

Reply-To: "users@groovy.apache.org" 

Date: Tuesday, September 25, 2018 at 5:19 AM

To: "users@groovy.apache.org" 

Subject: Re: Long String concatenation failed


 

If it is just the CTE that is the problem, you just have ro move the "<<" to 
the end of the previous line... 


 



 Ursprüngliche Nachricht 


Von: Jmeter Tea 



Datum: 25.09.18 09:56 (GMT+01:00) 



An: users@groovy.apache.org 


Betreff: Long String concatenation failed



 






Hello,
I have to  concatenate a lot of variables in a script and I want to make it 
readable, but I failed to separate lines as in java, The following code doesn't 
compile due to:


Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: 
startup failed:


Script1.groovy: 2: unexpected token: << @ line 2, column 1.


   << vars["id2"] << ""


 
Code:
String text ="" <" 
<< vars["id2"] << "";

 


Is there a workaround or a better way concatenation a string in groovy?


 


Related question:


https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables


 


Thank you














Re: Long String concatenation failed

2018-09-25 Thread mg
You can have new lines, just move the "<<" oi the end of the previous line, so 
Groovy knows there is more coming (Groovy does not need end-of-line semicolons 
btw):
String text ="" <" << vars["id2"] << ""
 Ursprüngliche Nachricht Von: Jmeter Tea  
Datum: 25.09.18  14:54  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: 
Long String concatenation failed 
Thank for your answers, I still have some comments:mg: I don't want to have a 
huge line with 20 parameters that can't be seen on screen so I need new lines 
between parameters

Nelson, Erick: I don't need XML as the article suggest "
builder classes to create XML "

On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick  
wrote:








No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
 
 

Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523

 
 

From: mg 

Reply-To: "users@groovy.apache.org" 

Date: Tuesday, September 25, 2018 at 5:19 AM

To: "users@groovy.apache.org" 

Subject: Re: Long String concatenation failed


 

If it is just the CTE that is the problem, you just have ro move the "<<" to 
the end of the previous line... 


 



 Ursprüngliche Nachricht 


Von: Jmeter Tea 



Datum: 25.09.18 09:56 (GMT+01:00) 



An: users@groovy.apache.org 


Betreff: Long String concatenation failed



 






Hello,
I have to  concatenate a lot of variables in a script and I want to make it 
readable, but I failed to separate lines as in java, The following code doesn't 
compile due to:


Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: 
startup failed:


Script1.groovy: 2: unexpected token: << @ line 2, column 1.


   << vars["id2"] << ""


 
Code:
String text ="" <" 
<< vars["id2"] << "";

 


Is there a workaround or a better way concatenation a string in groovy?


 


Related question:


https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables


 


Thank you












Re: Long String concatenation failed

2018-09-25 Thread mg
I replied to the original question and how to fix the the compile time error 
shown there, not your (valid) suggestion for a completely different approach... 
:-)
 Ursprüngliche Nachricht Von: "Nelson, Erick" 
 Datum: 25.09.18  14:39  (GMT+01:00) An: 
users@groovy.apache.org Betreff: Re: Long String concatenation failed 


No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
 
 

Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523

 
 

From: mg 

Reply-To: "users@groovy.apache.org" 

Date: Tuesday, September 25, 2018 at 5:19 AM

To: "users@groovy.apache.org" 

Subject: Re: Long String concatenation failed


 

If it is just the CTE that is the problem, you just have ro move the "<<" to 
the end of the previous line... 


 



 Ursprüngliche Nachricht 


Von: Jmeter Tea 



Datum: 25.09.18 09:56 (GMT+01:00) 



An: users@groovy.apache.org 


Betreff: Long String concatenation failed



 






Hello,
I have to  concatenate a lot of variables in a script and I want to make it 
readable, but I failed to separate lines as in java, The following code doesn't 
compile due to:


Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: 
startup failed:


Script1.groovy: 2: unexpected token: << @ line 2, column 1.


   << vars["id2"] << ""


 
Code:
String text ="" <" 
<< vars["id2"] << "";

 


Is there a workaround or a better way concatenation a string in groovy?


 


Related question:


https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables


 


Thank you








Re: Long String concatenation failed

2018-09-25 Thread mg
If it is just the CTE that is the problem, you just have ro move the "<<" to 
the end of the previous line... 
 Ursprüngliche Nachricht Von: Jmeter Tea  
Datum: 25.09.18  09:56  (GMT+01:00) An: users@groovy.apache.org Betreff: Long 
String concatenation failed 


Hello,I have to 

concatenate a lot of variables in a script and I want to make it readable, but 
I failed to separate lines as in java, The following code doesn't compile due 
to:Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: 
startup failed:Script1.groovy: 2: unexpected token: << @ line 2, column 1.   << 
vars["id2"] << ""
Code:
String text ="" <" 
<< vars["id2"] << "";
Is there a workaround or a better way concatenation a string in groovy?
Related 
question:https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables

Thank you


Re: @MapConstructor + @CompileStatic on Static Inner Class => CTE

2018-09-03 Thread MG

Might have been reported before. Will do.

On 04.09.2018 00:12, Paul King wrote:

Please create an issue. VerifyError is always a bug.

On Tue, Sep 4, 2018 at 4:55 AM MG <mailto:mg...@arscreat.com>> wrote:


The following code using @MapConstructor on a static inner class
raises
a compile time error (see end of mail; different error when making
the
inner class non-static):

import groovy.transform.CompileStatic
import groovy.transform.MapConstructor

@CompileStatic
class GroovyMapConstructorCheck {

 @MapConstructor(noArg = true)
 static class Goo {
 final String s0 = "text0"
 final int x0
 final String s1
 final String s2 = "TEXT2"
 final o0

 @Override
 public String toString() {
 return "Goo(|$s0|,|$x0|,|$s1|,|$s2|,|$o0|)"
 }
 }

 void go() {
 println new Goo()
 println new Goo(s0:"abc")
 println new Goo(x0:123, s0:"abc")
 println new Goo(s1:"S1", s2:"S2", x0:-999, o0:new Object(),
s0:"S0")
 final goo = new Goo(s1:"S1", s2:"S2", x0:-999, o0:new
Object(),
s0:"S0")
 }
}

final check = new GroovyMapConstructorCheck()
check.go()

/*
Compile time error:

java.lang.VerifyError: Bad type on operand stack
Exception Details:
   Location:
GroovyMapConstructorCheck$Goo.(Ljava/util/Map;)V @85:
invokevirtual
   Reason:
 Type 'GroovyMapConstructorCheck$Goo' (current frame,
stack[0]) is
not assignable to 'groovy/lang/Closure'
   Current Frame:
 bci: @85
 flags: { }
 locals: { 'GroovyMapConstructorCheck$Goo', 'java/lang/Object',
'java/lang/String', 'java/lang/String', 'groovy/lang/MetaClass' }
 stack: { 'GroovyMapConstructorCheck$Goo' }
   Bytecode:
 0x000: 2ab7 001b 121d 4d2c 2a5f b500 1f2c 5712
 0x010: 214e 2d2a 5fb5 0023 2d57 2ab6 0027 3a04
 0x020: 1904 2a5f b500 2919 0457 2bc7 0007 04a7
 0x030: 0004 0399 001a 03bd 0004 b800 2f3a 0519
 0x040: 0512 31b8 0035 c000 314c 1905 572a 2bb8
 0x050: 003b 0157 2ab6 0041 c000 4312 44b9 004a
 0x060: 0200 9900 232a b600 41c0 0043 1244 b900
 0x070: 4e02 003a 0619 06b8 0054 c000 562a 5fb5
 0x080: 001f 1906 572a b600 41c0 0043 1257 b900
 0x090: 4a02 0099 0020 2ab6 0041 c000 4312 57b9
 0x0a0: 004e 0200 3a07 1907 b800 5d2a 5fb5 005f
 0x0b0: 1907 572a b600 41c0 0043 1260 b900 4a02
 0x0c0: 0099 0023 2ab6 0041 c000 4312 60b9 004e
 0x0d0: 0200 3a08 1908 b800 54c0 0056 2a5f b500
 0x0e0: 6219 0857 2ab6 0041 c000 4312 63b9 004a
 0x0f0: 0200 9900 232a b600 41c0 0043 1263 b900
 0x100: 4e02 003a 0919 09b8 0054 c000 562a 5fb5
 0x110: 0023 1909 572a b600 41c0 0043 1264 b900
 0x120: 4a02 0099 001d 2ab6 0041 c000 4312 64b9
 0x130: 004e 0200 3a0a 190a 2a5f b500 6619 0a57
 0x140: b1
   Stackmap Table:

full_frame(@50,{Object[#2],Object[#70],Object[#86],Object[#86],Object[#108]},{})
 same_locals_1_stack_item_frame(@51,Integer)

full_frame(@77,{Object[#2],Object[#4],Object[#86],Object[#86],Object[#108]},{})
 same_frame(@133)
 same_frame(@179)
 same_frame(@228)
 same_frame(@277)
 same_frame(@320)


 at

GroovyMapConstructorCheck.go(MapConstructorCheck_inner_class_error.groovy:24)

 at GroovyMapConstructorCheck$go.call(Unknown Source)

 at

MapConstructorCheck_inner_class_error.run(MapConstructorCheck_inner_class_error.groovy:33)
*/





Re: @CompileStatic void method returns null ?

2018-09-03 Thread MG
But the call to Foo#baz() coud return an e.g. GroovyVoidObject instance, 
which in turn throws a "cannot return void from method" if that happens 
to be the last expression in your example, no ?
It feels like returning null here is just a stopgap, not anything one 
actually wants to have in the language...


I don't expect the dynamic compiler to be changed, but should we really 
mirror the dynamic comiler behavior in the static compiler in this case 
? I think it would be much more least surprise in the @CompileStatic case...


Cheers,
mg

PS: Calling void methods better be fine, otherwise why do they exist in 
the first place ;-)  - I am/was always referring to my initial question, 
so the whole thread is about expecting/using void method call results 
somewhere...



On 04.09.2018 01:41, Paul King wrote:

Calling void methods is fine. Expecting a result is the point in question.

For dynamic Groovy, you can't always tell which case you have:

class Foo {
  def bar() { 42 }
  void baz() { }
}

def method(boolean condition, delegate, meth1, meth2) {
  if (condition) delegate."$meth1"()
  else delegate."$meth2"()
}

println method(true, new Foo(), 'bar', 'baz') // 42
println method(false, new Foo(), 'bar', 'baz') // null

Here, "method" is expecting to return some value that happens to be 
the last expression, i.e. the result of the if/then/else expression, 
so we return null in such cases.


Cheers, Paul.


On Tue, Sep 4, 2018 at 7:38 AM MG <mailto:mg...@arscreat.com>> wrote:


What I meant was: What sense does letting void methods be called make
for the dynamic case, i.e. the dynamic compiler ? From a programmer's
perspective, i.e. what is a programming use case for that
feature/behavior, in dynamic Groovy ?

Of course I can do the following in dynamic Groovy:

// Groovy 2.5.0
class Goo {
 //void nogoo() { return 123 } // Dynamic Groovy compiler:
RuntimeParserException: Cannot use return statement with an
expression on a method that returns void
 void nogoo() { 123 }
}

final goo = new Goo()

println "original: goo.nogoo()=${goo.nogoo()}"

goo.metaClass.nogoo = { return 456 }

println "mopped: goo.nogoo()=${goo.nogoo()}"


Which will build, run, and output

original: goo.nogoo()=null
mopped: goo.nogoo()=456

  i.e. returning 456 from a void method in the second case.
But if I am using a library that includes the Goo class, why would I
ever expect a return value from the nogoo method (and therefore call
it), considering its return type is void ? And if I control the Goo
class myself, why would I not just change its return type to int
or def ?

Cheers,
mg


On 03.09.2018 22:36, Jochen Theodorou wrote:
> On 03.09.2018 17:13, mg wrote:
>> But in what scenario does the dynamic behavior make sense ?
>
> for a static compiler? none other than being compatible
>
> bye Jochen
>





Re: @CompileStatic void method returns null ?

2018-09-03 Thread MG
What I meant was: What sense does letting void methods be called make 
for the dynamic case, i.e. the dynamic compiler ? From a programmer's 
perspective, i.e. what is a programming use case for that 
feature/behavior, in dynamic Groovy ?


Of course I can do the following in dynamic Groovy:

// Groovy 2.5.0
class Goo {
    //void nogoo() { return 123 } // Dynamic Groovy compiler: 
RuntimeParserException: Cannot use return statement with an expression on a 
method that returns void
    void nogoo() { 123 }
}

final goo = new Goo()

println "original: goo.nogoo()=${goo.nogoo()}"

goo.metaClass.nogoo = { return 456 }

println "mopped: goo.nogoo()=${goo.nogoo()}"


Which will build, run, and output

original: goo.nogoo()=null
mopped: goo.nogoo()=456

 i.e. returning 456 from a void method in the second case.
But if I am using a library that includes the Goo class, why would I 
ever expect a return value from the nogoo method (and therefore call 
it), considering its return type is void ? And if I control the Goo 
class myself, why would I not just change its return type to int or def ?


Cheers,
mg


On 03.09.2018 22:36, Jochen Theodorou wrote:

On 03.09.2018 17:13, mg wrote:

But in what scenario does the dynamic behavior make sense ?


for a static compiler? none other than being compatible

bye Jochen





@MapConstructor + @CompileStatic on Static Inner Class => CTE

2018-09-03 Thread MG
The following code using @MapConstructor on a static inner class raises 
a compile time error (see end of mail; different error when making the 
inner class non-static):


import groovy.transform.CompileStatic
import groovy.transform.MapConstructor

@CompileStatic
class GroovyMapConstructorCheck {

    @MapConstructor(noArg = true)
    static class Goo {
    final String s0 = "text0"
    final int x0
    final String s1
    final String s2 = "TEXT2"
    final o0

    @Override
    public String toString() {
    return "Goo(|$s0|,|$x0|,|$s1|,|$s2|,|$o0|)"
    }
    }

    void go() {
    println new Goo()
    println new Goo(s0:"abc")
    println new Goo(x0:123, s0:"abc")
    println new Goo(s1:"S1", s2:"S2", x0:-999, o0:new Object(), 
s0:"S0")
    final goo = new Goo(s1:"S1", s2:"S2", x0:-999, o0:new Object(), 
s0:"S0")

    }
}

final check = new GroovyMapConstructorCheck()
check.go()

/*
Compile time error:

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    GroovyMapConstructorCheck$Goo.(Ljava/util/Map;)V @85: 
invokevirtual

  Reason:
    Type 'GroovyMapConstructorCheck$Goo' (current frame, stack[0]) is 
not assignable to 'groovy/lang/Closure'

  Current Frame:
    bci: @85
    flags: { }
    locals: { 'GroovyMapConstructorCheck$Goo', 'java/lang/Object', 
'java/lang/String', 'java/lang/String', 'groovy/lang/MetaClass' }

    stack: { 'GroovyMapConstructorCheck$Goo' }
  Bytecode:
    0x000: 2ab7 001b 121d 4d2c 2a5f b500 1f2c 5712
    0x010: 214e 2d2a 5fb5 0023 2d57 2ab6 0027 3a04
    0x020: 1904 2a5f b500 2919 0457 2bc7 0007 04a7
    0x030: 0004 0399 001a 03bd 0004 b800 2f3a 0519
    0x040: 0512 31b8 0035 c000 314c 1905 572a 2bb8
    0x050: 003b 0157 2ab6 0041 c000 4312 44b9 004a
    0x060: 0200 9900 232a b600 41c0 0043 1244 b900
    0x070: 4e02 003a 0619 06b8 0054 c000 562a 5fb5
    0x080: 001f 1906 572a b600 41c0 0043 1257 b900
    0x090: 4a02 0099 0020 2ab6 0041 c000 4312 57b9
    0x0a0: 004e 0200 3a07 1907 b800 5d2a 5fb5 005f
    0x0b0: 1907 572a b600 41c0 0043 1260 b900 4a02
    0x0c0: 0099 0023 2ab6 0041 c000 4312 60b9 004e
    0x0d0: 0200 3a08 1908 b800 54c0 0056 2a5f b500
    0x0e0: 6219 0857 2ab6 0041 c000 4312 63b9 004a
    0x0f0: 0200 9900 232a b600 41c0 0043 1263 b900
    0x100: 4e02 003a 0919 09b8 0054 c000 562a 5fb5
    0x110: 0023 1909 572a b600 41c0 0043 1264 b900
    0x120: 4a02 0099 001d 2ab6 0041 c000 4312 64b9
    0x130: 004e 0200 3a0a 190a 2a5f b500 6619 0a57
    0x140: b1
  Stackmap Table:
full_frame(@50,{Object[#2],Object[#70],Object[#86],Object[#86],Object[#108]},{})
    same_locals_1_stack_item_frame(@51,Integer)
full_frame(@77,{Object[#2],Object[#4],Object[#86],Object[#86],Object[#108]},{})
    same_frame(@133)
    same_frame(@179)
    same_frame(@228)
    same_frame(@277)
    same_frame(@320)


    at 
GroovyMapConstructorCheck.go(MapConstructorCheck_inner_class_error.groovy:24)


    at GroovyMapConstructorCheck$go.call(Unknown Source)

    at 
MapConstructorCheck_inner_class_error.run(MapConstructorCheck_inner_class_error.groovy:33)

*/


Re: @CompileStatic void method returns null ?

2018-09-03 Thread mg
But in what scenario does the dynamic behavior make sense ? You tell the 
compiler that a method does not have a return value - then you call that method 
using its return value, knowing it will always be null... ?-)
So the following:

final result = voidMethod() // looks like result might contain something 
interesting after the call... ?-)
is 100% equivalent to:
voidMethod()final result = null // ...r - not :-/

I feel at least in the @CompileStatic case using a void return value should 
fail at compile time - what do you think ?


 Ursprüngliche Nachricht Von: Paul King  
Datum: 29.08.18  10:35  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: 
@CompileStatic void method returns null ? 
See also: https://issues.apache.org/jira/browse/GROOVY-8770
Which I presume was also to mimick dynamic behavior.
Cheers, Paul.

On Wed, Aug 29, 2018 at 4:42 AM Jochen Theodorou  wrote:
On 28.08.2018 19:45, mg wrote:

> Since I just stumbled across this behavior while helping a junior 

> developer debug his code: Why does statically compiled Groovy (2.5.2) 

> return null from void methods, instead of raising a compile error ?



i was actually not aware we kept this logic for static compilation, but 

essentially it is like that because of dynamic Groovy, which derives 

this from the reflective and methodhandles based method invocation



bye Jochen




@CompileStatic void method returns null ?

2018-08-28 Thread mg
Since I just stumbled across this behavior while helping a junior developer 
debug his code: Why does statically compiled Groovy (2.5.2) return null from 
void methods, instead of raising a compile error ? 

E.g. 

import groovy.transform.CompileStatic

@CompileStatic
class Goo {
void calcId(String a, String b) { // Programming error: Return type should be 
String
 "${a}.${b}"
}

String getId() {
 calcId("abera","kadavera")
}

String getId2() {
 String id = calcId("abera","kadavera")
 return id
}
}

final Goo goo = new Goo()
println "goo.calcId(...)=${goo.calcId("x","y")}"
println "goo.id=${goo.id}"
println "goo.id2=${goo.id2}" 


outputs 


goo.calcId(...)=null 
goo.id=null 
goo.id2=null
Cheers,mg



Re: multi-declaration does not work in the for loop, groovy 2.4

2018-08-06 Thread mg
2.5.x does not use the new Parrot parser afaik, the upcoming 3.x and its now 
dormant 2.6.x JDK 7 backport do.
(apart from that: Agree, never used that syntax in any language, never missed 
it in Groovy due to functional constructs)
 Ursprüngliche Nachricht Von: "Nelson, Erick" 
 Datum: 06.08.18  15:10  (GMT+00:00) An: 
users@groovy.apache.org Betreff: Re: multi-declaration does not work in the for 
loop, groovy 2.4 


Same in 2.5.1 from eclipse photon…
 
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/Users/en032339/Documents/workspace3/script6/src/erick/erick.groovy: 6: 
unexpected token: = @ line 6, column 14.
   for (int foo = 0, bar = 0; foo

Reply-To: "users@groovy.apache.org" 

Date: Monday, August 6, 2018 at 6:37 AM

To: "users@groovy.apache.org" 

Subject: multi-declaration does not work in the for loop, groovy 2.4


 

Hi there, 

 


I have just bumped into a — presumably — parser error, which causes that a 
declaration of more variables is not accepted in a for loop:


 


===


44
/tmp> /usr/local/groovy-2.4.15/bin/groovy q


org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:


/private/tmp/q.groovy: 1: unexpected token: = @ line 1, column 13.


   for (int foo=0,bar=0;foo /usr/local/groovy-2.4.15/bin/groovy -version


Groovy Version: 2.4.15 JVM: 10.0.1 Vendor: "Oracle Corporation" OS: Mac OS X


45
/tmp> 


===


 


At the moment alas I can't test in newer groovys, not sure whether the problem 
is fixed there or not.


 


All the best,


OC


 




Re: Groovy and JDK 11: Compilation issue

2018-07-30 Thread mg
FYI: Groovy 2.4.15 under the current OpenJDK 11 prerelease, with IntelliJ as 
the build system ran (after the JDK deprecation fixes we needed, described in 
previous email) without any problems with our 900+ (database/integration) tests 
(WIN7), as well as Vaadin 7 (RHEL).
 Ursprüngliche Nachricht Von: Misagh Moayyed 
 Datum: 30.07.18  18:32  (GMT+00:00) An: 
users@groovy.apache.org Betreff: Groovy and JDK 11: Compilation issue 
Has anyone here tried to use Apache Groovy 2.5.1 or 3.x and JDK 11 together? I 
am trying to troubleshoot a build failure (Using Gradle 4.8, or 4.9) that 
manifests itself as:
...
General error during class generation: java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
 at 
groovyjarjarasm.asm.ClassVisitor.visitNestMemberExperimental(ClassVisitor.java:248)
 at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:651)
 at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:391)
Here is the full output of the 
failure:https://travis-ci.org/apereo/cas/builds/409569422
It appears to me that perhaps JDK 11 support for Groovy still has a few rough 
edges and may not be "officially" there. Could someone confirm this please?
Thanks. 
--Misagh

Groovy with OpenJDK 10 and IntelliJ Build - Solved

2018-07-30 Thread mg
Hi,
we recently had a little bit of time to revisit the OpenJDK 10 build problem: 
As it turns out, it has nothing to do with Groovy, module support, or OpenJDK - 
instead the missing JARs have simply been removed from JDK 10 (they had only 
been deprecated in JDK 9 - quick removal after deprecation in the Java world 
will need some getting used to ;-) ).
All one needs to do to remedy the situation is add external dependencies 
replacing the removed JDK functionality to ones project, in our case:
OJDK 10: glassfish-corba-omgapi-3.2.0-b005.jar (for Notes 9) 

OJDK 11: jaxb-api-2.3.0.jar (for Vaadin 7) 

(All these removals come from the same JEP:

JDK Extension Proposal (no longer a proposal, alreday happening in JDK 9/10/11 
- e.g. JAXB is gone in 11) betreffend das java.corba Problem, das wir gerade 
gelöst haben: 

http://openjdk.java.net/jeps/320 )
Chhers,mg

On Wed, Jul 4, 2018 at 9:28 AM MG 
  wrote:


Hi,

  

  does anyone allready have experience compiling a Groovy
  project under 

  IntelliJ and OpenJDK 10 ?

  We are currently using OpenJDK 8 and would need to evaluate
  (if 

  possible) if our Groovy framework has any problems building
  & running 

  under OpenJDK 10. We are using IntelliJ modules as our build
  system, and 

  with OpenJDK 10 the Groovy build throws an internal compiler
  error that 

  NotesException requires a base class from the java.corba
  module, which 

  can no longer be found. Is there a (quick) way to make Groovy
  code 

  module compatible under IntelliJ 2018.1.5 ?

  

  Cheers,

      mg

Re: XML RPC Service

2018-07-25 Thread MG
This Java lib also looks interesting, since it seems quite compact and 
explicitely mentions support for asynchronous calls (if you need that), 
which looks like it would lend itself nicely to be wrapped in some 
Groovy goodness (see below):

https://github.com/gturri/aXMLRPC

What we have found is, that oftentimes the best approach - if something 
is not covered by the core Groovy libraries already - is to pick the 
best/supported/maintained Java library, and develop your own Groovy 
wrapper as you go along. This is what we did with Vaadin (works like a 
charm), and are now planning to do for Apache LDAP. I usually use a 
static Groovy class for low level function-type support, and add 
configurable instance helper classes as needed. It does not take much 
effort to write these on the go, and you can use the newest Groovy 
features (many older Groovy based libraries are quite dynamic in nature 
I have found; if you are coming from Perl you might not mind, but coming 
from a C/C++/Java background myself I prefer as much static type safety 
as I can get - and modern Groovy (combined with a good IDE with Groovy 
support (I use IntelliJ myself, but the Eclipse Groovy supprt recently 
got a major update afaik) delivers on that, with @CompileStatic, 
@Delegate/traits, final fields support in ctors, etc)).


Cheers,
mg


On 19.07.2018 17:25, Bernhard Donaubauer wrote:

Hello,

I think about replacing an old xml-rpc service written in perl with groovy.

There are examples using groovy-xmlrpc like here:
https://gist.github.com/bjfish/370521

But I wonder if this module is still maintained. While I can find the
jar files in the repositories I can't find the according project or sources.

Regards,
Bernhard Donaubauer





Re: XML RPC Service

2018-07-25 Thread MG
I have no personal experience with either XML-RPC, SOAP or REST (DB 
Developer, Web-GUI needs covered by Vaadin), but this guy expresses a 
different (seemingly pragmatic) opinion (and he is using Groovy ;-) ):

https://sites.google.com/a/athaydes.com/renato-athaydes/posts/thereturnofrpc-orhowrestisnolongertheonlyrespectablesolutionforapis

(Generally speaking, in modern software development especially the web 
development domain to me seems to suffer from an overabundance of "this 
is the /absolute /right way to do things !" - until a newer/hipper/... 
(or simply different ?-) ) approach comes along the next year...; I mean 
I am not saying there is no improvement in some areas, but it took the 
web guys how many decades to rediscover configurable, encapsulated GUI 
components as a general concept ?-) )


Cheers,
mg


On 24.07.2018 12:33, Russel Winder wrote:

I suspect XML-RPC is pure legacy. It evolved into SOAP and that is pure
legacy.

All the Web Services folk I know are now using RESTful HTTP/HTTPS
microservices.

On Sat, 2018-07-21 at 16:50 +0200, Jacques Le Roux wrote:

Hi Bernhard,

Actually XML-RPC is no longer maintained, last fix in3.1.3 is for

http://www.openwall.com/lists/oss-security/2011/10/05/10

And there are CVEs pending :

https://0ang3el.blogspot.com/2016/07/beware-of-ws-xmlrpc-library-in-y
our.html

Other TLPs might be affected, I guess Archiva has been picked because
being the 1st in alphabetical order...

HTH

Jacques


Le 19/07/2018 à 17:25, Bernhard Donaubauer a écrit :

Hello,

I think about replacing an old xml-rpc service written in perl with
groovy.

There are examples using groovy-xmlrpc like here:
https://gist.github.com/bjfish/370521

But I wonder if this module is still maintained. While I can find
the
jar files in the repositories I can't find the according project or
sources.

Regards,
Bernhard Donaubauer







Re: About the groovy code style

2018-07-04 Thread MG

Two questions:

1. Jochen says "Danil  is doing special things with DSL", but "Daniil
   Ovchinnikov" replied regarding IntelliJ Groovy parsing. So is Danil
   == Daniil ?
2. I neither like nor use these syntax varieties - but wouldn't
   changing any of that behavior potentially break Groovy DSLs from
   here to Baghdad (not only "Danil"'s) ?-)

Cheers,
mg


On 04.07.2018 20:40, Paul King wrote:


Comment inline.

On Tue, Jul 3, 2018 at 10:31 PM Jochen Theodorou <mailto:blackd...@gmx.org>> wrote:




Am 03.07.2018 um 04:44 schrieb Daniel.Sun:
> Hi all,
>
>       The following code is supported in the older parser, but I
propose to
> stop supporting the ugly code style in the new Parrot parser.
Any thoughts?
>
> 1) import statement (
https://issues.apache.org/jira/browse/GROOVY-8642 )
> ```
> import java.
> lang.
> Object
> ```
>
> 2) prefix operator (
https://issues.apache.org/jira/browse/GROOVY-8650 )
> ```
> def c = --
> 1

I do not need these.. but since I know Danil is doing special things
with DSL, maybe we should first ask him if he needs that and why


Jochen, even though you say you "do not need these", the real question 
is what set of rules are you replacing the existing conceptual rule with?


Existing rule: if the set of tokens parsed when an end of line is 
reached doesn't make a complete expression/statement, continue reading 
tokens as if the EOL wasn't there.


There are exceptions, e.g. we currently don't allow single quote and 
single double quoted strings to span multiple lines but the list is short.


What are your new rules and new list of exceptions?

We shouldn't be tied down by our existing set of rules but we want to 
keep them simple for our users so they all don't need to be grammar 
experts to use the language.


Cheers, Paul.

bye Jochen





  1   2   3   >