@@ -9,40 +9,38 @@ import org.gradle.work.DisableCachingByDefault
9
9
import javax.inject.Inject
10
10
11
11
@DisableCachingByDefault(because = " Produces no cacheable output" )
12
- abstract class CreateGitTag extends DefaultTask {
12
+ abstract class CreateGitTag @Inject constructor(
13
+ private val objects : ObjectFactory ,
14
+ private val execOperations : ExecOperations
15
+ ) : DefaultTask() {
13
16
14
- @Inject
15
- abstract ObjectFactory getObjects ( )
17
+ @get:Input
18
+ val tagName : Property < String > = objects.property( String :: class .java )
16
19
17
- @Inject
18
- abstract ExecOperations getExecOperations ()
19
-
20
- @Input
21
- abstract Property<String > getTagName ()
22
-
23
- @Input
24
- @Optional
25
- final abstract Property<Boolean > overwriteExisting = objects. property(Boolean ). convention(false )
20
+ @get:Input
21
+ @get:Optional
22
+ val overwriteExisting: Property <Boolean > = objects.property(Boolean ::class .java).apply {
23
+ value(false )
24
+ }
26
25
27
26
@TaskAction
28
- def tag () {
27
+ fun applyArgbash () {
29
28
logger.info(" Tagging HEAD as ${tagName.get()} " )
30
- execOperations. exec { execSpec ->
31
- def args = [ " git" , " tag" ]
29
+ execOperations.exec {
30
+ val args = mutableListOf ( " git" , " tag" )
32
31
if (overwriteExisting.get()) {
33
32
args.add(" -f" )
34
33
}
35
34
args.add(tagName.get())
36
- execSpec . commandLine(args)
35
+ commandLine(args)
37
36
}
38
- execOperations. exec { execSpec ->
39
- def args = [ " git" , " push" , " origin" ]
37
+ execOperations.exec {
38
+ val args = mutableListOf ( " git" , " push" , " origin" )
40
39
if (overwriteExisting.get()) {
41
40
args.add(" -f" )
42
41
}
43
42
args.add(" --tags" )
44
- execSpec . commandLine(args)
43
+ commandLine(args)
45
44
}
46
45
}
47
-
48
46
}
0 commit comments