@@ -3,36 +3,45 @@ package org.junit.gradle.java
3
3
import javaModuleName
4
4
import org.gradle.api.Named
5
5
import org.gradle.api.Project
6
+ import org.gradle.api.file.ConfigurableFileCollection
6
7
import org.gradle.api.file.FileCollection
8
+ import org.gradle.api.provider.Property
7
9
import org.gradle.api.provider.Provider
8
10
import org.gradle.api.tasks.*
9
11
import org.gradle.kotlin.dsl.get
10
12
import org.gradle.kotlin.dsl.the
11
13
import org.gradle.process.CommandLineArgumentProvider
14
+ import javax.inject.Inject
12
15
13
- class PatchModuleArgumentProvider (compiledProject : Project , patchModuleProject : Project ) : CommandLineArgumentProvider,
14
- Named {
16
+ abstract class PatchModuleArgumentProvider @Inject constructor (compiledProject : Project , patchModuleProject : Project ) :
17
+ CommandLineArgumentProvider , Named {
15
18
16
- @get:Input
17
- val module: String = patchModuleProject.javaModuleName
19
+ @get:Input
20
+ abstract val module: Property < String >
18
21
19
- @get:InputFiles
20
- @get:PathSensitive(PathSensitivity .RELATIVE )
21
- val patch: Provider <FileCollection > = compiledProject.provider {
22
- if (patchModuleProject == compiledProject)
23
- compiledProject.files(compiledProject.the<SourceSetContainer >().matching { it.name.startsWith(" main" ) }.map { it.output })
24
- else
25
- patchModuleProject.files(patchModuleProject.the<SourceSetContainer >()[" main" ].java.srcDirs)
26
- }
22
+ @get:InputFiles
23
+ @get:PathSensitive(PathSensitivity .RELATIVE )
24
+ abstract val patch: ConfigurableFileCollection
27
25
28
- override fun asArguments (): List <String > {
29
- val path = patch.get().filter { it.exists() }.asPath
30
- if (path.isEmpty()) {
31
- return emptyList()
32
- }
33
- return listOf (" --patch-module" , " $module =$path " )
34
- }
26
+ init {
27
+ module.convention(patchModuleProject.javaModuleName)
28
+ patch.from(compiledProject.provider {
29
+ if (patchModuleProject == compiledProject)
30
+ compiledProject.files(compiledProject.the<SourceSetContainer >().matching { it.name.startsWith(" main" ) }
31
+ .map { it.output })
32
+ else
33
+ patchModuleProject.files(patchModuleProject.the<SourceSetContainer >()[" main" ].java.srcDirs)
34
+ })
35
+ }
35
36
36
- @Internal
37
- override fun getName () = " patch-module($module )"
37
+ override fun asArguments (): List <String > {
38
+ val path = patch.filter { it.exists() }.asPath
39
+ if (path.isEmpty()) {
40
+ return emptyList()
41
+ }
42
+ return listOf (" --patch-module" , " ${module.get()} =$path " )
43
+ }
44
+
45
+ @Internal
46
+ override fun getName () = " patch-module(${module.get()} )"
38
47
}
0 commit comments