Questions tagged [groovysh]

The Groovy Shell, aka. groovysh is a command-line application which allows easy access to evaluate Groovy expressions, define classes and run simple experiments.

The Groovy Shell, aka. groovysh is a command-line application which allows easy access to evaluate Groovy expressions, define classes and run simple experiments.

http://groovy.codehaus.org/Groovy+Shell

16 questions
17
votes
2 answers

How do you declare and use a Set data structure in groovysh?

I've tried: groovy:000> Set s = ["a", "b", "c", "c"] ===> [a, b, c] groovy:000> s Unknown property: s I want to be able to use this as a set, but even if I pass it explicitly, it turns it into an ArrayList: groovy:000> joinList(["a", "b",…
reectrix
  • 7,999
  • 20
  • 53
  • 81
3
votes
0 answers

groovysh: how to solve "no jansi in java.library.path" in Mac M1?

I am running groovysh (groovy 4.0.8 which is installed by sdkman) on my Mac M1, and it raises a warning: ansi will be disabled because an error occurred while installing ansi: Could not load library. Reasons: [no jansi in java.library.path: ....…
chenzhongpu
  • 6,193
  • 8
  • 41
  • 79
2
votes
1 answer

How do you import Shared Libraries in groovysh?

Jenkins lets you import a shared library using: library But how would you do this using groovysh?
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
2
votes
1 answer

Strange behavior using def in groovy's repl (groovysh)

Problem Summary This morning I was using groovysh to test a closure but in the process of doing so I experience unexpected behavior I defined a class in groovysh then instantiated an object from that class as follows groovy:000> class Student…
2
votes
1 answer

how to make groovysh work with apache spark

I am using Apache Spark with Groovy successfully, however I have no luck using groovysh as an interactive spark shell. Groovy Shell (2.5.0-beta-3, JVM: 1.8.0_161) Type ':help' or ':h' for…
robokaso
  • 81
  • 1
  • 7
1
vote
1 answer

Debugging groovy code in groovysh step by step

I'm new to Java and Groovy, and this is a really simple question on debugging groovy code in groovysh step by step. $ groovysh groovy:000> String str = "abcd" ===> abcd groovy:000> println str Unknown property: str In interactives debug shell for…
xpt
  • 20,363
  • 37
  • 127
  • 216
1
vote
1 answer

groovysh: how to deal with a typo

This seems like a really silly question, but when I use groovysh, if I have a typo, it seems to kill the entire shell. For example, if I want to iterate through an array, I can do this arr.each { elt ->. But if I accidentally type arr.each { elt…
ewok
  • 20,148
  • 51
  • 149
  • 254
1
vote
2 answers

Why am I getting an "unable to resolve class" error with groovysh and Grape?

I am using Groovysh and I need to load some classes with Grape. Right now I am trying this: > @Grab(group='group.example', module='module.example', version='1.2.3') > import group.example.TheClass > theClass = new TheClass() However, after I enter…
1
vote
1 answer

grovysh imports when working with HBase fail

What *.jar I need to make my groovysh work with hbase 1.1.2 i am trying to run a simple script and the following imports fail - groovy:000> import org.apache.hadoop.hbase.client.Put ERROR java.lang.NoClassDefFoundError: …
andrew shved
  • 137
  • 1
  • 8
1
vote
1 answer

How to change the default location of groovysh.profile?

I need to run a couple of application on the same host as the same user with different set of custom commands registered in the groovysh.profile. Is it possible to tell groovysh to not load the $HOME/.groovy/groovysh.profile and instead load what is…
Mir
  • 11
  • 1
1
vote
1 answer

Need help implementing new commands in groovysh

I've found very little info on building new commands for Groovysh. I'd like to use it as a normal part of my dev environment, to some degree replacing cmd.exe(). I did notice that there is a "register" command in groovysh that allows you to…
Bill K
  • 62,186
  • 18
  • 105
  • 157
0
votes
1 answer

Strange groovy closure construction

How this code works in groovysh: whatever: { x = 1+1 } I dont understand how Groovy execute this closure and how interpreted this:'\ :'. For calling closure used () or call() according documentation. Groovy doesnt have ':' operator. I…
0
votes
1 answer

groovysh > sdk - java - WARNING: An illegal reflective access operation has occurred

Running groovysh I get: groovysh WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/home/snowcrash/.sdkman/candidates/groovy/2.5.2/lib/groovy-2.5.2.jar)…
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
0
votes
1 answer

Can I add a group of classes as delegates to groovysh

When I run groovysh I'd like to add some classes so they execute as though they were delegates. It should work like this: assuming these classes exist: def A{ def test() {println "test"} } def B{ def test2() {println "test2"} } I'd…
Bill K
  • 62,186
  • 18
  • 105
  • 157
0
votes
1 answer

groovy: groovysh interpreterMode preference not working

I am trying to set interpreterMode in groovysh. I open up groovysh and execute set interpreterMode, but then when I try to use def x=1, x does not get set: groovy:000> set interpreterMode groovy:000> set Preferences: …
ewok
  • 20,148
  • 51
  • 149
  • 254
1
2