groovy

MissingMethodException in groovy

十年热恋 提交于 2020-01-15 11:22:51
问题 I'm trying to work with pdfbox and groovy together. I wrote a code that takes some information in a format of string and creates a pdf document with that info. I want to integrate this code to an android app I'm creating. I ran the code in intellij IDEA and it works very well, but when I try to run the code in Android Studio, I get a MissingPropertyException in some part of the code which works perfectly not on Android Studio. The code in this part use a method called getWidth() from the

MissingMethodException in groovy

自闭症网瘾萝莉.ら 提交于 2020-01-15 11:22:42
问题 I'm trying to work with pdfbox and groovy together. I wrote a code that takes some information in a format of string and creates a pdf document with that info. I want to integrate this code to an android app I'm creating. I ran the code in intellij IDEA and it works very well, but when I try to run the code in Android Studio, I get a MissingPropertyException in some part of the code which works perfectly not on Android Studio. The code in this part use a method called getWidth() from the

Jenkins' JobDSL Queue with Parameters

匆匆过客 提交于 2020-01-15 10:25:13
问题 Does anyone know if you can run a Jenkins' job from JobDSL that has parameters? I have used queue https://jenkinsci.github.io/job-dsl-plugin/#path/queue But according to the docs, it only accepts a string or Job object. Maybe there is a way to do it with Job object, but its not clear. From JobDSL docs: def example1 = job('example-1') { displayName('first example') } queue(example1) job('example-2') { displayName('second example') } queue('example-2') 回答1: Have same problem and couldn't find

groovy script in jenkins fails

房东的猫 提交于 2020-01-15 08:58:09
问题 I have a groovy script which works fine for all jenkins job but fails for one jenkin jobs. It works fine in Jenkins scriptler but does not work when I create the job dsl in groovy. parameters { activeChoiceParam('BRANCH') { description('Select the branch to build') choiceType('SINGLE_SELECT') groovyScript { script(""" import jenkins.* import jenkins.model.* import hudson.* credentialsId = 'bbfe8cd19' def github_token = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(

Grails - Making Methods Globally Available and Metaclass Programming

和自甴很熟 提交于 2020-01-15 08:15:42
问题 I inserted this line into my init() of my BootStrap class Integer.metaClass.minutes = { 60000L * delegate } I was then not able to use it from a Job class (Quartz plugin). Do I put this line of code somewhere else to make it a global modification? I was also wondering the best way to make a function available inside all classes in Grails. Like a global function. Would it be to extend the Object metaclass? or is there a better way? 回答1: Do I put this line of code somewhere else to make it a

WorkflowScript.with in Jenkins

岁酱吖の 提交于 2020-01-15 05:13:11
问题 I have a class in a jenkins shared library that stores the instance of a WorkflowScript class from a jenkins pipeline script as shown below. def myTools = new my.org.MyTools(this) the constructore of MyTools just stores the instance of WorkflowScript like this... MyTools(script){ this.script = script } then I have a method that tries to use groovy's .with on script but fails... myMethod(){ script.with{ node{ echo "I want to be able to use pipeline syntax here" sh 'echo "without using script.

groovy/java regex check if “yyyy.MM.dd” format

大憨熊 提交于 2020-01-15 04:54:33
问题 I have a string representing a date, for example "2010.12.25" . How can I control if it is of "yyyy.MM.dd" format? There is no need to check the validness of the date. 回答1: You have the Regex, in Groovy, you can just do: boolean match = "2010.12.12" ==~ /\d{4}\.\d{2}\.\d{2}/ 回答2: use SimpleDateFormat to parse() the string, handling the exception to decide if it is a valid date string. don't use regex to check a date. e.g.: 2010.30.40 2010.13.34 回答3: try { Date.parse('yyyy.MM.dd', '2013.12.21'

What is the better way to add commas to multiple elements string output?

混江龙づ霸主 提交于 2020-01-15 04:50:30
问题 I need to put comma separated values into ourOutput (for future output). So, what I need is to add commas and remove last unnecessary comma or check if comma should be placed. I came to two following solutions: 1st approach: ourOutput = ''<<''; for (int i = 0; i< 10, i++) { if (/*some condition goes here*/) { if (ourOutput.size() == 0) { ourOutput << ', ' } ourOutput << i; } } pros: don't change resulting string cons: check on each iteration; 2nd approach: ourOutput = ''<<''; for (int i = 0;

NoClassDefFound ShortTypeHandling with gradle custom plugin usage

五迷三道 提交于 2020-01-15 03:50:26
问题 I wrote some groovy code, compiled using compile localGroovy() and published the jar to artifactory. Now I wrote a gradle plugin, where I have compile localGroovy() and compile "gav of jar above" I build my plugin and publish to same artifactory. Now, To use the above custom plugin, I am having buildscript { dependencies { classpath localGroovy() classpath "gav of plugin", transitive: true } } As you see, I'm using same localGroovy() everywhere. My gradle version is also same. Now with above,

How to prevent from Grails not to delete child while deleting parent?

本小妞迷上赌 提交于 2020-01-15 02:47:24
问题 i have one to many relationship between author and books, one author has many books.. i have domain class like this Author.groovy class Author { String authorName; String authorAddress; String authorCNIC; static hasMany = [books:Book] static constraints = { books(nullable: true) } } Book.groovy class Book { String bookName; String Isbn; static belongsTo = [author:Author] static constraints = { author(nullable: true) } } now when i call this function def deleteauthor() { def id=params.id