forked from RLBot/RLBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
192 lines (160 loc) · 6.4 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
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
}
}
plugins {
id "com.jfrog.bintray" version "1.8.4"
}
apply plugin: 'java' // This is the backbone of the gradle build process, we don't just use it for java files.
apply plugin: 'maven-publish' // Needed for publishing to bintray.
repositories {
jcenter()
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
def javaDllDir = 'build/dll'
dependencies {
compile group: 'net.java.dev.jna', name: 'jna', version: '4.5.1' // Allows the java bot manager to communicate with dll
compile group: 'net.java.dev.jna', name: 'jna-platform', version: '4.5.1' // Allows the java bot manager to communicate with dll
compile group: 'net.sf.py4j', name: 'py4j', version: '0.10.6' // Allows the java bot manager to accept commands from python.
compile 'com.github.davidmoten:flatbuffers-java:1.9.0.1' // Temporarily using this guy's flatbuffers package because the official one is behind.
// This is handy for running the test without needing to supply jna.library.path.
testRuntime files(javaDllDir)
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}
project.setGroup('org.rlbot.commons')
project.setVersion('1.11.0')
def pythonRoot = './src/main/python/'
sourceSets {
main {
java {
// This is the default location where java protobuf classes are generated
srcDirs = ['src/main/java', 'src/generated/java/flatbuffers']
}
}
}
// After flatbuffers are generated, copy the generated file to its home in the python folder.
task copyFlatbuffersPython(type: Copy) {
dependsOn 'generateFlatbuffersPython'
from fileTree('src/generated/python/flatbuffers/rlbot')
into pythonRoot + 'rlbot/messages'
}
def flatbufDir = "./src/main/flatbuffers/"
task generateFlatbuffersJava(type: Exec) {
commandLine flatbufDir + "flatc.exe", "--java", "-o", "./src/generated/java/flatbuffers", flatbufDir + "rlbot.fbs"
}
task generateFlatbuffersPython(type: Exec) {
commandLine flatbufDir + "flatc.exe", "--python", "-o", "./src/generated/python/flatbuffers", flatbufDir + "rlbot.fbs"
}
task generateFlatbuffersCpp(type: Exec) {
commandLine flatbufDir + "flatc.exe", "--cpp", "-o", "./src/generated/cpp/flatbuffers", flatbufDir + "rlbot.fbs"
}
// You can use the clean task to remove build output.
clean {
// In addition to the normal clean behavior, also remove the generated flatbuffer file(s).
delete pythonRoot + 'rlbot/messages/flat'
delete 'src/generated'
}
// Establish some task dependencies so that some tasks always run before others.
compileJava.dependsOn generateFlatbuffersJava
task pythonSetup {
dependsOn 'copyFlatbuffersPython'
dependsOn 'pipInstallRequirements'
}
task cppSetup {
dependsOn 'generateFlatbuffersCpp'
}
task createJavaDllFolder {
mkdir javaDllDir
}
task javaSetup {
dependsOn 'generateFlatbuffersJava'
dependsOn 'createJavaDllFolder'
}
// This task creates a jar file which contains the java source files.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
// Parses a .gitignore file and attempts to build a list of file paths that can be used by gradle.
def gitignoreToList(File f) {
def ignores = []
f.eachLine { line ->
//ignore comments and empty lines
if (!line.startsWith('#') && !line.isEmpty()) {
ignores.add(line)
}
}
return ignores
}
def pythonDistStaging = './build/python-dist/'
// Creates a folder with the right structure for publishing to the python package index (PyPI).
// https://packaging.python.org/tutorials/packaging-projects/
task pythonPackageIndexFolder(type: Sync, dependsOn: copyFlatbuffersPython) {
from(fileTree(pythonRoot)) // Grab all the files in the src/main/python folder and add them to the package folder
from 'LICENSE.txt' // Also grab the license
exclude gitignoreToList(file('.gitignore')) // Avoid putting any git-ignored files in the zip
exclude '**/__pycache__' // Explicitly exclude __pycache__ folders because the gitignoreToList trick doesn't cover this
into(pythonDistStaging)
}
// Use pip, which is the python package manager, to install all requirements listed in requirements.txt.
// Python and pip must already be installed for this to work.
task pipInstallRequirements(type: Exec, dependsOn: pythonPackageIndexFolder) {
workingDir pythonDistStaging
commandLine "pip", "install", "-r", "requirements.txt"
}
// Publishes to the python package index.
// Depends on bintrayUpload because we use bintray for hosting the zip file.
task publishToTestPyPI(type: Exec, dependsOn: pythonPackageIndexFolder) {
workingDir pythonDistStaging
commandLine "python", "setup.py", "sdist", "upload", "-r", "pypitest"
}
// Publishes to the python package index.
// Depends on bintrayUpload because we use bintray for hosting the zip file.
task publishToPyPI(type: Exec, dependsOn: pythonPackageIndexFolder) {
workingDir pythonDistStaging
commandLine "python", "setup.py", "sdist", "upload"
}
// This is associated with the maven-publish plugin. It's needed for bintrayUpload to work properly.
publishing {
publications {
Main(MavenPublication) {
from components.java
artifact sourcesJar
groupId project.getGroup()
artifactId 'framework'
version project.getVersion()
}
}
}
// In order to run the bintrayUpload task successfully, create a file called local.properties
// and add a line like bintray.apikey=...
// To get the API key, go here and log in: https://bintray.com/profile/edit/organizations
// You'll also need to increment the project.setVersion(...) number in this file to push successfully.
Properties localProperties = new Properties()
File propsFile = new File('local.properties')
if (propsFile.exists()) {
localProperties.load(new FileInputStream(propsFile))
}
bintray {
user = 'rlbotofficial'
key = localProperties.getProperty("bintray.apikey")
publications = ['Main']
pkg {
repo = 'RLBotMaven'
name = 'rlbot-framework'
licenses = ['MIT']
vcsUrl = 'https://github.com/RLBot/RLBot.git'
version {
name = project.getVersion()
released = new Date()
}
}
}