-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
258 lines (221 loc) · 8.22 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
import org.apache.tools.ant.filters.ReplaceTokens
/**
* HOW TO BUILD
*
* To build this web application, you must build the frontend and the backend.
*
* FRONTEND BUILD:
* Nodejs and npm must be globally installed (windows: must be on PATH).
* Run 'gradle buildFrontend' to build frontend (javascript and sass).
*
* BACKEND BUILD & RUN:
* See 'https://github.com/gretty-gradle-plugin/gretty' for detailed instructions.
* User Gradle task 'appRun' to start embedded tomcat and deploy webapp.
*
* CONFIGURATION:
* Default configuration file can be found at 'src/main/resources/default.properties'.
* Use configuration file at 'config/config.properties' to override defaults.
*
* DEBUG:
* Use Gradle task 'appRunDebug' to cause the webapp container to wait for debugger on port 5005.
*/
plugins {
id 'java'
id 'war'
id 'org.gretty' version '3.1.1'
id 'com.github.node-gradle.node' version '3.1.0'
}
wrapper.gradleVersion = '7.6'
class Profile {
String name
String type
String warName
String workspaceLocation
Profile(String name) {
this.name = name
}
}
class ProfilesPlugin implements Plugin<Project> {
void apply(final Project project) {
NamedDomainObjectContainer<Profile> profileContainer = project.container(Profile)
project.extensions.add('profiles', profileContainer)
}
}
apply plugin: ProfilesPlugin
// external profiles in profile.gradle override these profiles
profiles {
local {
type = "dev"
// warName = "foo.war" // change default war name
workspaceLocation = "$projectDir/gmm-workspace"
}
ext.active = local// overriden by profile.gradle!
}
if (file('profile.gradle').exists()) {
apply from: 'profile.gradle'
}
group = 'de.gothic-reloaded-mod'
version = '1.0.3-SNAPSHOT'
description = "Gothic Mod Manager"
sourceCompatibility = 11
targetCompatibility = 11
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
}
dependencies {
// Spring 5
ext.springVersion = '5.3.25'
ext.springSecVersion = '5.8.1'
implementation group: "com.realityinteractive.imageio.tga", name: "undefined"
implementation group: 'org.springframework', name: 'spring-context', version: springVersion
implementation group: 'org.springframework', name: 'spring-core', version: springVersion
implementation group: 'org.springframework', name: 'spring-context-support', version: springVersion
implementation group: 'org.springframework', name: 'spring-webmvc', version: springVersion
implementation group: 'org.springframework', name: 'spring-test', version: springVersion
implementation group: 'org.springframework', name: 'spring-beans', version: springVersion
implementation group: 'org.springframework', name: 'spring-messaging', version: springVersion
implementation group: 'org.springframework', name: 'spring-websocket', version: springVersion
implementation group: 'org.springframework.security', name: 'spring-security-core', version: springSecVersion
implementation group: 'org.springframework.security', name: 'spring-security-config', version: springSecVersion
implementation group: 'org.springframework.security', name: 'spring-security-web', version: springSecVersion
implementation group: 'org.springframework.security', name: 'spring-security-taglibs', version: springSecVersion
implementation group: 'org.springframework.security', name: 'spring-security-messaging', version: springSecVersion
// Libs
implementation group: 'com.google.jimfs', name: 'jimfs', version:'1.2'
implementation group: 'org.tmatesoft.svnkit', name: 'svnkit', version:'1.10.9'
implementation group: 'com.google.guava', name: 'guava', version:'31.1-jre'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.14.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.14.1'
implementation group: 'com.thoughtworks.xstream', name: 'xstream', version:'1.4.20'
implementation group: 'org.freemarker', name: 'freemarker', version:'2.3.31'
implementation group: 'ch.qos.logback', name: 'logback-classic', version:'1.4.5'
implementation group: 'org.imgscalr', name: 'imgscalr-lib', version:'4.2'
// Libs (Commons)
implementation group: 'org.apache.commons', name: 'commons-lang3', version:'3.12.0'
implementation group: 'org.apache.commons', name: 'commons-collections4', version:'4.4'
implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
implementation group: 'commons-fileupload', name: 'commons-fileupload', version:'1.4'
// JavaEE
implementation group: 'javax.servlet', name: 'jstl', version:'1.2'
// Testing
testImplementation group: 'junit', name: 'junit', version:'4.12'
// JavaEE APIs
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version:'4.0.0'
providedCompile group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version:'2.3.1'
providedCompile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
// Change gretty tomcat version
def tomcatVersion = '9.0.71'
gretty(
"org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-el:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}"
)
}
// #####################
// Backend Build
// #####################
task printInfo {
println 'Build Profile: ' + project.profiles.ext.active.name
println 'Build Version: ' + project.version
}
// context.xml Filtering
task copyMetaInf(type: Copy) {
// up-to-date for same profile workspace path
inputs.property('profile', project.profiles.ext.active.workspaceLocation)
from ("$projectDir/src/main/webapp/META-INF-src") {
exclude 'context.xml'
}
from ("$projectDir/src/main/webapp/META-INF-src") {
include 'context.xml'
filter(ReplaceTokens, tokens: [
workspaceLocation: project.profiles.ext.active.workspaceLocation
])
}
filteringCharset = 'UTF-8'
into "$projectDir/src/main/webapp/META-INF"
}
// Resource Filtering
processResources {
dependsOn copyMetaInf
// up-to-date for same version & profile
inputs.property('version', project.version)
inputs.property('profile', project.profiles.ext.active.type)
with copySpec {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from "$projectDir/src/main/resources/meta.properties"
expand(
'gmm_version': project.version,
'gmm_name': project.description,
'gmm_profile_type': project.profiles.ext.active.type
)
}
}
war {
exclude '**/META-INF-src'
def profile = project.profiles.ext.active;
if (profile.hasProperty('warName') && profile.warName) {
archiveFileName = profile.warName
}
}
// Embedded Tomcat/Jetty Configuration
gretty {
httpPort = 8080
contextPath = '/GMM'
servletContainer = "tomcat9"
serverConfigFile = "tomcat.xml" // Connectors for HTTP2 can be specified in this file
recompileOnSourceChange = false // call javaCompile to reload or auto reload
enableNaming = true // enable JNDI in context.xml for embedded tomcat
}
tasks.whenTaskAdded { task ->
// https://github.com/gretty-gradle-plugin/gretty/issues/117
if (task.name == 'prepareInplaceWebAppFolder') {
task.dependsOn(processResources)
}
// disallow non-local profiles for appRun
if (task.name == 'appRun') {
task.doFirst {
def profile = project.profiles.ext.active.name
if (profile != 'local') {
throw new InvalidUserDataException(
"Expected profile to be set to 'local' for jetty task, but was '" + profile + "'!")
}
}
}
}
/*
cargo {
containerId = 'tomcat9x'
port = 8080
deployable {
context = '/GMM'
}
remote {
hostname = 'localhost'
username = 'tomcat'
password = 'tomcat'
}
}*/
// #####################
// Fontend Build
// #####################
task buildFrontend(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'gulp_build']
}
task buildJs(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'gulp_build_js']
}
task buildSass(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'gulp_build_sass']
}
war.dependsOn buildFrontend
node {
download = false
nodeModulesDir = file("$projectDir/src/main/frontend")
}