forked from MovingBlocks/FacadeServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
143 lines (113 loc) · 4.93 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
// Dependencies needed for what our Gradle scripts themselves use. It cannot be included via an external Gradle file :-(
buildscript {
repositories {
// External libs - jcenter is Bintray and is supposed to be a superset of Maven Central, but do both just in case
jcenter()
mavenCentral()
}
dependencies {
// Artifactory plugin
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '4.0.0')
}
}
plugins {
id "org.standardout.versioneye" version "1.3.0"
}
apply from: "$rootDir/config/gradle/artifactory.gradle"
apply plugin: 'application'
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'
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
def jettyVersion = '9.3.8.v20160314'
def jerseyVersion = '2.22.2'
dependencies {
// Support both standalone workspace (fetch binary engine) and embedding in a Terasology workspace (use local engine source)
if (project.name != project(':').name) {
compile project(':engine')
} else {
// For a standalone workspace we need to retrieve the engine from Artifactory instead
compile(group: 'org.terasology.engine', name: 'engine', version: '+', changing: true)
}
//TODO: add Guava dependency?
compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: jettyVersion
compile group: 'org.eclipse.jetty.websocket', name: 'websocket-server', version: jettyVersion
compile 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
compile group: 'com.github.oshi', name: 'oshi-core', version: '3.4.0'
compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-jetty-servlet', version: jerseyVersion
compile group: 'org.glassfish.jersey.ext', name: 'jersey-mvc-freemarker', version: jerseyVersion
testCompile 'junit:junit:4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
}
jar {
manifest {
attributes('Main-Class': mainClassName)
attributes('Class-Path': "jopenvr.jar " + configurations.runtime.collect { it.getName() }.join(' '))
}
}
// Copied from PC facade
// By delaying this task to doLast (the << bit) we don't get the headless server dir set up unless actually wanting it
// TODO: This is not the Gradle Way. Needs more declared output-fu to determine up-to-date instead of the if
task setupServerConfig() << {
description "Parses parameters passed via Gradle and writes them to the local run-from-source server dir's config.cfg"
def json = new JsonBuilder()
def serverRoot = rootProject.file(localServerDataPath);
def config = new File(serverRoot, 'config.cfg')
if (!config.exists()) {
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
// Support both standalone workspace (expect certain things provided) and embedding in a Terasology workspace (use task dependencies)
if (project.name != project(':').name) {
run.dependsOn rootProject.extractNatives
run.dependsOn rootProject.moduleClasses
} else {
// For a standalone workspace natives should be provided
}