-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathbuild.gradle
307 lines (256 loc) · 10.6 KB
/
build.gradle
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
plugins {
id 'com.jetbrains.rdgen' version "2023.1.2"
}
import com.jetbrains.rd.generator.gradle.RdGenExtension
import com.jetbrains.rd.generator.gradle.RdGenTask
if (includeRiderInBuild.toBoolean()) {
def utbotRider = project.rootProject.childProjects["utbot-rider"]
evaluationDependsOn(utbotRider.path)
tasks.getByName("classes").dependsOn(utbotRider.tasks.getByName("addRiderModelsToUtbotModels"))
}
compileKotlin {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
configurations {
lifetimedProcessMockCompileClasspath.extendsFrom configurations.compileClasspath
processWithRdServerMockCompileClasspath.extendsFrom configurations.compileClasspath
rdgenModelsCompileClasspath.extendsFrom configurations.compileClasspath
if (includeRiderInBuild.toBoolean())
riderRdgenModelsCompileClasspath.extendsFrom configurations.rdgenModelsCompileClasspath
}
sourceSets {
lifetimedProcessMock {
kotlin {
srcDirs = ["src/main/lifetimedProcessMock"]
}
}
processWithRdServerMock {
kotlin {
srcDirs = ["src/main/processWithRdServerMock"]
}
}
rdgenModels {
kotlin {
srcDirs = ["src/main/rdgen"]
}
}
if (includeRiderInBuild.toBoolean()) {
riderRdgenModels {
kotlin {
srcDirs = ["src/main/riderRdgenModels"]
}
}
}
}
def riderModelJar = new File(project.buildDir, "libs/rider-model.jar")
dependencies {
implementation project(':utbot-core')
implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: rdVersion
implementation group: 'com.jetbrains.rd', name: 'rd-core', version: rdVersion
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlinLoggingVersion
processWithRdServerMockImplementation project(':utbot-rd')
rdgenModelsCompileClasspath group: 'com.jetbrains.rd', name: 'rd-gen', version: rdVersion
if (includeRiderInBuild.toBoolean()) {
riderRdgenModelsCompileClasspath files(riderModelJar)
}
}
task lifetimedProcessMockJar(type: Jar) {
dependsOn lifetimedProcessMockClasses
archiveAppendix.set("lifetimedProcessMock")
manifest {
attributes(
'Main-Class': 'org.utbot.rd.tests.LifetimedProcessMockKt'
)
}
from configurations.lifetimedProcessMockCompileClasspath.collect {
(it.isDirectory() || !it.exists()) ? it : zipTree(it)
} + sourceSets.lifetimedProcessMock.output
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
task processWithRdServerMockJar(type: Jar) {
dependsOn processWithRdServerMockClasses
archiveAppendix.set("processWithRdServerMock")
manifest {
attributes(
'Main-Class': 'org.utbot.rd.tests.ProcessWithRdServerMockKt'
)
}
from configurations.processWithRdServerMockCompileClasspath.collect {
(it.isDirectory() || !it.exists()) ? it : zipTree(it)
} + sourceSets.processWithRdServerMock.output
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
test {
dependsOn lifetimedProcessMockJar
dependsOn processWithRdServerMockJar
systemProperty("RD_MOCK_PROCESS", lifetimedProcessMockJar.archiveFile.get().getAsFile().canonicalPath)
systemProperty("PROCESS_WITH_RD_SERVER_MOCK", processWithRdServerMockJar.archiveFile.get().getAsFile().canonicalPath)
}
if (includeRiderInBuild.toBoolean()) {
def currentProjectDir = project.projectDir
def riderProject = project.rootProject.childProjects["utbot-rider"]
def riderTask = riderProject.tasks.getByName("addRiderModelsToUtbotModels")
// !!!! IMPORTANT !!!!
// after generation you should MANUALLY correct kotlin generated code as it is incorrectly references some rider model
// mandatory steps:
// 1. In UtBotRiderModel.Generated.kt change package to `package org.utbot.rider.generated`
// 2. then import all unreferenced classes
// otherwise you will have broken plugin initialization and ClassNotFoundException
task generateRiderModels(type: RdGenTask) {
dependsOn(riderTask)
def riderProjectDir = riderProject.projectDir
def generatedOutputDir = new File(riderProjectDir, "src/main/kotlin/org/utbot/rider/generated")
def hashDir = generatedOutputDir
def sourcesDir = new File(currentProjectDir, "src/main/riderRdgenModels/org/utbot/rider/rd/models")
def rdParams = extensions.getByName("params") as RdGenExtension
group = "rdgen"
rdParams.verbose = true
rdParams.sources(sourcesDir)
rdParams.hashFolder = hashDir.canonicalPath
rdParams.packages = "org.utbot.rider.rd.models"
rdParams.classpath(riderModelJar)
rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "com.jetbrains.rider.model.nova.ide.IdeRoot"
directory = generatedOutputDir.canonicalPath
namespace = "org.utbot.rider.generated"
}
rdParams.generator {
language = "csharp"
transform = "symmetric"
root = "com.jetbrains.rider.model.nova.ide.IdeRoot"
namespace = "UtBot"
directory = new File(riderProjectDir, "src/dotnet/UtBot/UtBot/Generated")
}
}
}
task generateInstrumentedProcessModels(type: RdGenTask) {
def currentProjectDir = project.projectDir
def instrumentationProjectDir = project.rootProject.childProjects["utbot-instrumentation"].projectDir
def generatedOutputDir = new File(instrumentationProjectDir, "src/main/kotlin/org/utbot/instrumentation/rd/generated")
def hashDir = generatedOutputDir
def sourcesDir = new File(currentProjectDir, "src/main/rdgen/org/utbot/rd/models")
def rdParams = extensions.getByName("params") as RdGenExtension
group = "rdgen"
rdParams.verbose = true
rdParams.sources(sourcesDir)
rdParams.hashFolder = hashDir.canonicalPath
// where to search roots
rdParams.packages = "org.utbot.rd.models"
rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.utbot.rd.models.InstrumentedProcessRoot"
directory = generatedOutputDir.canonicalPath
namespace = "org.utbot.instrumentation.process.generated"
}
}
task generateEngineProcessModels(type: RdGenTask) {
def currentProjectDir = project.projectDir
def ideaPluginProjectDir = project.rootProject.childProjects["utbot-framework"].projectDir
def generatedOutputDir = new File(ideaPluginProjectDir, "src/main/kotlin/org/utbot/framework/process/generated")
def hashDir = generatedOutputDir
def sourcesDir = new File(currentProjectDir, "src/main/rdgen/org/utbot/rd/models")
def rdParams = extensions.getByName("params") as RdGenExtension
group = "rdgen"
rdParams.verbose = true
rdParams.sources(sourcesDir)
rdParams.hashFolder = hashDir.canonicalPath
// where to search roots
rdParams.packages = "org.utbot.rd.models"
rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.utbot.rd.models.EngineProcessRoot"
directory = generatedOutputDir.canonicalPath
namespace = "org.utbot.framework.process.generated"
}
}
task generateCommonModels(type: RdGenTask) {
def currentProjectDir = project.projectDir
def ideaPluginProjectDir = project.rootProject.childProjects["utbot-rd"].projectDir
def generatedOutputDir = new File(ideaPluginProjectDir, "src/main/kotlin/org/utbot/rd/generated")
def hashDir = generatedOutputDir
def sourcesDir = new File(currentProjectDir, "src/main/rdgen/org/utbot/rd/models")
def rdParams = extensions.getByName("params") as RdGenExtension
group = "rdgen"
rdParams.verbose = true
rdParams.sources(sourcesDir)
rdParams.hashFolder = hashDir.canonicalPath
// where to search roots
rdParams.packages = "org.utbot.rd.models"
rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.utbot.rd.models.SynchronizationRoot"
directory = generatedOutputDir.canonicalPath
namespace = "org.utbot.rd.generated"
}
rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.utbot.rd.models.SettingsRoot"
directory = generatedOutputDir.canonicalPath
namespace = "org.utbot.rd.generated"
}
rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.utbot.rd.models.LoggerRoot"
directory = generatedOutputDir.canonicalPath
namespace = "org.utbot.rd.generated"
}
}
task generateSpringModels(type: RdGenTask) {
def currentProjectDir = project.projectDir
def ideaPluginProjectDir = project.rootProject.childProjects["utbot-spring-analyzer"].projectDir
def generatedOutputDir = new File(ideaPluginProjectDir, "src/main/kotlin/org/utbot/spring/generated")
def hashDir = generatedOutputDir
def sourcesDir = new File(currentProjectDir, "src/main/rdgen/org/utbot/rd/models")
def rdParams = extensions.getByName("params") as RdGenExtension
group = "rdgen"
rdParams.verbose = true
rdParams.sources(sourcesDir)
rdParams.hashFolder = hashDir.canonicalPath
// where to search roots
rdParams.packages = "org.utbot.rd.models"
rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.utbot.rd.models.SpringAnalyzerRoot"
directory = generatedOutputDir.canonicalPath
namespace = "org.utbot.spring.generated"
}
}
task generateCSharpModels(type: RdGenTask) {
def currentProjectDir = project.projectDir
def riderPluginProjectDir = project.rootProject.projectDir.toPath().resolve("utbot-rider").toFile()
def generatedOutputDir = new File (riderPluginProjectDir, "src/dotnet/UtBot/UtBot.Rd/Generated")
def hashDir = generatedOutputDir
def sourcesDir = new File(currentProjectDir, "src/main/rdgen/org/utbot/rd/models")
def rdParams = extensions.getByName("params") as RdGenExtension
group = "rdgen"
rdParams.verbose = true
rdParams.sources(sourcesDir)
rdParams.hashFolder = hashDir.canonicalPath
rdParams.packages = "org.utbot.rd.models"
rdParams.generator {
language = "csharp"
transform = "symmetric"
root = "org.utbot.rd.models.CSharpRoot"
directory = generatedOutputDir.canonicalPath
namespace = "UtBot.Rd.Generated"
}
}