淺談 Groovy 與 Gradle

  • View
    108

  • Download
    5

Embed Size (px)

DESCRIPTION

- Java Groovy - Groovy DSL - Gradle - Gradle IDE

Transcript

  • 1. Groovy Gradle http://openhome.cc

2. Java Groovy Groovy DSL Gradle Gradle IDE 3. Java Groovy 4. Hello, world! Java 5. Groovy - public - print 6. - Setter - Getter 7. - Gstring - Setter - Getter - 8. 9. - List - Map - Range 10. 11. 12. - - 13. String.prototype.toUpperEach = function(action) { for(var i = 0; i < this.length; i++) { action(this.charAt(i).toUpperCase()); } }; 'abcdef'.toUpperEach(function(ch) { console.log(ch); }); 14. XD function toString() { return this.name + ', ' + this.age; } var p1 = {name : 'Justin', age : 38}; var p2 = {name : 'Monica', age : 35}; p1.toString = toString; console.log(p1.toString());p2.toString = toString; console.log(p2.toString()); 15. Groovy DSL 16. Groovy Closure Closure Lambda 17. Closure 18. this - Java this Closure owner - Closure this Closure Closure delegate - owner 19. DSL Domain Specific Language Closure maketo frombodyxml 20. 21. Gradle 22. XML Project Target Task Ant ... Ant Ivy 23. XML Convention Over Configuration Archetype plugin Maven 4.0.0tw.com.codedatahelloworldjar1.0-SNAPSHOThelloworldhttp://maven.apache.orgjunitjunit3.8.1test 24. Ant Maven Lifecycle DSL plugin Gradle Hibernate Maven Gradle Spring Maven Gradle Android Studio Gradle 25. Gradle apply plugin: 'java' apply plugin:'application' mainClassName = "tw.com.codedata.HelloWorld" repositories { mavenCentral() } dependencies { compile group: 'commons-logging', name: 'commons-logging', version: '1.1.1' compile group: 'log4j', name: 'log4j', version: '1.2.16' } 26. Gradle $ gradle run :compileJava :processResources apply plugin: 'java' :classes :run apply plugin:'application' INFO [main] (HelloWorld.java:11) - Hello World mainClassName = "tw.com.codedata.HelloWorld"BUILD SUCCESSFULrepositories { mavenCentral() } Total time:6.027 secsdependencies { compile group: 'commons-logging', name: 'commons-logging', version: '1.1.1' compile group: 'log4j', name: 'log4j', version: '1.2.16' } 27. Every configuration file becomes a programming language 28. Hello World build.gradle Closuretask hello { doLast { println 'Hello world!' } } Closure Groovy $ gradle -q hello Hello world! 29. task upper