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
1 answer

How do I count the number of occurrences of a charSequence in a String in Groovy

For Example if this is my equation string, IF(AND(x>0,x<100),5,IF(AND(x>101,x<200),6,10)) I want to count the no:of occurrences of "IF(" string in the equation.
Maria
  • 91
  • 1
  • 1
  • 3
8
votes
1 answer

How can Groovy Postbuild check the log message of a previous post-build action

I want to access the log of another post-build action, which runs right before the groovy postbuild. The console output looks like this: Build succeeded. 0 Warning(s) 0 Error(s) Time Elapsed 00:00:00.48 Code Metrics Report path:…
user5392653
8
votes
2 answers

How to produce a list of enum keys/names in groovy

I have the following enum in groovy public enum ImageTypes { jpg ("image/jpeg"), jpeg ("image/jpeg"), jpe ("image/jpeg"), jfif ("image/jpeg"), bmp ("image/bmp"), png ("image/png"), gif ("image/gif"), ief…
TriumphST
  • 1,194
  • 1
  • 10
  • 17
8
votes
3 answers

GroovyWS and complex requests

I've faced with a problem of sending complex requests with GroovyWS. This is sample request generated by soapUI:
trnl
  • 514
  • 3
  • 20
8
votes
2 answers

Geb login spec by example

I am trying to get familiar with Geb. I’m trying to run it from inside Grails, but that shouldn’t matter at all since my question here is specific to Geb. I have the following test directory structure: myapp/ test/ …
smeeb
  • 27,777
  • 57
  • 250
  • 447
8
votes
5 answers

grails app root context

I have a test grails app setup with a context of "/testapp". When I add a link in my gsp that references / it does not go to the root of my grails.app.context, but to the root of my grails.serverURL property. For example given a link with href…
ibuck
  • 495
  • 1
  • 5
  • 16
8
votes
2 answers

Import inner enum in Groovy script

I have a Groovy class defined in Vehicles.groovy that contains some inner enums: public class Vehicles { public enum Land { BICYCLE, CAR, TRAIN } public enum Water { SAILBOAT, MOTORBOAT } public enum Air { JET, …
jiangty
  • 311
  • 2
  • 9
8
votes
2 answers

Spring Boot devtools IntelliJ

I am using Spring Boot 1.3.0.M5 and I am trying to take advantage of devtools. This allows you to make changes to your application while in development and boot will reload your application. I have seen this demo work in STS using Java and Maven. I…
Dan Vega
  • 1,097
  • 1
  • 14
  • 23
8
votes
2 answers

Set encoding for filter() call in gradle copy task

Let's say there is this sample groovy code in my build.gradle: import org.apache.tools.ant.filters.ReplaceTokens task doSomeFiltering(type: Copy) { from 'some/directory' into 'some/target' filter(ReplaceTokens, tokens: [SAMPLE:…
randers
  • 5,031
  • 5
  • 37
  • 64
8
votes
1 answer

Invalid name provided (Mechanism level: KrbException: Cannot locate default realm) in groovy script

i have a groovy script that connect to MSSQL database, a few week ago it works very nice, but today i had upload a last version of mac os, and my script give me this exception: Caught: java.sql.SQLException: I/O Error: GSS Failed: Invalid name…
user3468273
  • 81
  • 1
  • 1
  • 3
8
votes
1 answer

Import Java library groovy

i want to use a method defined in the apache.common.net library in my groovy-Script. I first downloaded and included it in my config: this.class.classLoader.rootLoader.addURL(new…
Mattes
  • 159
  • 1
  • 2
  • 11
8
votes
1 answer

Spring boot + Groovy + logback.groovy

I am mixing Groovy and Java in my Spring-boot application. Rest controllers and data access is written in Groovy. Configurations are mainly in Java. As per logback documentation, if there is a logback.groovy file in the classpath, it's supposed to…
Sree
  • 746
  • 6
  • 21
8
votes
1 answer

Grails Unit Test Exception java.lang.Exception: No tests found matching grails test target pattern filter

I am just starting to learn Grails testing and I tried to write my first grails test.For this, I created a fresh grails project and created a controller named com.rahulserver.SomeController: package com.rahulserver class SomeController { def…
rahulserver
  • 10,411
  • 24
  • 90
  • 164
8
votes
2 answers

Groovy: Is for..in significantly faster than .each?

I'm curious if for..in should be preferred to .each for performance reasons.
Alexander Suraphel
  • 10,103
  • 10
  • 55
  • 90
8
votes
4 answers

Mocking slf4j with Spock

I have a Groovy class annotated with @Slf4j, so it gets a private final Logger log field, whose usage I'd like to test. I want to continue using @Slf4j and not expose the log field any further just to enable testing. I'm writing my tests using Spock…
orsg
  • 661
  • 1
  • 6
  • 15
1 2 3
99
100