groovy

Catching an exception when loading a groovy file

荒凉一梦 提交于 2020-03-23 04:06:52
问题 I have these 3 groovy files: A.groovy: // ... stage("Test") { throw new Exception("This script fails") } B.groovy: // ... stage("Test") { // Nothing, want this to pass } main.groovy: // ... m = [:] status = [:] scripts = ["A", "B"] for script in scripts { m["${script}"] = { stage("${script}") { try { load "${script}.groovy" status["${script}"] = true } catch (Exception e) { status["${script}"] = false } } } } parallel m for result_iterator in status: print "${result_iterator.key} resulted in

升级andorid studio 3.5 后报错的问题解决方案

两盒软妹~` 提交于 2020-03-22 17:14:14
3 月,跳不动了?>>> 1.android studio GC overhead limit exceeded 在gradele.properties 中配置如下内容: android.useDeprecatedNdk=true org.gradle.daemon=true org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.configureondemand=true 2.cannot build selected target abi x86 no suitable splits configured armeabi-v7a arm64-v8a 在build.gradle中配置如下内容: splits { abi { enable true reset() include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' //select ABIs to build APKs for universalApk true //generate an additional APK that contains all

groovy 使用

℡╲_俬逩灬. 提交于 2020-03-22 11:25:13
3 月,跳不动了?>>> 简介 Groovy是构建在JVM上的一个轻量级却强大的动态语言, 它结合了Python、Ruby和Smalltalk的许多强大的特性. Groovy就是用Java写的 , Groovy语法与Java语法类似, Groovy 代码能够与 Java 代码很好地结合,也能用于扩展现有代码, 相对于Java, 它在编写代码的灵活性上有非常明显的提升,Groovy 可以使用其他 Java 语言编写的库. Groovy语法特性 return关键字可省略, 方法的最后一句表达式可作为返回值返回 (视具体情况使用, 避免降低可读性) 应用场景 动态规则配置 参考: https://gitee.com/pengchua/groovyrule 来源: oschina 链接: https://my.oschina.net/pengchanghua/blog/3208188

How to execute a gradle task after android dexDebug or dexRelease task

馋奶兔 提交于 2020-03-22 09:05:08
问题 The bounty expires in 9 hours . Answers to this question are eligible for a +50 reputation bounty. Arjun T Raj is looking for an up-to-date answer to this question. I want to run a Gradle task to execute some shell scripts after dexRelease or dexDebug task during the android build. I have tried the below approach task taskAfterDex(type:Exec) { workingDir '.' executable 'sh' args "-c", "source scriptskAfterDex.sh" ignoreExitValue true doLast { println "taskAfterDex completed" } } tasks

How to execute a gradle task after android dexDebug or dexRelease task

浪子不回头ぞ 提交于 2020-03-22 09:04:26
问题 The bounty expires in 9 hours . Answers to this question are eligible for a +50 reputation bounty. Arjun T Raj is looking for an up-to-date answer to this question. I want to run a Gradle task to execute some shell scripts after dexRelease or dexDebug task during the android build. I have tried the below approach task taskAfterDex(type:Exec) { workingDir '.' executable 'sh' args "-c", "source scriptskAfterDex.sh" ignoreExitValue true doLast { println "taskAfterDex completed" } } tasks

execute an exe on windows using groovy script

你。 提交于 2020-03-21 04:00:07
问题 I am trying to execute a MIR3 (notification system) exe from the Groovy console: def proc = "cmd /c C:\\Users\\AAithal\\Desktop\\MIR3\bin\\inConsole -H \"company.mir3.com\" -u \"user\" -p \"password\" -I -i \"Server\"".execute(); proc.waitForProcessOutput(System.out, System.err); println "proc" But get an error: The filename, directory name, or volume label syntax is incorrect. The path I have in the script is correct and I am able to execute the same from Windows CLI and getting the required

execute an exe on windows using groovy script

你离开我真会死。 提交于 2020-03-21 03:59:15
问题 I am trying to execute a MIR3 (notification system) exe from the Groovy console: def proc = "cmd /c C:\\Users\\AAithal\\Desktop\\MIR3\bin\\inConsole -H \"company.mir3.com\" -u \"user\" -p \"password\" -I -i \"Server\"".execute(); proc.waitForProcessOutput(System.out, System.err); println "proc" But get an error: The filename, directory name, or volume label syntax is incorrect. The path I have in the script is correct and I am able to execute the same from Windows CLI and getting the required

Dynamically compile java code which has dependencies on classes loaded by specific classloader

泪湿孤枕 提交于 2020-03-20 06:36:47
问题 We have an ability to compile java code dynamically on the fly. I know at least Java-Runtime-Compiler and InMemoryJavaCompiler But seems they cannot compile class which depends on some class from certain classloader. Is it possible to dynamically compile java code which depends on classes available only in specific classloader? Let's say: ClassLoader classloader = ... // only this CL can load class 'com.External' String source = "public class MyClass extends com.External {}"; Class<?>

别再 select * 了,送你 12 个查询技巧!

时光怂恿深爱的人放手 提交于 2020-03-18 13:08:14
某厂面试归来,发现自己落伍了!>>> 作者:AIOps 前端 应用程序慢如牛,原因多多,可能是网络的原因、可能是系统架构的原因,还有可能是数据库的原因。 那么如何提高数据库SQL语句执行速度呢?有人会说性能调优是数据库管理员(DBA)的事,然而性能调优跟程序员们也有莫大的关系。 image 程序中嵌入的一行行的SQL语句,如果使用了一些优化小技巧,定能达到事半功倍的效果。 技巧1 比较运算符能用 “=”就不用“<>” “=”增加了索引的使用几率。 技巧2 明知只有一条查询结果,那请使用 “LIMIT 1” “LIMIT 1”可以避免全表扫描,找到对应结果就不会再继续扫描了。 技巧3 为列选择合适的数据类型 能用TINYINT就不用SMALLINT,能用SMALLINT就不用INT,道理你懂的,磁盘和内存消耗越小越好嘛。 技巧4 将大的DELETE,UPDATE or INSERT 查询变成多个小查询 能写一个几十行、几百行的SQL语句是不是显得逼格很高?然而,为了达到更好的性能以及更好的数据控制,你可以将他们变成多个小查询。 image 技巧5 使用UNION ALL 代替 UNION,如果结果集允许重复的话 因为 UNION ALL 不去重,效率高于 UNION。 技巧6 为获得相同结果集的多次执行,请保持SQL语句前后一致 这样做的目的是为了充分利用查询缓冲

Groovy - Ignore extra attributes in a map during object instantiation

情到浓时终转凉″ 提交于 2020-03-18 03:18:53
问题 Is there a way to make groovy ignore extra attributes in a map during object instantiation? Example: class Banana{ String name } def params = [name:'someGuy', age:13] new Banana(params) In this example, groovy throws a No such property: age exception (obviously because age isn't defined in the Banana class. Without resorting to manually mapping only the desired attributes from the map to the constructor of the Banana class, is there a way to tell Banana to ignore the extra attributes? I