File tree Expand file tree Collapse file tree 5 files changed +28
-12
lines changed
buildSrc/src/main/kotlin/com/datadog/gradle Expand file tree Collapse file tree 5 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,18 @@ package com.datadog.gradle.plugin
9
9
import com.datadog.gradle.utils.execShell
10
10
import org.gradle.api.DefaultTask
11
11
import org.gradle.api.tasks.Internal
12
+ import org.gradle.process.ExecOperations
12
13
import java.io.File
13
14
14
15
abstract class CheckGeneratedFileTask (
15
- @Internal val genTaskName : String
16
+ @Internal val genTaskName : String ,
17
+ private val execOperations : ExecOperations
16
18
) : DefaultTask() {
17
19
18
20
// region Task
19
21
20
22
fun verifyGeneratedFileExists (targetFile : File ) {
21
- val lines = project .execShell(
23
+ val lines = execOperations .execShell(
22
24
" git" ,
23
25
" diff" ,
24
26
" --color=never" ,
Original file line number Diff line number Diff line change @@ -10,10 +10,15 @@ import com.datadog.gradle.plugin.CheckGeneratedFileTask
10
10
import org.gradle.api.tasks.InputFile
11
11
import org.gradle.api.tasks.InputFiles
12
12
import org.gradle.api.tasks.TaskAction
13
+ import org.gradle.process.ExecOperations
13
14
import java.io.File
15
+ import javax.inject.Inject
14
16
15
- open class CheckApiSurfaceTask : CheckGeneratedFileTask (
16
- genTaskName = ApiSurfacePlugin .TASK_GEN_KOTLIN_API_SURFACE
17
+ open class CheckApiSurfaceTask @Inject constructor(
18
+ execOperations : ExecOperations
19
+ ) : CheckGeneratedFileTask(
20
+ genTaskName = ApiSurfacePlugin .TASK_GEN_KOTLIN_API_SURFACE ,
21
+ execOperations
17
22
) {
18
23
19
24
@InputFile
Original file line number Diff line number Diff line change @@ -10,10 +10,14 @@ import com.datadog.gradle.utils.execShell
10
10
import org.gradle.api.DefaultTask
11
11
import org.gradle.api.tasks.Input
12
12
import org.gradle.api.tasks.TaskAction
13
+ import org.gradle.process.ExecOperations
13
14
import java.io.File
14
15
import java.nio.file.Files.createTempDirectory
16
+ import javax.inject.Inject
15
17
16
- open class GitCloneDependenciesTask : DefaultTask () {
18
+ open class GitCloneDependenciesTask @Inject constructor(
19
+ private val execOperations : ExecOperations
20
+ ) : DefaultTask() {
17
21
18
22
@get: Input
19
23
var extension: GitCloneDependenciesExtension =
@@ -60,7 +64,7 @@ open class GitCloneDependenciesTask : DefaultTask() {
60
64
target : File
61
65
) {
62
66
println (" --- Cloning ${dependency.originRepository} into ${target.absolutePath} " )
63
- project .execShell(
67
+ execOperations .execShell(
64
68
" git" ,
65
69
" clone" ,
66
70
" --branch" ,
@@ -135,7 +139,7 @@ open class GitCloneDependenciesTask : DefaultTask() {
135
139
136
140
private fun deleteClone (target : File ) {
137
141
println (" --- Deleting temp folder ${target.absolutePath} " )
138
- project .execShell(" rm" , " -r" , target.absolutePath)
142
+ execOperations .execShell(" rm" , " -r" , target.absolutePath)
139
143
println (" --- Deleted" )
140
144
}
141
145
Original file line number Diff line number Diff line change @@ -9,10 +9,15 @@ package com.datadog.gradle.plugin.transdeps
9
9
import com.datadog.gradle.plugin.CheckGeneratedFileTask
10
10
import org.gradle.api.tasks.InputFile
11
11
import org.gradle.api.tasks.TaskAction
12
+ import org.gradle.process.ExecOperations
12
13
import java.io.File
14
+ import javax.inject.Inject
13
15
14
- open class CheckTransitiveDependenciesTask : CheckGeneratedFileTask (
15
- genTaskName = TransitiveDependenciesPlugin .TASK_GEN_TRANSITIVE_DEPS
16
+ open class CheckTransitiveDependenciesTask @Inject constructor(
17
+ execOperations : ExecOperations
18
+ ) : CheckGeneratedFileTask(
19
+ genTaskName = TransitiveDependenciesPlugin .TASK_GEN_TRANSITIVE_DEPS ,
20
+ execOperations
16
21
) {
17
22
18
23
@InputFile
Original file line number Diff line number Diff line change 6
6
7
7
package com.datadog.gradle.utils
8
8
9
- import org.gradle.api.Project
9
+ import org.gradle.process.ExecOperations
10
10
import java.io.ByteArrayInputStream
11
11
import java.io.ByteArrayOutputStream
12
12
import java.io.InputStreamReader
13
13
14
- fun Project .execShell (vararg command : String ): List <String > {
14
+ fun ExecOperations .execShell (vararg command : String ): List <String > {
15
15
val outputStream = ByteArrayOutputStream ()
16
- this . exec {
16
+ exec {
17
17
commandLine(* command)
18
18
standardOutput = outputStream
19
19
}
You can’t perform that action at this time.
0 commit comments