-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle
244 lines (208 loc) · 7.84 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
plugins {
id 'java'
id 'idea'
id 'maven-publish'
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
repositories {
mavenLocal()
maven {
url = 'https://repo.runelite.net'
}
mavenCentral()
}
def lastSupportedVersion = "1.10.32.1"
def runeLiteVersion = getRuneLiteVersion()
def supportedCheck = false
if (supportedCheck) {
if (runeLiteVersion != lastSupportedVersion) {
println("Warning - client has been updated")
throw new Exception("Out of date (last supported: " + lastSupportedVersion + " current client: " + runeLiteVersion + ")")
}
}
static def getRuneLiteVersion() {
URL url = new URL("http://repo.runelite.net/net/runelite/client/maven-metadata.xml")
URLConnection urlConnection = url.openConnection()
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
urlConnection.getInputStream()))
String latestName = null
String inputLine
while ((inputLine = bufferedReader.readLine()) != null) {
inputLine = inputLine.trim()
if (inputLine.contains("<release>")) {
latestName = inputLine.replace("<release>", "").replace("</release>", "")
}
}
bufferedReader.close()
return latestName
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
//implementation project(":OSRSBot")
implementation group: 'net.runelite', name: 'client', version: runeLiteVersion
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.slf4j:slf4j-simple:1.7.36'
implementation group: 'net.sf.jopt-simple', name:'jopt-simple', version: '5.0.4'
//implementation group: 'net.runelite', name:'client', version: runeLiteVersion
testImplementation group: 'net.runelite', name:'client', version: runeLiteVersion
testImplementation group: 'net.runelite', name:'jshell', version: runeLiteVersion
//We want these both at compile and at runtime.
//So we use implementation instead of compileOnly or runtimeOnly
implementation 'com.github.OSRSB:OSRSBot:master-SNAPSHOT'
//implementation 'com.github.OSRSB:DaxWalkerOSRSBot:master-SNAPSHOT'
//implementation project(":DaxWalkerRSB")
}
group = 'osrsb'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
sourceSets {
main {
java {
srcDirs= ["src/main/java"]
}
}
}
jar {
configurations.implementation.setCanBeResolved(true)
from {
configurations.implementation.filter {it.name.startsWith('Dax')}.collect {zipTree(it)}
}
exclude 'META-INF/*.RSA'
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
enum OperatingSystem {
MAC, WINDOWS, LINUX, UNKNOWN
static def getOperatingSystem() {
final String os = System.getProperty("os.name")
if (os.contains("Mac")) {
return MAC
} else if (os.contains("Windows")) {
return WINDOWS
} else if (os.contains("Linux")) {
return LINUX
} else {
return UNKNOWN
}
}
}
class ScriptTask extends DefaultTask {
static String getBotScriptDirectory() {
final String NAME = "OsrsBot"
final String SCRIPT_DIRECTORY = "/Scripts/Sources"
final String env = System.getenv(NAME.toUpperCase().concat("_HOME"))
if (env == null || env.isEmpty()) {
String homeDirBuilder = System.getProperty("user.home")
switch(OperatingSystem.getOperatingSystem()) {
case OperatingSystem.LINUX:
homeDirBuilder += File.separator + ".config"
break
case OperatingSystem.MAC:
homeDirBuilder += (homeDirBuilder == null) ? "~" : ""
break
case OperatingSystem.WINDOWS:
//Do nothing
break
default:
//If you're using Solaris or something you're wrong.
break
}
return (homeDirBuilder + File.separator + NAME + SCRIPT_DIRECTORY)
}
return env
}
def copyLargeDir(File dirFrom, File dirTo) {
if (!dirTo.exists()) {
dirTo.mkdir();
}
dirFrom.eachFile(groovy.io.FileType.FILES) { File source ->
File target = new File(dirTo, source.getName())
target.bytes = source.bytes
}
dirFrom.eachFile(groovy.io.FileType.DIRECTORIES) { File source ->
File target = new File(dirTo, source.getName())
copyLargeDir(source, target)
}
}
@InputDirectory
var scriptDependency =
project.file("${project.buildDir}/classes/java/main")
@OutputDirectory
var outputDir =
project.file(getBotScriptDirectory())
@TaskAction
def copyFiles() {
copyLargeDir(scriptDependency, outputDir)
}
}
task outputToScriptDirectory(type: ScriptTask) {
group = 'TEST'
dependsOn(classes)
}
task botRunGUI(type: JavaExec) {
group = "Execution"
description = "Runs the main method within RSB"
classpath = sourceSets.main.compileClasspath + sourceSets.main.runtimeClasspath
getMainClass() set "net.runelite.rsb.botLauncher.Application"
String jvmArgString = (OperatingSystem.MAC == OperatingSystem.getOperatingSystem()) ?
"-debug --add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED" :
"-debug"
jvmArgs jvmArgString.split(" ")
args "--bot-runelite --developer-mode".split(" ")
dependsOn(outputToScriptDirectory)
}
task botRunHeadless(type: JavaExec) {
group = "Execution"
description = "Runs the main method within RSB"
classpath = sourceSets.main.compileClasspath + sourceSets.main.runtimeClasspath
getMainClass() set "net.runelite.rsb.botLauncher.Application"
String jvmArgString = (OperatingSystem.MAC == OperatingSystem.getOperatingSystem()) ?
"-debug --add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED" :
"-debug"
jvmArgs jvmArgString.split(" ")
args "--bot-runelite --developer-mode --headless".split(" ")
dependsOn(outputToScriptDirectory)
}
task dockerBuild(type: Exec) {
group = "Docker"
description = "Builds the docker image"
commandLine 'docker', 'build', '-t', 'bot-image', '.'
dependsOn classes
}
task dockerRunGUI(type: Exec) {
group = "Docker"
description = "Runs the Docker image on the host XServer"
commandLine 'docker', 'run', '-e', 'DISPLAY=host.docker.internal:0', '-t', '--rm', 'bot-image'
dependsOn dockerBuild
}
task dockerRunHeadless(type: Exec) {
group = "Docker"
description = "Runs the Docker image on the host XServer"
commandLine 'docker', 'run', '-e', 'DISPLAY=host.docker.internal:0', '-t', '--rm', 'bot-image', '--headless'
dependsOn dockerBuild
}
task dockerCompose(type: Exec) {
group = "Docker"
commandLine 'docker', 'compose', '-f', 'docker-compose.yml', 'up', '--build', '--no-deps', '-d'
}
task dockerComposeForceBuild(type: Exec) {
group = "Docker"
commandLine 'docker', 'compose', '-f', 'docker-compose.yml', 'build', '--no-cache', 'script'
commandLine 'docker', 'compose', '-f', 'docker-compose.yml', 'up', '--build', '--force-recreate', '--no-deps', '-d'
}
task dockerComposeWithWireGuard(type: Exec) {
group = "Docker"
commandLine 'docker', 'compose', '-f', 'docker-compose-wireguard.yml', 'up', '--build', '--no-deps', '-d'
}
task dockerComposeWithWireGuardForceBuild(type: Exec) {
group = "Docker"
commandLine 'docker', 'compose', '-f', 'docker-compose-wireguard.yml', 'build', '--no-cache', 'script'
commandLine 'docker', 'compose', '-f', 'docker-compose-wireguard.yml', 'up', '--build', '--force-recreate', '--no-deps', '-d'
}