-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
109 lines (100 loc) · 3.01 KB
/
build.gradle.kts
File metadata and controls
109 lines (100 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
val kotlinLoggingVersion: String? by rootProject
val utbotExecutorVersion = File(project.projectDir, "src/main/resources/utbot_executor_version").readText()
// these two properties --- from GRADLE_USER_HOME/gradle.properties
val pypiToken: String? by project
val pythonInterpreter: String? by project
val utbotExecutorPath = File(project.projectDir, "src/main/python/utbot_executor")
val localUtbotExecutorPath = File(utbotExecutorPath, "dist")
tasks.register("cleanDist") {
group = "python"
delete(localUtbotExecutorPath.canonicalPath)
}
val installPoetry =
if (pythonInterpreter != null) {
tasks.register<Exec>("installPoetry") {
group = "python"
workingDir = utbotExecutorPath
commandLine(pythonInterpreter, "-m", "pip", "install", "poetry")
}
} else {
null
}
val setExecutorVersion =
if (pythonInterpreter != null) {
tasks.register<Exec>("setVersion") {
dependsOn(installPoetry!!)
group = "python"
workingDir = utbotExecutorPath
commandLine(pythonInterpreter, "-m", "poetry", "version", utbotExecutorVersion)
}
} else {
null
}
val buildExecutor =
if (pythonInterpreter != null) {
tasks.register<Exec>("buildUtbotExecutor") {
dependsOn(setExecutorVersion!!)
group = "python"
workingDir = utbotExecutorPath
commandLine(pythonInterpreter, "-m", "poetry", "build")
}
} else {
null
}
if (pythonInterpreter != null && pypiToken != null) {
tasks.register<Exec>("publishUtbotExecutor") {
dependsOn(buildExecutor!!)
group = "python"
workingDir = utbotExecutorPath
commandLine(
pythonInterpreter,
"-m",
"poetry",
"publish",
"-u",
"__token__",
"-p",
pypiToken
)
}
}
val installExecutor =
if (pythonInterpreter != null) {
tasks.register<Exec>("installUtbotExecutor") {
dependsOn(buildExecutor!!)
group = "python"
environment("PIP_FIND_LINKS" to localUtbotExecutorPath.canonicalPath)
commandLine(
pythonInterpreter,
"-m",
"pip",
"install",
"utbot_executor==$utbotExecutorVersion"
)
}
} else {
null
}
val installPytest =
if (pythonInterpreter != null) {
tasks.register<Exec>("installPytest") {
group = "pytest"
workingDir = utbotExecutorPath
commandLine(pythonInterpreter, "-m", "pip", "install", "pytest")
}
} else {
null
}
if (pythonInterpreter != null) {
tasks.register<Exec>("runTests") {
dependsOn(installExecutor!!)
dependsOn(installPytest!!)
group = "pytest"
workingDir = utbotExecutorPath
commandLine(
pythonInterpreter,
"-m",
"pytest",
)
}
}