groovy

how to debug a gsp page? (no grails, just gsp)

帅比萌擦擦* 提交于 2020-01-13 10:29:12
问题 I've tried with netbeans and eclipse, with no luck... (coudn't try IntelliJ idea) I gave a quick look ant the code http://kickjava.com/src/groovy/servlet/TemplateServlet.java.htm and it gives me the impression that .gsp pages are translated to .groovy servlets (groovlets) in memory (I might be wrong)... so perhaps it's not so easy to debug gsp as I though... so, can anybody tell me how to do it? pd: By debugging I mean things like browsing the code step-by-step, inspecting variables, adding

Jenkins Packages on Groovy Classpath?

做~自己de王妃 提交于 2020-01-13 10:23:12
问题 When using the Groovy Jenkins plugin (not the Groovy Post Build Plugin, which is a different thing) as a Post Step, I can't resolve classes in the hudson.model package. Do I need to add the Jenkins .war onto the classpath, or should these packages already be there? Script: import hudson.model.*; import hudson.util.*; AbstractBuild currentBuild = (AbstractBuild) Thread.currentThread().executable; def mavenVer = currentBuild.getMavenArtifacts().getModuleRecords()[0].mainArtifact.version;

Why Groovy's map does not have metaClass?

强颜欢笑 提交于 2020-01-13 09:09:15
问题 Why does Groovy's literal map does not have a metaClass? // lists work as expected: aList = [] println aList.class // class java.util.ArrayList println aList.metaClass // gives the full blown metaclass // org.codehaus.groovy.runtime.HandleMetaClass@3de6696c // [groovy.lang.MetaClassImpl@3de6696c[class java.util.ArrayList]] // string and numbers too: println ''.metaClass println 12.metaClass // map does not: aMap = [:] println myMap.metaClass // gives null println myMap.class // also gives

Get Date from timestamp in Groovy

泄露秘密 提交于 2020-01-13 08:43:17
问题 As trivial as it may seem, I cannot find a way to transform a Unix timestamp into a Date object in Groovy. Let me try with 1280512800 , which should become Fri, 30 Jul 2010 18:00:00 GMT My first attempt was new Date(1280512800) // wrong, becomes Thu Jan 15 20:41:52 CET 1970 Then I read that Java timestamps use milliseconds, hence I should use new Date((long)1280512800 * 1000) // the cast to long is irrelevant in Groovy, in any case I get // Thu Jan 08 03:09:05 CET 1970 What is the right way

Get Date from timestamp in Groovy

£可爱£侵袭症+ 提交于 2020-01-13 08:42:06
问题 As trivial as it may seem, I cannot find a way to transform a Unix timestamp into a Date object in Groovy. Let me try with 1280512800 , which should become Fri, 30 Jul 2010 18:00:00 GMT My first attempt was new Date(1280512800) // wrong, becomes Thu Jan 15 20:41:52 CET 1970 Then I read that Java timestamps use milliseconds, hence I should use new Date((long)1280512800 * 1000) // the cast to long is irrelevant in Groovy, in any case I get // Thu Jan 08 03:09:05 CET 1970 What is the right way

Create a file with some content using Groovy in Jenkins pipeline

限于喜欢 提交于 2020-01-13 07:36:09
问题 I am trying to create a file called groovy1.txt with the content "Working with files the Groovy way is easy." Note: I don't want to use the shell to create this file, instead I want to use Groovy to achieve this. I have following script in my Jenkins pipeline. node { def file1 = new File('groovy1.txt') file1.write 'Working with files the Groovy way is easy.\n' sh 'ls -l' // Expecting the file groovy1.txt should present with the content mentioned above } But it is throwing FileNotFound

How to use groovy interpreted (with spring-aop annotation) within an spring boot 2 java application build with maven?

拈花ヽ惹草 提交于 2020-01-13 03:23:06
问题 I have a spring boot 2 java app and would like to use interpreted (not compiled) groovy code to inject aop. From reading the spring documentation this sounds like it is possible, but I could'nt find any examples. AOP - advising scripted beans: You are of course not just limited to advising scripted beans…​ you can also write aspects themselves in a supported dynamic language and use such beans to advise other Spring beans. This really would be an advanced use of the dynamic language support

Groovy GDK equivalent of Apache Commons StringUtils.capitalize(str) or Perl's ucfirst(str)

烂漫一生 提交于 2020-01-12 16:06:13
问题 Yes/no-question: Is there a Groovy GDK function to capitalize the first character of a string? I'm looking for a Groovy equivalent of Perl's ucfirst(..) or Apache Commons StringUtils.capitalize(str) (the latter capitalizes the first letter of all words in the input string). I'm currently coding this by hand using .. str = str[0].toUpperCase() + str[1 .. str.size() - 1] .. which works, but I assume there is a more Groovy way to do it. I'd imagine ucfirst(..) being a more common operation than

Groovy GDK equivalent of Apache Commons StringUtils.capitalize(str) or Perl's ucfirst(str)

杀马特。学长 韩版系。学妹 提交于 2020-01-12 16:06:04
问题 Yes/no-question: Is there a Groovy GDK function to capitalize the first character of a string? I'm looking for a Groovy equivalent of Perl's ucfirst(..) or Apache Commons StringUtils.capitalize(str) (the latter capitalizes the first letter of all words in the input string). I'm currently coding this by hand using .. str = str[0].toUpperCase() + str[1 .. str.size() - 1] .. which works, but I assume there is a more Groovy way to do it. I'd imagine ucfirst(..) being a more common operation than

closures in groovy vs closures in java 8 (lambda expressions)?

点点圈 提交于 2020-01-12 06:56:07
问题 Given doSomething(Function foo) { println foo(2) } Groovy: doSomething( { it*it } as Function ) Java: doSomething( (x) -> x*x ) Is there any difference between the two? 回答1: In Groovy, closures are first class citizens of type groovy.lang.Closure , whereas lambdas in Java 8 are actual instances of the default method interface they represent. This means you need to use the as keyword in Groovy (as you've shown), but alternatively, in Java you need to specify an interface, so in Groovy, you