Size: 356
Comment:
|
Size: 2136
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
* http://groovy-lang.org/groovy-dev-kit.html * http://groovy-lang.org/objectorientation.html |
|
Line 4: | Line 6: |
* https://dl.bintray.com/groovy/maven/apache-groovy-binary-3.0.3.zip | == Install == {{{#!highlight bash wget https://dl.bintray.com/groovy/maven/apache-groovy-binary-3.0.3.zip cp apache-groovy-binary-3.0.3.zip ~/ cd ~/ unzip apache-groovy-binary-3.0.3.zip wget https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-binary-4.0.26.zip unzip apache-groovy-binary-4.0.26.zip nano ~/.bashrc # export GROOVY_HOME=$HOME/groovy-4.0.26 # PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/user/jdk-11.0.2/bin:/home/user/scripts # PATH=$PATH:/opt/mssql-tools/bin/:$GROOVY_HOME/bin # export PATH . ~/.bashrc groovysh # print("aaa") groovyConsole }}} == groovyc - compiler == * nano MyClass.groovy {{{#!highlight groovy class X{ int amount } def x = new X() x.amount = 1 println("${x.amount}") }}} {{{#!highlight sh groovyc MyClass.groovy java -cp . -jar $GROOVY_HOME/lib/groovy-3.0.3.jar MyClass java -jar $GROOVY_HOME/lib/groovy-3.0.3.jar MyClass }}} == swing - groovy == {{{#!highlight groovy import groovy.swing.SwingBuilder import java.awt.BorderLayout as BL count = 0 def actionPerformedFn(){ count++; textlabel.text = "Clicked ${count} time(s)." println "clicked" } def quitFn(){ System.exit(0) } new SwingBuilder().edt { frame(title: 'Frame', size: [300, 300], show: true) { borderLayout() textlabel = label(text: 'Click the button!', constraints: BL.NORTH) button(text:'Click Me', actionPerformed: {actionPerformedFn()}, constraints:BL.WEST) button(text:'Quit', actionPerformed: {quitFn()}, constraints:BL.EAST) } } }}} {{{#!highlight sh groovyc swing.groovy java -cp .:$GROOVY_HOME/lib/groovy-3.0.3.jar:$GROOVY_HOME/lib/groovy-swing-3.0.3.jar swing }}} |
Groovy
Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax
Install
1 wget https://dl.bintray.com/groovy/maven/apache-groovy-binary-3.0.3.zip
2 cp apache-groovy-binary-3.0.3.zip ~/
3 cd ~/
4 unzip apache-groovy-binary-3.0.3.zip
5
6 wget https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-binary-4.0.26.zip
7 unzip apache-groovy-binary-4.0.26.zip
8
9
10 nano ~/.bashrc
11 # export GROOVY_HOME=$HOME/groovy-4.0.26
12 # PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/user/jdk-11.0.2/bin:/home/user/scripts
13 # PATH=$PATH:/opt/mssql-tools/bin/:$GROOVY_HOME/bin
14 # export PATH
15 . ~/.bashrc
16 groovysh
17 # print("aaa")
18 groovyConsole
groovyc - compiler
nano MyClass.groovy
swing - groovy
1 import groovy.swing.SwingBuilder
2 import java.awt.BorderLayout as BL
3
4 count = 0
5
6 def actionPerformedFn(){
7 count++;
8 textlabel.text = "Clicked ${count} time(s)."
9 println "clicked"
10 }
11
12 def quitFn(){
13 System.exit(0)
14 }
15
16 new SwingBuilder().edt {
17 frame(title: 'Frame', size: [300, 300], show: true) {
18 borderLayout()
19 textlabel = label(text: 'Click the button!', constraints: BL.NORTH)
20 button(text:'Click Me', actionPerformed: {actionPerformedFn()}, constraints:BL.WEST)
21 button(text:'Quit', actionPerformed: {quitFn()}, constraints:BL.EAST)
22 }
23 }