-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle
139 lines (111 loc) · 4.51 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
// Need this here in case we're building standalone, not inside a Terasology engine workspace
buildscript {
repositories {
// External libs
mavenCentral()
// gradle plugins
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
//Spotbugs
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.0.0"
// SonarQube / Cloud scanning
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8"
}
}
plugins {
id "java"
id "application"
}
apply from: "$rootDir/config/gradle/publish.gradle"
apply from: 'config/gradle/versioning.gradle'
import groovy.json.JsonBuilder
mainClassName = "org.terasology.web.ServerMain"
ext {
localServerDataPath = 'terasology-server'
}
// For artifact organizing - version is set in gradle.properties
group = 'org.terasology.web'
def jettyVersion = '9.3.8.v20160314'
def jerseyVersion = '2.22.2'
configurations {
modules
}
sourceSets {
// Adjust output path (changed with the Gradle 6 upgrade, this puts it back)
main.java.outputDir = new File("$buildDir/classes")
test.java.outputDir = new File("$buildDir/testClasses")
}
dependencies {
implementation group: 'org.terasology.engine', name: 'engine', version: '+', changing: true
//TODO: add Guava dependency?
implementation group: 'com.google.code.gson', name: 'gson', version: '2.6.2'
implementation group: 'org.eclipse.jetty', name: 'jetty-servlet', version: jettyVersion
implementation group: 'org.eclipse.jetty.websocket', name: 'websocket-server', version: jettyVersion
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
//TODO: update this to newer version if the engine updates its version of JNA
implementation group: 'com.github.oshi', name: 'oshi-core', version: '3.4.0'
implementation group: 'org.glassfish.jersey.containers', name: 'jersey-container-jetty-servlet', version: jerseyVersion
implementation group: 'org.glassfish.jersey.ext', name: 'jersey-mvc-freemarker', version: jerseyVersion
testImplementation 'junit:junit:4.12'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.2.0'
}
jar {
manifest {
attributes('Main-Class': mainClassName)
attributes('Class-Path': "jopenvr.jar " + configurations.runtimeClasspath.collect { it.getName() }.join(' '))
}
}
// Copied from PC facade
// By delaying this task to doLast we don't get the headless server dir set up unless actually wanting it
task setupServerConfig() {
description "Parses parameters passed via Gradle and writes them to the local run-from-source server dir's config.cfg"
def serverRoot = rootProject.file(localServerDataPath);
def config = new File(serverRoot, 'config.cfg')
onlyIf { !config.exists() }
doLast {
def json = new JsonBuilder()
serverRoot.mkdir()
logger.lifecycle("Creating config file $config")
json {
worldGeneration {
if (project.hasProperty('seed')) {
logger.lifecycle(" Seed value: $seed");
defaultSeed seed
}
if (project.hasProperty('worldGen')) {
logger.lifecycle(" World Generator: $worldGen");
defaultGenerator worldGen
}
}
defaultModSelection {
if (project.hasProperty('extraModules')) {
logger.lifecycle(" Enabling modules: $extraModules");
modules extraModules.tokenize(" ,")
}
}
}
config.text = json.toPrettyString()
}
}
// TODO: Seems to always be up to date so no modules get copied
task setupServerModules(type: Sync) {
description 'Parses "extraModules" - a comma-separated list of modules and puts them into ' + localServerDataPath
if (project.hasProperty('extraModules')) {
// Grab modules from Artifactory - cheats by declaring them as dependencies
extraModules.tokenize(' ,').each { String module ->
println "Extra module: " + module
dependencies {
modules group: 'org.terasology.modules', name: module, version: '+', changing: 'true'
}
}
}
from(configurations.modules)
into(new File(rootProject.file(localServerDataPath), "modules"))
}
run.workingDir = rootDir
run.args = ["-homedir=terasology-server"]
run.dependsOn setupServerConfig
run.dependsOn setupServerModules