Skip to content

Commit 00f5648

Browse files
abialasmaibin
authored andcommitted
BAEL-1432 (eugenp#3743)
* BAEL-1412 add java 8 spring data features * BAEL-21 new HTTP API overview * BAEL-21 fix executor * BAEL-1432 add custom gradle task
1 parent d9fddbd commit 00f5648

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

gradle/build.gradle

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,60 @@ task execSecondTest {
3333
}
3434
println 'This will be executed during the configuration phase as well.'
3535
}
36+
37+
task welcome {
38+
doLast {
39+
println 'Welcome on the Baeldung!'
40+
}
41+
}
42+
43+
task welcomeWithGroup {
44+
group 'Sample category'
45+
doLast {
46+
println 'Welcome on the Baeldung!'
47+
}
48+
}
49+
50+
task welcomeWithGroupAndDescription {
51+
group 'Sample category'
52+
description 'Tasks which shows welcome message'
53+
doLast {
54+
println 'Welcome on the Baeldung!'
55+
}
56+
}
57+
58+
class PrintToolVersionTask extends DefaultTask {
59+
String tool
60+
61+
@TaskAction
62+
void printToolVersion() {
63+
switch (tool) {
64+
case 'java':
65+
println System.getProperty("java.version")
66+
break
67+
case 'groovy':
68+
println GroovySystem.version
69+
break
70+
default:
71+
throw new IllegalArgumentException("Unknown tool")
72+
}
73+
}
74+
}
75+
76+
task printJavaVersion(type : PrintToolVersionTask) {
77+
tool 'java'
78+
}
79+
80+
task printGroovyVersion(type : PrintToolVersionTask) {
81+
tool 'groovy'
82+
}
83+
84+
import com.baeldung.PrintToolVersionBuildSrcTask
85+
86+
task printJavaVersionBuildSrc(type : PrintToolVersionBuildSrcTask) {
87+
tool 'java'
88+
}
89+
90+
task printGroovyVersionBuildSrc(type : PrintToolVersionBuildSrcTask) {
91+
tool 'groovy'
92+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung
2+
3+
import org.gradle.api.DefaultTask
4+
import org.gradle.api.tasks.TaskAction
5+
6+
class PrintToolVersionBuildSrcTask extends DefaultTask {
7+
String tool
8+
9+
@TaskAction
10+
void printToolVersion() {
11+
switch (tool) {
12+
case 'java':
13+
println System.getProperty("java.version")
14+
break
15+
case 'groovy':
16+
println GroovySystem.version
17+
break
18+
default:
19+
throw new IllegalArgumentException("Unknown tool")
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)