|
| 1 | +buildscript { |
| 2 | + repositories { |
| 3 | + maven { |
| 4 | + url "https://plugins.gradle.org/m2/" |
| 5 | + } |
| 6 | + } |
| 7 | + dependencies { |
| 8 | + classpath "org.shipkit:shipkit:0.9.117" |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | + |
| 13 | +plugins { |
| 14 | + id 'java' |
| 15 | +} |
| 16 | + |
| 17 | + |
| 18 | +apply from: 'aplugin.gradle' |
| 19 | +apply plugin: 'org.shipkit.bintray-release' |
| 20 | + |
| 21 | + |
| 22 | +//hello task |
| 23 | +task hello { |
| 24 | + doLast { |
| 25 | + println 'Baeldung' |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +//Groovy in gradle task |
| 30 | +task toLower { |
| 31 | + doLast { |
| 32 | + String someString = 'HELLO FROM BAELDUNG' |
| 33 | + println "Original: " + someString |
| 34 | + println "Lower case: " + someString.toLowerCase() |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | + |
| 39 | +// Task dependencies |
| 40 | +task helloGradle { |
| 41 | + doLast { |
| 42 | + println 'Hello Gradle!' |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +task fromBaeldung(dependsOn: helloGradle) { |
| 47 | + doLast { |
| 48 | + println "I'm from Baeldung" |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | + |
| 53 | +//Adding behavior to a task via api |
| 54 | +task helloBaeldung { |
| 55 | + doLast { |
| 56 | + println 'I will be executed second' |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +helloBaeldung.doFirst { |
| 61 | + println 'I will be executed first' |
| 62 | +} |
| 63 | + |
| 64 | +helloBaeldung.doLast { |
| 65 | + println 'I will be executed third' |
| 66 | +} |
| 67 | + |
| 68 | +helloBaeldung { |
| 69 | + doLast { |
| 70 | + println 'I will be executed fourth' |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +//Adding extra task properties |
| 78 | +task ourTask { |
| 79 | + ext.theProperty = "theValue" |
| 80 | +} |
| 81 | + |
| 82 | +task printTaskProperty { |
| 83 | + doLast { |
| 84 | + println ourTask.theProperty |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +//Declaring dependencies |
| 91 | +dependencies { |
| 92 | + compile group: |
| 93 | + 'org.springframework', name: 'spring-core', version: '4.3.5.RELEASE' |
| 94 | + compile 'org.springframework:spring-core:4.3.5.RELEASE', |
| 95 | + 'org.springframework:spring-aop:4.3.5.RELEASE' |
| 96 | + compile( |
| 97 | + [group: 'org.springframework', name: 'spring-core', version: '4.3.5.RELEASE'], |
| 98 | + [group: 'org.springframework', name: 'spring-aop', version: '4.3.5.RELEASE'] |
| 99 | + ) |
| 100 | + testCompile('org.hibernate:hibernate-core:5.2.12.Final') { |
| 101 | + transitive = true |
| 102 | + } |
| 103 | + runtime(group: 'org.hibernate', name: 'hibernate-core', version: '5.2.12.Final') { |
| 104 | + transitive = false |
| 105 | + } |
| 106 | + runtime "org.codehaus.groovy:groovy-all:2.4.11@jar" |
| 107 | + runtime group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.11', ext: 'jar' |
| 108 | + |
| 109 | + compile fileTree(dir: 'libs', include: '*.jar') |
| 110 | +} |
0 commit comments