-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
84 lines (68 loc) · 2.54 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
// This file controls gradle, which we are using to install and update the RLBot framework used by this example bot,
// and also compile and run the java code used by this bot.
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 1.8
repositories {
jcenter()
}
mainClassName = 'rlbotexample.JavaExample'
// This directory will be created and the interface dll copied into it at runtime.
// The end result is that the interface dll will be available for loading.
def dllDirectory = 'build/dll'
applicationDefaultJvmArgs = ["-Djna.library.path=" + dllDirectory]
dependencies {
// Fetch the framework jar file
compile 'org.rlbot.commons:framework:1.+'
// This is makes it easy to find the dll when running in intellij, where JVM args don't get passed from gradle.
runtime files(dllDirectory)
}
task checkPipUpgradeSafety {
doLast {
new ByteArrayOutputStream().withStream { os ->
def exitValue = exec {
commandLine "python", "-c", "from rlbot.utils import public_utils; print(public_utils.is_safe_to_upgrade());"
standardOutput = os
ignoreExitValue = true
}.exitValue
// If the exit value is nonzero, the command probably failed because rlbot is not installed at all.
ext.isSafe = exitValue != 0 || os.toString().trim() == "True"
}
}
}
// Uses pip (the python package manager) to install all the python packages needed for this bot, as defined
// in requirements.txt.
task pipInstallRequirements {
dependsOn 'checkPipUpgradeSafety'
doLast {
if (checkPipUpgradeSafety.isSafe) {
exec {
commandLine "python", "-m", "pip", "install", "-r", "requirements.txt", "--upgrade"
}
} else {
println 'Skipping upgrade attempt because files are in use.'
}
}
}
task createDllDirectory {
mkdir dllDirectory
}
// Installs or updates RLBot. Empty task for now. It still does stuff because it "dependsOn" tasks that do things.
task updateRLBot {
dependsOn 'pipInstallRequirements'
dependsOn 'createDllDirectory'
}
updateRLBot.dependsOn pipInstallRequirements
applicationDistribution.exclude(dllDirectory)
// You can run gradew.bat distZip to generate a zip file suitable for tournament submissions.
// It will be generated in build/distributions
distZip {
into ('python') {
from fileTree('src/main/python') {
exclude '__pycache__'
}
}
into (applicationName + '/bin') {
from fileTree('port.cfg')
}
}