Guillaume Laforge | 19 Dec 16:12 2014
Picon

[groovy-user] [ANN] Groovy 2.3.9

Hi all,


As an early Christmas present, the Groovy team is happy to release a Groovy 2.3.9 update.


It’s also the opportunity for us to wish you all pretty Groovy holidays!


Groovy 2.3.9 is essentially a bug fix release in our official stable branch.


We’re also planning on releasing a first release candidate of Groovy 2.4 very soon, with a goal to release the final version in January, once we’re happy with the stability and feedback from the community.


You can read the Groovy 2.3.9 release notes to learn more about the tickets closed, and head over to the download section of the beta Grooy website to get the latest and greatest bits on your computer!


Thanks a lot for all your contributions and support!


Keep on groovy-ing, and groovy holidays.


--
Guillaume Laforge
Groovy Project Manager
Pivotal, Inc.

Schalk Cronjé | 18 Dec 22:21 2014
Picon

[groovy-user] [ANN] Groovy VFS 1.0 Beta 2

I am glad to make the second 1.0 pre-release of Groovy VFS available.

Beta 2, in addition to Beta 1 includes:

- Use of 'uri' keyword to disambiguate URIs on certain circumstances

- resolveURI is now public method, making it available to the DSL and for people who need an easy way of getting hold of the underlying Apache VFS FileObject instance.

- Ability to send arbitrary text to a remote file (from feedback at Grovvy-Grails Exchange 2014).

vfs {
overwrite 'sftp://user:pass <at> server/file' with 'this text'

append 'sftp://user:pass <at> server/file' with 'this text'

overwrite 'sftp://user:pass <at> server/file' with 'this text', {
// Closure takes an OutputStream
it << 'text'
}
}
- cmdline vfs: mkdir now supports GNU options -p, --parents

- cmdline vfs: mv now supports non-GNU option --parents

- Codebase: https://github.com/ysb33r/groovy-vfs/tree/RELEASE_1_0_BETA_2

- Those who would like to try out the command-line version, get it at https://bintray.com/ysb33r/nanook/vfs/1.0-beta2/view/files.

Beta 1 already included:

- Ability to load additional providers via an 'extend' keyword in the DSL

extend { provider className: 'org.ysb33r.groovy.vfsplugin.cloud.s3.S3FileProvider', schemes: ['s3'] }

- SMB provider based upon jCIFS. (Thanks to Maarten Boekhold for trying out the initial codebase some time ago)

- S3 provider based on jClouds. This will give the ability to provide VFS support to other cloud offerings too.

- Command-line utility mimicking GNU 'cp'. 'mv', 'mkdir', 'ls' and 'cat' commands.

- Gradle plugin built against v2.0 utilising Groovy 2.3.x and as such now using <at> CompileStatic etc.

- Ability to turn off intermediates creation when creating a directory
 
I expect for some bugs to appear especially in SMB & S3 support, so please feel free to log them at

    https://github.com/ysb33r/groovy-vfs/issues

-- Schalk W. Cronjé Twitter / Ello / Toeter : <at> ysb33r
akumar1512 | 18 Dec 21:02 2014
Picon

[groovy-user] Newbie trying to understand Closures

Newbie to Groovy, learning the basics of Groovy as a part of Online
Functional Programming course, that was completed about a month ago (so no
one is there to answer my question).

The course assignment made me define two closures.

head = { it[0] }

length = { it.size() }

and then proceeded to pass one into the other and produce result. 

head([length])("hello")
This gave a result ===> 5

I don't understand how this worked. Is there a way to see the Stack Trace to
understand how this was executed ?

Also why did the reverse not work, i.e 
length([head])("hello")

--
View this message in context: http://groovy.329449.n5.nabble.com/Newbie-trying-to-understand-Closures-tp5721976.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

KARR, DAVID | 18 Dec 16:39 2014
Picon

[groovy-user] List of "high-profile" applications or frameworks that embed a Groovy DSL?

As part of a small presentation I'll be giving in a couple of months, I'd like to build a short list of
"high-profile" applications or frameworks that embed a Groovy DSL (or two).  I'd like to limit this list to
items that would be known to people who use Java, but don't use Groovy yet.  For instance, I think Gradle
passes that requirement, but I don't think Griffon does.  I also don't count Maven in this list because it
just provides the ability to execute Groovy code, it's not really an enhanced DSL.

Can anyone think of any examples?

The ones I'm aware of are:
* Gradle
* Jenkins
* Artifactory

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Simon | 18 Dec 01:30 2014
Picon

[groovy-user] Strange problem with CliBuilder

Hello all,

I have an odd issue where the parsing of numeric arguments to options lose their "-" prefix when the argument is negative in some cases. 

Here's an example script:

  c = new CliBuilder(); 
  c.with { cr "hello", args:1 }; 
  opts = c.parse(args); 
  println opts.cr;

I run this with the latest stable release (2.3.x) or the latest beta (2.4.0-beta-4), I get the following results with different arguments:

  groovy test.groovy -cr 1
  1 
  ^^^ good

  groovy test.groovy -cr -1
  -1 
  ^^^ good

  groovy test.groovy -cr -1.5
  1.5 
  ^^^ Wut???!!!

Is there any explanation for why the option loses the "-" ONLY if I pass a non-integer value? It seems to me it must be a bug, but I thought I should check if there is some reason this happens before I try to file one.

Cheers,

Simon

东坡 | 17 Dec 07:08 2014

[groovy-user] What's the diffrence between the two style

hello,everyone
below is  about  collectEntries(),my question is what's the diffrence about a list style and map style.
* def letters = "abc"
* // collect letters with index using list style
* assert (0..2).collectEntries { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c']
* // collect letters with index using map style
* assert (0..2).collectEntries { index -> [(index): letters[index]] } == [0:'a', 1:'b', 2:'c']
this is my code
thanks.
public static void main(String[] args) {
def list = [1, 2, 3]
def map = list.collectEntries {
it == 1 ? [:] : [it, it * 2]
}
println(map)
}

------------------
相信开源的力量可以改变世界
Maarten Boekhold | 17 Dec 06:35 2014
Picon

[groovy-user] Compilation of multi-line statements

Hi,
 
The following 2 code fragments do not compile (tested in GroovyConsole):
 
def sb = new StringBuffer()
sb << "hello"
   << " world"
 
fails with:
 
Exception thrown
groovy.lang.MissingMethodException: No signature of method: java.lang.String.positive() is applicable for argument types: () values: []
Possible solutions: notify(), size(), tokenize(), tokenize(), size()
    at ConsoleScript5.run(ConsoleScript5:2)
1 compilation error:
unexpected token: << at line: 3, column: 4
 
and:
 
def s = "hello"
      + "world"
 
fails with:
 
Exception thrown
groovy.lang.MissingMethodException: No signature of method: java.lang.String.positive() is applicable for argument types: () values: []
Possible solutions: notify(), size(), tokenize(), tokenize(), size()
    at ConsoleScript9.run(ConsoleScript9:2)
 
I understand that the compiler considers the second line as a separate statement, which is a little bit surprising. The equivalent in Java does work. Ending the complete statement with a semi-colon doesn't help.
 
I understand that the Groovy compiler considers the second line as a separate statement, but it's a little bit surprising. Any particular explanation for this?
 
Maarten

--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Guillaume Laforge | 16 Dec 23:22 2014
Picon

[groovy-user] [ANN] Groovy Weekly #49

Hi all,

It's been a super busy week with all the great content coming straight from Groovy Grails eXchange and already available online!

Don't miss Cédric's article on 10 things static languages can't do (but Groovy can), or the story of how Rakuten's scaling with Groovy at large!


Keep on groovy-ing!

--
Guillaume Laforge
Groovy Project Manager
Pivotal, Inc.

Winnebeck, Jason | 16 Dec 17:23 2014

[groovy-user] DSL Question

I have a question about Groovy DSLs that I've never quite resolved. I don't know how to handle "variable"
grammar components at odd positions (only at even positions).

I know how to do this:

add person named "Jason" //add(person).named("Jason")

using the code:

class PersonToken {}
person = new PersonToken()
def add(PersonToken ignored) {
  [named: { name -> println "$name added" }]
}

But I don't know how to make this work the same way:

add person "Jason" //add(person)."Jason"

The problem is the "Jason" parameter is not an argument to a method but instead is used as a property lookup.
How can I get something in the 3rd (or any odd numbered) position to work "like a method" such that I can put
any object there, run arbitrary code and it could also return a value? Bonus points if there is ability for
type information for IDEs like IntelliJ IDEA to use for auto-complete (like what was done with PersonToken).

Jason Winnebeck

----------------------------------------------------------------------
This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply email and destroy all copies of the original message and any attachments.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Matthias F. Brandstetter | 12 Dec 01:27 2014
Picon

[groovy-user] Type uninitializedThis is not assignable to 'java/lang/Object'

Hello all,

I have a Groovy project (using Intellij), built with Gradle. Within that project there is a module which I have copied into a new module.

Each of these modules have a main script (new module: "glow.groovy"), which loads the module-specific main class (new module: "GlowGame"). All that logic incl. Gradle building works fine with the original module.

However, when I want to build and run the newly copied module, I get the following exception from Gradle. Unfortunately I have never seen such an error, and I have no idea how to read it.

Any ideas?

Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    glow/GlowGame.<init>()V <at> 16: invokeinterface
  Reason:
    Type uninitializedThis (current frame, stack[4]) is not assignable to 'java/lang/Object'
  Current Frame:
    bci: <at> 16
    flags: { flagThisUninit }
    locals: { uninitializedThis, '[Lorg/codehaus/groovy/runtime/callsite/CallSite;' }
    stack: { uninitializedThis, 'java/lang/String', 'org/codehaus/groovy/runtime/callsite/CallSite', 'org/codehaus/groovy/runtime/callsite/CallSite', uninitializedThis }
  Bytecode:
    0x0000000: b800 124c 2a12 142b 1215 322b 1216 322a
    0x0000010: b900 1c02 00b9 001f 0200 b800 25c0 0027
    0x0000020: 1229 122b b700 2e04 3d1c b800 3401 1236
    0x0000030: 1238 b800 3e1c 57b1                   

    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
    at java.lang.Class.getDeclaredConstructors(Class.java:2012)
    at org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:69)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:66)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:64)
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
    at org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:258)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:213)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:223)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:168)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:158)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:141)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:209)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:241)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:255)
    at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:859)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:84)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
    at glow.run(glow.groovy:7)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:901)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:884)
    at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:406)
    at org.codehaus.groovy.runtime.InvokerHelper$runScript.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at glow.main(glow.groovy)
Schalk Cronjé | 11 Dec 23:25 2014
Picon

[groovy-user] A DSL question for Groovy VFS

After the Groovy VFS presentation at GGX today a conversation with some of the InteeliGrape folks came up with an interesting feature. In *nix shell one can do something like

  echo 'some text' >> afile.txt

How to achieve something similar in Groovy VFS. It is pretty trivial to implement something like
(assuming the reader is familiar with the DSL, otherwise see https://github.com/ysb33r/groovy-vfs)

vfs {
  echo 'write some text', 'sftp://some.server/file', append: fakse
  echo 'append some text', 'sftp://some.server/file', append: true
}
But what if one wants to do something like

vfs {
  echo 'write some text' > 'sftp://some.server/file'
  echo 'append some text' >> 'sftp://some.server/file'
}
(bearing in mind here that the second string has not yet been converted to a VFS URI object at this point).

This will fail immediately due to operator precedence. 'write some text'  will be compared to 'sftp://some.server/file', instead of echo('write some text') being evaluated.

Is there any way one could manipulate this with an AST transform, so that the second set of code, effectively does the same as the first?
-- Schalk W. Cronjé Twitter / Ello / Toeter : <at> ysb33r

Gmane