forked from protop-io/protop-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctional-test.gradle
59 lines (45 loc) · 1.4 KB
/
functional-test.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
facets {
functionalTest {
parentSourceSet = 'test'
}
}
compileFunctionalTestJava {
options.compilerArgs += ['--enable-preview']
}
final envProtopHome = System.getenv('PROTOP_HOME')
final defaultProtopHome = "${buildDir}/protop" as String
final protopHome = envProtopHome ?: defaultProtopHome
final shouldUseLocalProtopExecutable = (protopHome == defaultProtopHome)
functionalTest {
dependsOn ':createProtopExecutable'
jvmArgs += ['--enable-preview']
environment 'PROTOP_HOME', protopHome
doFirst {
println "`:functionalTest` using `${protopHome}/bin/protop`." +
(shouldUseLocalProtopExecutable
? ' Set `PROTOP_HOME` to override.'
: '')
}
}
task createProtopExecutable {
final protopSubmodule = gradle.includedBuild('protop')
onlyIf {
shouldUseLocalProtopExecutable
}
if (shouldUseLocalProtopExecutable) {
dependsOn protopSubmodule.task(':distFatJar')
}
final outputFile = file("${defaultProtopHome}/bin/protop")
inputs.files file("${protopSubmodule.projectDir}/build/libs/protop.jar")
outputs.file outputFile
doFirst {
mkdir outputFile.getParent()
}
doLast {
outputFile.text = '#!/bin/bash\n'
outputFile.append('exec java -jar "$0" "$@"\n')
outputFile.append(inputs.files.first().readBytes())
outputFile.setExecutable(true)
println "`:createProtopExecutable` built ${[outputFile, '-v'].execute().text}"
}
}