import groovy.json.JsonOutput class Example { static void main(String[] args) { def output = JsonOutput.toJson([name: 'John', ID: 1]) println(output); } }
class Example { static void main(String[] args) { def clos = {println "Hello ${it}"}; clos.call("World"); } }
class Student { int StudentID; String StudentName; int Marks1; int Marks2; int Marks3; int Total() { return Marks1+Marks2+Marks3; } static void main(String[] args) { Student st = new Student(); st.StudentID = 1; st.StudentName="Joe"; st.Marks1 = 10; st.Marks2 = 20; st.Marks3 = 30; println(st.Total()); } }
class Example { static void main(String[] args) { try { def arr = new int[3]; arr[5] = 5; } catch(ArrayIndexOutOfBoundsException ex) { println("Catching the Array out of Bounds exception"); }catch(Exception ex) { println("Catching the exception"); } finally { println("The final block"); } println("Let's move on after the exception"); } }
class Example { static void main(String[] args) { Integer x = 5,y = 10,z = 0; // The the values of 5,10 and 0 are boxed into Integer types // The values of x and y are unboxed and the addition is performed z = x+y; println(z); } }
/* Hello World in Groovy */ void deployDocs(String documentGenDir, Boolean ignoreAppendingSlack = false, Boolean isNewDocs = false) { Closure funcDeployDocs = { sh("yarn run docs") packageDocsBuild(documentGenDir, isNewDocs) send("${vars.getAppName()}-docs-build.tgz", "/home/ubuntu/") String deployScript = makeDeployScriptForDocs(isNewDocs) execFileOnRemote(deployScript) } executeDeployment(funcDeployDocs, ignoreAppendingSlack) } void packageDocsBuild(String documentGenDir, Boolean isNewDocs = false) { String script = "" if (!isNewDocs) { script = [ "appName=${getAppName()}", "documentGenDir=${documentGenDir}", ''' homeDir=`pwd` # Compress the build cd $homeDir/$documentGenDir tar -zcf ../$appName-docs-build.tgz html/ ''' ].join("\n") } else { script = [ "appName=${vars.getAppName()}", "envName=${vars.getEnvironment()}", "getProdDevices=${documentGenDir}", ''' homeDir=`pwd` # Check if this is prod environment or not if [ $envName == "prod" ] then mv site $homeDir/$getProdDevices cd $homeDir/$getProdDevices yarn install && yarn start tar -zcf ../$appName-docs-build.tgz site/ else tar -zcf $appName-docs-build.tgz site/ fi ''' ].join("\n") } retry(2) { sh(script) } }
dataSource { pooled = true jmxExport = true driverClassName = "com.mysql.jdbc.Driver" username = "prismdba" password = "password" password = "QAZwsxEDC123" //product } hibernate { cache.use_second_level_cache = true cache.use_query_cache = false //cache.region.factory_class = 'org.hibernate.cache.SingletonEhCacheRegionFactory' // Hibernate 3 cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' // Hibernate 4 singleSession = true // configure OSIV singleSession mode flush.mode = 'manual' // OSIV session flush mode outside of transactional context } // environment specific settings environments { development { dataSource { dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', '' username = "prismdba" password = "password" url = "jdbc:mysql://localhost:3306/nposms?useUnicode=yes&characterEncoding=UTF-8" } } test { dataSource { dbCreate = "update" url = "jdbc:mysql://192.168.1.152:3306/nposms?useUnicode=yes&characterEncoding=UTF-8" username = "prismdba" password = "password" properties { // See https://grails.org/doc/latest/guide/conf.html#dataSource for documentation jmxEnabled = true initialSize = 5 maxActive = 50 minIdle = 5 maxIdle = 25 maxWait = 10000 maxAge = 10 * 60000 timeBetweenEvictionRunsMillis = 5000 minEvictableIdleTimeMillis = 60000 validationQuery = "SELECT 1" validationQueryTimeout = 3 validationInterval = 15000 testOnBorrow = true testWhileIdle = true testOnReturn = false jdbcInterceptors = "ConnectionState" defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED } } } klaverio { println "Using klaverio datasource" dataSource { dbCreate = "update" username = "prismdba" password = "QAZwsxEDC123" url = "jdbc:mysql://klaverio.c5zd4oxwvys7.ap-southeast-1.rds.amazonaws.com:3306/nposms?useUnicode=yes&characterEncoding=UTF-8" properties { // See https://grails.org/doc/latest/guide/conf.html#dataSource for documentation jmxEnabled = true initialSize = 5 maxActive = 50 minIdle = 5 maxIdle = 25 maxWait = 10000 maxAge = 10 * 60000 timeBetweenEvictionRunsMillis = 5000 minEvictableIdleTimeMillis = 60000 validationQuery = "SELECT 1" validationQueryTimeout = 3 validationInterval = 15000 testOnBorrow = true testWhileIdle = true testOnReturn = false jdbcInterceptors = "ConnectionState" defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED } } } prismbhamas { // doesn't seem to like a hyphen here println "Using prism-bhamas datasource" dataSource { dbCreate = "update" username = "prismrds" password = "1qazxsw2" url = "jdbc:mysql://prism-bhamas-rds.cucuwdqljar7.ap-southeast-1.rds.amazonaws.com:3306/nposms?useUnicode=yes&characterEncoding=UTF-8" properties { // See https://grails.org/doc/latest/guide/conf.html#dataSource for documentation jmxEnabled = true initialSize = 5 maxActive = 50 minIdle = 5 maxIdle = 25 maxWait = 10000 maxAge = 10 * 60000 timeBetweenEvictionRunsMillis = 5000 minEvictableIdleTimeMillis = 60000 validationQuery = "SELECT 1" validationQueryTimeout = 3 validationInterval = 15000 testOnBorrow = true testWhileIdle = true testOnReturn = false jdbcInterceptors = "ConnectionState" defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED } } } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more