Showing posts with label Groovy. Show all posts
Showing posts with label Groovy. Show all posts

Running Groovy with multiple command line parameters


Source for ArgumentsTest.groovy


#!/bin/bash
//usr/bin/env groovy  -cp extra.jar:spring.jar:etc.jar -d -Dlog4j.configuration=file:/etc/myapp/log4j.xml "$0" $@; exit $?


def params = ""
args.each() {
    if (it) {
        params +=   it + "! "
    }
}

println "Hello World " + params

Execute permission

$ sudo chmod +x ArgumentsTest.groovy
Password:

Output


$ ./ArgumentsTest.groovy Uki Natalia Zoe
Hello World Uki! Natalia! Zoe!


As an Amazon Associate I earn from qualifying purchases.

Running Groovy with multiple command line parameters


Source for ArgumentsTest.groovy


#!/bin/bash
//usr/bin/env groovy  -cp extra.jar:spring.jar:etc.jar -d -Dlog4j.configuration=file:/etc/myapp/log4j.xml "$0" $@; exit $?


def params = ""
args.each() {
    if (it) {
        params +=   it + "! "
    }
}

println "Hello World " + params

Execute permission

$ sudo chmod +x ArgumentsTest.groovy
Password:

Output


$ ./ArgumentsTest.groovy Uki Natalia Zoe
Hello World Uki! Natalia! Zoe!


As an Amazon Associate I earn from qualifying purchases.

Mac Groovy installation with brew

$ brew install groovy
==> Downloading https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.6.zip
######################################################################## 100.0%
==> Caveats
You should set GROOVY_HOME:
  export GROOVY_HOME=/usr/local/opt/groovy/libexec
==> Summary
🍺  /usr/local/Cellar/groovy/2.4.6: 63 files, 27.6M, built in 6 seconds
$ groovy -v
Groovy Version: 2.4.6 JVM: 1.8.0_77 Vendor: Oracle Corporation OS: Mac OS X



If you like this post, please donate 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

Mac Groovy installation with brew

$ brew install groovy
==> Downloading https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.6.zip
######################################################################## 100.0%
==> Caveats
You should set GROOVY_HOME:
  export GROOVY_HOME=/usr/local/opt/groovy/libexec
==> Summary
🍺  /usr/local/Cellar/groovy/2.4.6: 63 files, 27.6M, built in 6 seconds
$ groovy -v
Groovy Version: 2.4.6 JVM: 1.8.0_77 Vendor: Oracle Corporation OS: Mac OS X



If you like this post, please donate 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

9a. Gradle upgrade

In this tutorial we will overview basics of Gradle build system.

Step 1: verify what Gradle version you have

$ gradle -version

------------------------------------------------------------
Gradle 2.13
------------------------------------------------------------

Build time:   2016-04-25 04:10:10 UTC
Build number: none
Revision:     3b427b1481e46232107303c90be7b05079b05b1c

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_77 (Oracle Corporation 25.77-b03)
OS:           Mac OS X 10.11.4 x86_64



Step 2: update to the newest 

if you are missing entirely (on Mac using brew):

install brew on Mac:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

and now install gradle on Mac

brew install gradle

If you are updating (on Mac using brew):

brew update && brew upgrade gradle
...
==> Downloading https://downloads.gradle.org/distributions/gradle-2.1-bin.zip

######################################################################## 100.0%



$ gradle -version
------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------
Build time:   2014-09-08 10:40:39 UTC
Build number: none
Revision:     e6cf70745ac11fa943e19294d19a2c527a669a53
Groovy:       2.3.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_20-ea (Oracle Corporation 25.20-b05)
OS:           Mac OS X 10.9.4 x86_64

$ which 

gradle/usr/local/bin/gradle



If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:
Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

9a. Gradle upgrade

In this tutorial we will overview basics of Gradle build system.

Step 1: verify what Gradle version you have

$ gradle -version

------------------------------------------------------------
Gradle 2.13
------------------------------------------------------------

Build time:   2016-04-25 04:10:10 UTC
Build number: none
Revision:     3b427b1481e46232107303c90be7b05079b05b1c

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_77 (Oracle Corporation 25.77-b03)
OS:           Mac OS X 10.11.4 x86_64



Step 2: update to the newest 

if you are missing entirely (on Mac using brew):

install brew on Mac:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

and now install gradle on Mac

brew install gradle

If you are updating (on Mac using brew):

brew update && brew upgrade gradle
...
==> Downloading https://downloads.gradle.org/distributions/gradle-2.1-bin.zip

######################################################################## 100.0%



$ gradle -version
------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------
Build time:   2014-09-08 10:40:39 UTC
Build number: none
Revision:     e6cf70745ac11fa943e19294d19a2c527a669a53
Groovy:       2.3.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_20-ea (Oracle Corporation 25.20-b05)
OS:           Mac OS X 10.9.4 x86_64

$ which 

gradle/usr/local/bin/gradle



If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:
Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

Groovy

Groovy Installation



$ curl -s get.gvmtool.net | bash

$ source "/Users/uki/.gvm/bin/gvm-init.sh"

$ gvm install groovy

$ groovy -version

Groovy Version: 2.4.3 JVM: 1.7.0_79 Vendor: Oracle Corporation OS: Mac OS X

$ which groovy

/Users/uki/.gvm/groovy/current/bin/groovy


To add Groovy permanently to your Terminal  PATH

edit ~/.bash_profile
# Groovy updated May 19, 2015
export GROOVY_HOME=/Users/uki/.gvm/groovy/current
export PATH=${PATH}:${GROOVY_HOME}/bin


First Script


groovy_scripts $ cat hello.groovy 

println 'Hello from Groovy'
groovy_scripts $ groovy hello

Hello from Groovy




Groovy Console


Groovy Console is good for quick testing of Scripts, especially copy and paste from the Web.


$ groovyConsole








interface Alive{
   void alive()
}

class Creature implements Alive{
    def grawl() {
        println(" Grrrrrrrr!!! grawls the Creature")
    }
    void alive()
    {
        println(" Grrrrr!!! thinks the Creature")
    }
}

class Human extends Creature {
    String name;
    def sayHi(name) {
        println(" Hi, my name is $name! says the Human")
    }
   
    void alive()
    {
        println(" I am alive! says the Human")
    }
}



Creature me = new Human()
me.grawl()
me.alive()
me.name = "Uki"
me.sayHi me.name

Creature bear = new Creature();
bear.alive()


OUTPUT:

uki@ groovy_scripts $ groovy hello
 Grrrrrrrr!!! grawls the Creature
 I am alive! says the Human
 Hi, my name is Uki! says the Human

 Grrrrr!!! thinks the Creature



If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

Groovy

Groovy Installation



$ curl -s get.gvmtool.net | bash

$ source "/Users/uki/.gvm/bin/gvm-init.sh"

$ gvm install groovy

$ groovy -version

Groovy Version: 2.4.3 JVM: 1.7.0_79 Vendor: Oracle Corporation OS: Mac OS X

$ which groovy

/Users/uki/.gvm/groovy/current/bin/groovy


To add Groovy permanently to your Terminal  PATH

edit ~/.bash_profile
# Groovy updated May 19, 2015
export GROOVY_HOME=/Users/uki/.gvm/groovy/current
export PATH=${PATH}:${GROOVY_HOME}/bin


First Script


groovy_scripts $ cat hello.groovy 

println 'Hello from Groovy'
groovy_scripts $ groovy hello

Hello from Groovy




Groovy Console


Groovy Console is good for quick testing of Scripts, especially copy and paste from the Web.


$ groovyConsole








interface Alive{
   void alive()
}

class Creature implements Alive{
    def grawl() {
        println(" Grrrrrrrr!!! grawls the Creature")
    }
    void alive()
    {
        println(" Grrrrr!!! thinks the Creature")
    }
}

class Human extends Creature {
    String name;
    def sayHi(name) {
        println(" Hi, my name is $name! says the Human")
    }
   
    void alive()
    {
        println(" I am alive! says the Human")
    }
}



Creature me = new Human()
me.grawl()
me.alive()
me.name = "Uki"
me.sayHi me.name

Creature bear = new Creature();
bear.alive()


OUTPUT:

uki@ groovy_scripts $ groovy hello
 Grrrrrrrr!!! grawls the Creature
 I am alive! says the Human
 Hi, my name is Uki! says the Human

 Grrrrr!!! thinks the Creature



If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

Groovy as DSL

http://docs.groovy-lang.org/docs/latest/html/documentation/core-domain-specific-languages.html

If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

Groovy as DSL

http://docs.groovy-lang.org/docs/latest/html/documentation/core-domain-specific-languages.html

If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

Groovy on Android

Android developers are already using Groovy in many places AROUND Android, for example in Gradle build scripts. Now the dream of using Groovy as primary language for Android is a little closer to realization! See what is cooking.


http://melix.github.io/blog/2014/06/grooid.html

also a good interview with Cédric Champeau, Senior Software Engineer working on Groovy for SpringSource/Pivotal here:

http://www.infoq.com/news/2014/06/groovy-android


As an Amazon Associate I earn from qualifying purchases.

Groovy on Android

Android developers are already using Groovy in many places AROUND Android, for example in Gradle build scripts. Now the dream of using Groovy as primary language for Android is a little closer to realization! See what is cooking.



As an Amazon Associate I earn from qualifying purchases.

apt quotation..