-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
106 lines (77 loc) · 3.05 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
import org.apache.tools.ant.taskdefs.condition.Os
import java.nio.file.Paths
final String GOSU_HOME = Paths.get(project.buildDir.absolutePath, 'gosu', 'gosu-' + project.gosuVersion)
final String LF = System.getProperty("line.separator")
//check java version at initialization time
def javaVersion = Double.valueOf(System.getProperty('java.specification.version'))
if(javaVersion < Double.valueOf((String) project.minimumJavaVersion)) {
throw new InvalidUserDataException("Java version $project.minimumJavaVersion or higher is required, exiting") //effectively exits the script
} else {
println "Java version $project.minimumJavaVersion or later was found."
}
repositories {
mavenLocal()
mavenCentral()
}
configurations {
gosu
}
String gosuFullDistroNotation = "org.gosu-lang.gosu:gosu:$project.gosuVersion:full@zip"
dependencies {
gosu gosuFullDistroNotation
}
task extractGosu(type: Sync) {
from project.zipTree(project.configurations.getByName('gosu').singleFile)
into "$project.buildDir/gosu"
}
task inlineScript(type: GosuCommandLineTask, dependsOn: extractGosu) {
description = 'Run an inline script from the commandline'
gosuHome = GOSU_HOME
commandLine = ['-e', """print('Hello world')"""]
String expectedOutput = 'Hello world' + LF
doLast {
assert expectedOutput.equals(standardOutput.toString())
}
}
task simpleGosuProgram(type: GosuCommandLineTask, dependsOn: extractGosu) {
description = 'Run a simple Gosu Program with no dependencies or arguments'
gosuHome = GOSU_HOME
commandLine = ['simple/HelloWorld.gsp']
String expectedOutput = 'hello' + LF
doLast {
assert expectedOutput.equals(standardOutput.toString())
}
}
task gosuProgramWithArgs(type: GosuCommandLineTask, dependsOn: extractGosu) {
description = 'Run a simple Gosu Program with arguments'
gosuHome = GOSU_HOME
commandLine = ['simple/HelloWorldWithArgs.gsp', 'foo', 'bar', '\"baz\"', '42', 'Acceptable']
// Groovy's """ operator appends LF-only, not CRLF
String expectedOutput = 'hello, I found these arguments:' + LF +
'\tfoo' + LF +
'\tbar' + LF +
'\tbaz' + LF +
'\t42' + LF +
'\tAcceptable' + LF
doLast {
assert expectedOutput.equals(standardOutput.toString())
}
}
task gosuProgramWithImports(type: GosuCommandLineTask, dependsOn: extractGosu) {
description = 'Run a Gosu Program which imports other classes'
gosuHome = GOSU_HOME
commandLine = ['imports/RunFoo.gsp']
String expectedOutput = "baz" + LF
doLast {
assert expectedOutput.equals(standardOutput.toString())
}
}
task gosuProgramWithClasspath(type: GosuCommandLineTask, dependsOn: extractGosu) {
description = 'Run a simple Gosu Program with a classpath argument'
gosuHome = GOSU_HOME
commandLine = ['-classpath', '\"lib/commons-math-2.2.jar\"', 'externalDeps/Exponents.gsp']
String expectedOutput = "9 to the power of 3 is: 729" + LF
doLast {
assert expectedOutput.equals(standardOutput.toString())
}
}