Questions tagged [groovy]

Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl and Smalltalk. It can be used as a scripting language for the Java platform.

Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax. It integrates smoothly with any program, and immediately delivers to your application powerful features, including scripting capabilities, Domain-Specific Language authoring, runtime and compile-time meta-programming and functional programming.

Groovy is an object-oriented, agile and dynamic language for the Java Virtual Machine. It builds upon the strengths of but has additional power features inspired by languages like , and . It makes modern programming features available to developers with almost zero learning curve. It can be used as a scripting language for the Platform. From Wikipedia

Flat learning curve:

Concise, readable and expressive syntax, easy to learn for developers

Powerful features:

Closures, builders, runtime & compile-time meta-programming, functional programming, type inference, and static compilation

Smooth Java integration:

Seamlessly and transparently integrates and interoperates with and any third-party libraries

Domain-Specific Languages:

Flexible & malleable syntax, advanced integration & customization mechanisms, to integrate readable business rules in your applications

Vibrant and rich ecosystem:

Web development, reactive applications, concurrency / asynchronous / parallelism library, test frameworks, build tools, code analysis, GUI building

Scripting and testing glue:

Great for writing concise and maintainable tests, and for all your build and automation tasks

Hello World

println 'Hello World'

Tools

Online Resources

Groovy compared to other languages

On January 19, 2015 Pivotal announced end of their sponsorship to Groovy and Grails. Groovy was then submitted to become a project at the Apache Software Foundation. On November 18, 2015 the Groovy project graduated from Apache Project Incubation becoming an official Apache project.

29887 questions
8
votes
3 answers

No tests found for given includes on Spock unit tests for spring boot app

Setting up a new spring boot java project using groovy Spock unit tests in IntelliJ IDEA. I cannot get my first unit test to run. I created it from inside IntelliJ and it is under src/test/groovy. Here is the unit test. package…
Thom
  • 14,013
  • 25
  • 105
  • 185
8
votes
2 answers

Getting NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

I am getting the following error when I start my Spring Boot application. java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache at…
Thom
  • 14,013
  • 25
  • 105
  • 185
8
votes
4 answers

Grails / Groovy - Domain Object - Map of its Properties

How can I get a map of the key/values of only the user-defined properties on one of my domain objects? Problem is if I do this myself, I get my properties plus class, metaClass, constraints, closures, etc... I assume Grails can do this fairly easily…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
8
votes
2 answers

How to use Geb to check element attribute value after page event

After a bit of help here, I am writing a functional web test using Geb and want to test the disabled attribute value of an form submit button both before and after an event has occurred, the flow should be as follows: Load page, submit button is…
Edd Grant
  • 774
  • 2
  • 10
  • 22
8
votes
1 answer

Groovy 1.8 :: LINQ Applied

UPDATE 8/31/2011 Guillaume Laforge has nearly done it: http://gaelyk.appspot.com/tutorial/app-engine-shortcuts#query Looks like he's doing an AST transform to pull off the: alias as Entity bit. Cool stuff, Groovy 1.8 + AST transform = LINQ-esque…
virtualeyes
  • 11,147
  • 6
  • 56
  • 91
8
votes
2 answers

Logback Groovy Config to use JMX?

On Logback's documentation, they make putting JMX info into the XML file seem easy: http://logback.qos.ch/manual/jmxConfig.html But all their examples are using their XML configuration and I want to use Groovy. There is no mention of JMX…
MikeHoss
  • 1,477
  • 4
  • 18
  • 35
8
votes
5 answers

Groovy/Grails - Unable to Resolve Class

I am trying to build a Grails project in STS and am getting many error messages of the form: Groovy:unable to resolve class org.codehaus.groovy.grails.commons.ConfigurationHolder as well as others like Groovy:unable to resolve class…
skaz
  • 21,962
  • 20
  • 69
  • 98
8
votes
3 answers

What is meant by an "unbound" library or classpath container in Eclipse?

While recently imported a new project into eclipse, at one point when I tried to add the GROOVY_SUPPORT library it would up as "unbound" with error-X, like this: It also did not appear in the package explorer as I expected. What precisely does this…
Kaypro II
  • 3,210
  • 8
  • 30
  • 41
8
votes
3 answers

Gradle error: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

I need to see my dependencies in Gradle to fix a problem with multiple SLF4J bindings. However, when I run 'gradle dependencies' I get the error: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper In a similar question in…
Joshua Spinak
  • 133
  • 1
  • 1
  • 10
8
votes
2 answers

SpringBoot 2.2.1 groovyMarkupConfigurer exception

I have a SpringBoot application that was developed with JDK8 and was now ported to JDK11. I get the following exception at startup: ERROR SpringApplication: Application run failed org.springframework.beans.factory.BeanCreationException: Error…
ItFreak
  • 2,299
  • 5
  • 21
  • 45
8
votes
1 answer

Set gradle.ext in settings.gradle.kts with Gradle Kotlin DSL

Here's code snippet from google/exoplayer - which is written in Groovy buildscript. // settings.gradle gradle.ext.exoplayerRoot = 'path/to/exoplayer' gradle.ext.exoplayerModulePrefix = 'exoplayer-' apply from: new File(gradle.ext.exoplayerRoot,…
Tura
  • 1,227
  • 11
  • 22
8
votes
1 answer

Upload file in Jenkins input step to workspace

I would like to use the "input step" of Jenkins to upload a binary file to the current workspace. However, the code below seems to upload the file to the Jenkins master, not to the workspace of the current job on the slave where the job is…
Timmy Brolin
  • 1,101
  • 1
  • 8
  • 18
8
votes
1 answer

How to automate Maven and Java JDK8 installation with groovy for Jenkins?

I'm building a Jenkins Docker image and I will like to automate the installation of Maven 3 and Java 8 last JDK. But unfortunately I use these two groovy files locate into the groovy folder: groovy/java.groovy: import jenkins.model.* import…
3logy
  • 2,634
  • 8
  • 46
  • 99
8
votes
3 answers

How can I create a pathing jar in Gradle

When running groovyc in a Windows env, I am running into issues due to the length of the classpath, in my situation. I would like to work around this by creating a pathing jar, and then put that jar on the cp. How can I create a pathing jar w/ all…
Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
8
votes
2 answers

How to trim parameters in Jenkins pipeline?

I am setting up a parameterized Jenkins job with pipeline. I need to trim trim parameters any suggestions? In New version of Jenkins i can able to get the parameters. But I can't modify the parameters. If i use setValue(), it gives me…
Learner
  • 199
  • 2
  • 2
  • 12