1
1
package build
2
2
3
3
import org.gradle.api.Project
4
- import org.gradle.api.Task
5
4
import org.gradle.api.tasks.Exec
6
5
import org.gradle.api.tasks.InputFile
6
+ import org.gradle.kotlin.dsl.getByType
7
7
import java.nio.file.Path
8
8
9
- interface DistribOptions {
10
- val isOnProtectedBranch: Boolean
11
- val cleanInstallDirDistrib: Task
12
-
13
- val condaGroup: String
14
- val pyPiGroup: String
15
- val buildGroup: String
16
-
17
- val condaTaskSpecs: UploadTaskSpecs <CondaTaskSpec >
18
- val pyPiTaskSpecs: UploadTaskSpecs <PyPiTaskSpec >
19
-
20
- val distribKernelDir: String
21
- val distributionPath: Path
22
-
23
- val distribUtilsPath: Path
24
- val distribUtilRequirementsPath: Path
25
- val distribUtilRequirementsHintsRemPath: Path
26
- val removeTypeHints: Boolean
27
- val typeHintsRemover: Path
28
- }
29
-
30
- interface ProjectWithDistribOptions : Project , DistribOptions
31
-
32
9
open class TaskSpec (
33
10
var taskName : String = " "
34
11
)
35
12
36
- interface DistributionPackageSettings {
37
- val dir: String
38
- val fileName: String
39
- }
13
+ class DistributionPackageSettings (val dir : String , val fileName : String )
40
14
41
15
class UploadTaskSpecs <T : TaskSpec >(
42
16
val packageSettings : DistributionPackageSettings ,
@@ -52,19 +26,18 @@ class UploadTaskSpecs <T : TaskSpec>(
52
26
53
27
private fun taskName (type : String ) = repoName + " Upload" + type
54
28
55
- fun createTasks (project : ProjectWithDistribOptions , taskCreationAction : (T ) -> Unit ) {
56
- with ( project) {
57
- if (isOnProtectedBranch) {
58
- taskCreationAction(stable)
59
- }
60
- taskCreationAction(dev)
29
+ fun createTasks (project : Project , taskCreationAction : (T ) -> Unit ) {
30
+ val opts = project.extensions.getByType< KernelBuildExtension >()
31
+ if (opts. isOnProtectedBranch) {
32
+ taskCreationAction(stable)
33
+ }
34
+ taskCreationAction(dev)
61
35
62
- project.task(taskName(" Protected" )) {
63
- dependsOn(cleanInstallDirDistrib)
64
- group = taskGroup
65
- if (isOnProtectedBranch) {
66
- dependsOn(dev.taskName)
67
- }
36
+ project.task(taskName(" Protected" )) {
37
+ dependsOn(opts.cleanInstallDirDistrib)
38
+ group = taskGroup
39
+ if (opts.isOnProtectedBranch) {
40
+ dependsOn(dev.taskName)
68
41
}
69
42
}
70
43
}
0 commit comments