AW: Strange behaviour when using the Grab annotation

2024-01-08 Thread UIT
Hello Paul!

That explains all the - at least to me - strange behavior.

I also saw in the doc Bob pointed me to that there is a grape resolve command 
to check the transitive dependencies of a grape.

So no need to set up a dummy script for this and delete the ~/.groovy/grapes 
directory and re-fetch the jars. 

Thanks again to all involved here.

Regards

Clemens

-Ursprüngliche Nachricht-
Von: Paul King  
Gesendet: Montag, 8. Januar 2024 13:13
An: users@groovy.apache.org
Betreff: Re: Strange behaviour when using the Grab annotation

[Sie erhalten nicht häufig E-Mails von pa...@asert.com.au. Weitere 
Informationen, warum dies wichtig ist, finden Sie unter 
https://aka.ms/LearnAboutSenderIdentification ]

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

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

Cheers, Paul.

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

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


Re: Strange behaviour when using the Grab annotation

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

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

Cheers, Paul.

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

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


Re: Strange behaviour when using the Grab annotation

2024-01-07 Thread Clemens Quoss

Hello Bob!

Thanks for your answer. Yes, of course the right way would be to also 
use the 'grabbed' dependency in one way or the other.


This test script of mine was for investigating what dependency in a 
large script of mine pulls in groovy-all:2.4.x making this script 
unusable with Groovy 4.x due to classpath clashes.


Therefore i wrote this small test script putting in only one Grab at a 
time and deleting ~/.groovy/grapes between the runs to see what is 
transitively pulled from what @Grab.


And you do not have to write it like this:

@Grab(...)
import ...

@Grab(...)
import ...

Grab is not an annotation for a dedicated import statement. I think this 
part of the doc is misleading.


BTW, i forgot to mention that the script works if i leave out the 
"Hallo, Groovy!" part and only work with an empty println.


So i do still believe it is a bug of some sort.

Regards

Clemens

Am 07.01.2024 um 01:31 schrieb Bob Brown:


I think that @Grab needs to be ‘attached’ to something like an import.

The doco (https://groovy-lang.org/grape.html) says:

“””

Note that we are using an annotated import here, which is the 
recommended way.


“””

Take a look at:

https://dzone.com/articles/groovy-and-jsch-sftp

HTH

BOB

*From:*Quoß, Clemens (UIT) 
*Sent:* Sunday, January 7, 2024 7:04 AM
*To:* users@groovy.apache.org
*Subject:* Strange behaviour when using the Grab annotation

Hello everyone!

When I am running this script with 4.0.17 …

>>>
@GrabResolver(name = 'nexus', root = 'https://…')

@Grab(group = 'com.jcraft', module = 'jsch', version = '0.1.55')

println "Hallo, Groovy!"

<<<

… I am getting this:

>>>
org.codehaus.groovy.control.MultipleCompilationErrorsException: 
startup failed:


C:\Temp\test.groovy: 4: Unexpected input: '"Hallo, Groovy!"' @ line 4, 
column 9.


   println "Hallo, Groovy!"

   ^

1 error

<<<

When I remove the Grapes annotations everything works as expected.

Has anyone encountered similar issues? Is there a cure? Is this 
considered a bug? To me it looks that way. But maybe I am missing 
something here.


TIA

Regards

*Union IT-Services GmbH*

Clemens Quoß

FDI-INT

Senior Software Entwickler

Neue Mainzer Straße 12

60311 Frankfurt am Main

Tel. +49 69 2567 1241 

Fax +49 69 2567 61241

Mobil +49 151 55157195__

_clemens.qu...@union-investment.de 
<mailto:clemens.qu...@union-investment.de>_


Sitz der Gesellschaft: Weißfrauenstraße 7, 60311 Frankfurt am Main

Registergericht: Amtsgericht Frankfurt am Main HRB 33314

Geschäftsführer: Stephan Nasterlack, Siegfried Ehlert, Tobias Meier, 
Gregor Sauerzapf


RE: Strange behaviour when using the Grab annotation

2024-01-06 Thread Bob Brown
I think that @Grab needs to be 'attached' to something like an import.

The doco (https://groovy-lang.org/grape.html) says:

"""
Note that we are using an annotated import here, which is the recommended way.
"""

Take a look at:

https://dzone.com/articles/groovy-and-jsch-sftp

HTH

BOB

From: Quoß, Clemens (UIT) 
Sent: Sunday, January 7, 2024 7:04 AM
To: users@groovy.apache.org
Subject: Strange behaviour when using the Grab annotation

Hello everyone!

When I am running this script with 4.0.17 ...
>>>
@GrabResolver(name = 'nexus', root = 'https://...')
@Grab(group = 'com.jcraft', module = 'jsch', version = '0.1.55')

println "Hallo, Groovy!"
<<<

... I am getting this:
>>>
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
C:\Temp\test.groovy: 4: Unexpected input: '"Hallo, Groovy!"' @ line 4, column 9.
   println "Hallo, Groovy!"
   ^

1 error
<<<

When I remove the Grapes annotations everything works as expected.

Has anyone encountered similar issues? Is there a cure? Is this considered a 
bug? To me it looks that way. But maybe I am missing something here.

TIA

Regards

Union IT-Services GmbH
Clemens Quoß
FDI-INT
Senior Software Entwickler
Neue Mainzer Straße 12
60311 Frankfurt am Main

Tel. +49 69 2567 1241
Fax +49 69 2567 61241
Mobil +49 151 55157195
clemens.qu...@union-investment.de<mailto:clemens.qu...@union-investment.de>

Sitz der Gesellschaft: Weißfrauenstraße 7, 60311 Frankfurt am Main
Registergericht: Amtsgericht Frankfurt am Main HRB 33314
Geschäftsführer: Stephan Nasterlack, Siegfried Ehlert, Tobias Meier, Gregor 
Sauerzapf



Strange behaviour when using the Grab annotation

2024-01-06 Thread UIT
Hello everyone!

When I am running this script with 4.0.17 ...

>>>
@GrabResolver(name = 'nexus', root = 'https://...')
@Grab(group = 'com.jcraft', module = 'jsch', version = '0.1.55')

println "Hallo, Groovy!"
<<<

... I am getting this:

>>>
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
C:\Temp\test.groovy: 4: Unexpected input: '"Hallo, Groovy!"' @ line 4, column 9.
   println "Hallo, Groovy!"
   ^

1 error
<<<

When I remove the Grapes annotations everything works as expected.

Has anyone encountered similar issues? Is there a cure? Is this considered a 
bug? To me it looks that way. But maybe I am missing something here.

TIA

Regards

Union IT-Services GmbH
Clemens Quoß
FDI-INT
Senior Software Entwickler
Neue Mainzer Straße 12
60311 Frankfurt am Main

Tel. +49 69 2567 1241
Fax +49 69 2567 61241
Mobil +49 151 55157195
clemens.qu...@union-investment.de

Sitz der Gesellschaft: Weißfrauenstraße 7, 60311 Frankfurt am Main
Registergericht: Amtsgericht Frankfurt am Main HRB 33314
Geschäftsführer: Stephan Nasterlack, Siegfried Ehlert, Tobias Meier, Gregor 
Sauerzapf