-
Notifications
You must be signed in to change notification settings - Fork 153
/
build.gradle
189 lines (167 loc) · 5.95 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
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'idea'
apply plugin: 'scala'
// We compile using Java 7.
sourceCompatibility = 1.7
targetCompatibility = 1.7
/*
* For now, instead of using an online library repository (e.g. Maven), we keep
* local versions of .jars to reduce the number of things that can go wrong
* during setup.
*/
dependencies {
compile 'org.scala-lang:scala-library:2.11.7'
compile files(
'lib/Guava/guava-14.0.1.jar',
'lib/Jython/jython.jar',
'lib/Clojure/clojure.jar',
'lib/Batik/batik-1.7.jar',
'lib/FlyingSaucer/core-renderer.jar',
'lib/javassist/javassist.jar',
'lib/reflections/reflections-0.9.9-RC1.jar',
'lib/Htmlparser/htmlparser-1.4.jar',
'lib/gdl-validation/gdl-validation-0.2.2.jar',
'lib/gdl-validation/java-cup-11b-runtime-2015.03.26.jar',
)
testCompile files(
'lib/JUnit/junit-4.11.jar',
'lib/JUnit/hamcrest-core-1.3.jar',
)
}
//Checkstyle does need a repository to be defined to work. This is only
//required to check that the code works from the command line, not to run
//applications from the command line.
repositories {
mavenCentral()
}
/*
* Source jars can be specified here so the sources for these libraries will
* appear in Eclipse.
*/
def sourceJars = [
'lib/Guava/guava-14.0.1.jar' : 'lib/Guava/guava-14.0.1-sources.jar',
'lib/gdl-validation/gdl-validation-0.2.2.jar' : 'lib/gdl-validation/gdl-validation-0.2.2-sources.jar'
];
/*
* Unfortunately, the local-jar approach causes problems when generating a
* .classpath file for Eclipse. This will generate dependency entries that use
* absolute, rather than relative paths, and so can't be committed. To make sure
* committing contributions to the codebase also remains relatively easy, we
* apply a hack here to use relative addresses.
*
* This hasn't been tested in Windows yet; that might need special treatment if
* it tries to use absolute paths with backslashes.
*/
eclipse {
classpath {
file {
withXml {
def node = it.asNode()
for (classpathEntry in node) {
if (classpathEntry.attribute('kind') == 'lib') {
def absolutePath = classpathEntry.attribute('path')
if (absolutePath.contains('/lib/')) {
def startIndex = absolutePath.indexOf('/lib/') + 1
def relativePath = absolutePath.substring(startIndex)
classpathEntry.attributes().put('path', relativePath)
}
//Add source jars to .classpath
def path = classpathEntry.attribute('path')
if (sourceJars.containsKey(path)) {
def sourceJarPath = sourceJars.get(path)
classpathEntry.attributes().put('sourcepath', sourceJarPath)
}
}
}
}
}
}
}
/*
* It's convenient when working in Eclipse to have a test suite containing
* all available tests. However, Gradle normally runs every test it can find
* automatically, which would cause all tests to be run twice. This bit of
* configuration prevents that from happening; Gradle just runs the test suite
* instead.
*/
test {
include 'org/ggp/base/test/AllTests.class'
}
//Various applications that can be run from Gradle:
//Note: The clojureConsole task should be run with the -q flag to quiet Gradle's normal output.
task clojureConsole(type: JavaExec) {
main = 'org.ggp.base.apps.consoles.ClojureConsole'
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
}
task pythonConsole(type: JavaExec) {
doFirst {
println classpath.getAsPath()
}
main = 'org.ggp.base.apps.consoles.PythonConsole'
classpath = sourceSets.main.runtimeClasspath
}
/* Not working, no main method found (ant doesn't work in Ant either):
task clojureGamer(type: JavaExec) {
main='org.ggp.base.player.gamer.clojure.ClojureGamer'
classpath = sourceSets.main.runtimeClasspath
}
*/
//You can tweak these JVM arguments for players run through Gradle.
def playerJvmArgs = [
'-Xmx1500m', //Gives players a max heap size of 1500 MB
'-server',
'-XX:-DontCompileHugeMethods',
'-XX:MinHeapFreeRatio=10',
'-XX:MaxHeapFreeRatio=10']
//See playerRunner.sh
task playerRunner(type: JavaExec) {
main = 'org.ggp.base.apps.player.PlayerRunner'
classpath = sourceSets.main.runtimeClasspath
//These can be set on the command line with
//-Pport=9147 and -Pgamer=RandomGamer as arguments.
doFirst {
args = [port, gamer]
}
jvmArgs = playerJvmArgs
}
task kiosk(type: JavaExec) {
main = 'org.ggp.base.apps.kiosk.Kiosk'
classpath = sourceSets.main.runtimeClasspath
jvmArgs = playerJvmArgs
}
task server(type: JavaExec) {
main = 'org.ggp.base.apps.server.Server'
classpath = sourceSets.main.runtimeClasspath
}
task simpleGameSim(type: JavaExec) {
main = 'org.ggp.base.apps.utilities.SimpleGameSim'
classpath = sourceSets.main.runtimeClasspath
}
task tiltyardRequestFarm(type: JavaExec) {
main = 'org.ggp.base.apps.tiltyard.TiltyardRequestFarm'
classpath = sourceSets.main.runtimeClasspath
}
task player(type: JavaExec) {
main = 'org.ggp.base.apps.player.Player'
classpath = sourceSets.main.runtimeClasspath
jvmArgs = playerJvmArgs
}
task propNetAnnotater(type: JavaExec) {
main = 'org.ggp.base.util.propnet.factory.annotater.PropNetAnnotater'
classpath = sourceSets.main.runtimeClasspath
}
//See gameServerRunner.sh
task gameServerRunner(type: JavaExec) {
main = 'org.ggp.base.apps.utilities.GameServerRunner'
classpath = sourceSets.main.runtimeClasspath
doFirst {
args = myargs.split().toList()
}
}
// This was used to generate the Gradle wrapper.
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}