-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
395 lines (334 loc) · 11.6 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
id 'maven'
id 'maven-publish'
id 'idea'
id 'war'
id 'pmd'
id 'io.franzbecker.gradle-lombok' version '2.1'
}
group = "com.imcode.imcms"
version = "6.0.0-beta10"
description = "imCMS"
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = projectBuildSourceEncoding
options.fork = javaCompileFork
}
repositories {
jcenter()
maven { url "http://repo.imcode.com/maven2" }
}
ext {
springframeworkVersion = '5.1.5.RELEASE'
hibernateVersion = '5.2.18.Final'
solrVersion = '7.2.1'
slf4jVersion = '1.7.26'
junitVersion = '5.3.2'
lombokVersion = '1.18.6'
sharedManifest = manifest {
attributes "Build-Date": new Date()
attributes "Application-Version": project.version
attributes "Build-Jdk": System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')'
attributes "Built-With": "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}"
attributes "Built-By": project.hasProperty('BF_USER') ? project.getProperty('BF_USER', null) : System.getProperty('user.name')
}
}
dependencies {
compile "org.projectlombok:lombok:${lombokVersion}"
compile "com.drewnoakes:metadata-extractor:2.11.0"
compile "com.fasterxml.jackson.core:jackson-databind:2.9.8"
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8'
compile "com.zaxxer:HikariCP:3.1.0"
compile("com.imcode.db:imcode-db:0.7") {
exclude(module: 'junit')
}
compile "com.imcode.ldap:imcode-ldap:0.1"
compile("com.imcode.util:imcode-util:2.0.4") {
exclude(module: "servlet-api")
exclude(module: "commons-io")
}
compile "com.jcabi:jcabi-matchers:1.4"
compile("com.jcabi:jcabi-w3c:1.3") {
exclude(module: "commons-io")
}
compile 'com.squareup.okhttp3:okhttp:3.11.0'
compile "commons-beanutils:commons-beanutils:1.9.3"
compile "commons-dbutils:commons-dbutils:1.6"
compile "commons-lang:commons-lang:2.6"
compile("commons-validator:commons-validator:1.6") {
exclude(module: "commons-logging")
}
compile "javax.inject:javax.inject:1"
compile "javax.servlet:javax.servlet-api:3.1.0"
compile "javax.servlet:jstl:1.2"
compile "javax.servlet.jsp:javax.servlet.jsp-api:2.3.1"
compile "javax.validation:validation-api:2.0.1.Final"
compile("net.sf.ehcache:ehcache-web:2.0.4") {
exclude(module: 'ehcache-core')
}
compile "org.apache.commons:commons-collections4:4.3"
compile "org.apache.commons:commons-email:1.5"
compile "org.apache.commons:commons-lang3:3.8.1"
compile "org.apache.commons:commons-text:1.6"
compile("org.apache.httpcomponents:httpclient:4.5.7") {
exclude(module: "commons-logging")
}
compile "org.apache.solr:solr-core:${solrVersion}"
compile("org.apache.tika:tika-parsers:1.18") {
exclude(module: "commons-logging")
exclude(module: "asm")
exclude(module: "commons-io")
}
compile "org.aspectj:aspectjrt:1.8.13"
compile "org.aspectj:aspectjweaver:1.8.13"
compile("org.hibernate:hibernate-ehcache:${hibernateVersion}") {
exclude(module: "ehcache-core")
}
compile "org.hibernate.validator:hibernate-validator:6.0.15.Final"
compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
compile "org.springframework:spring-aop:${springframeworkVersion}"
compile("org.springframework:spring-core:${springframeworkVersion}") {
exclude(module: 'commons-logging')
}
compile "org.springframework:spring-orm:${springframeworkVersion}"
compile "org.springframework:spring-webmvc:${springframeworkVersion}"
compile "org.springframework.data:spring-data-jpa:1.11.18.RELEASE"
compile 'org.modelmapper:modelmapper:2.3.2'
compile 'javax.interceptor:javax.interceptor-api:1.2.2'
//Azure AD dependencies
compile "com.microsoft.azure:adal4j:1.6.3"
compile "com.nimbusds:oauth2-oidc-sdk:5.24.2"
runtime "com.fasterxml:classmate:1.3.4"
runtime "javax.el:javax.el-api:3.0.0"
runtime "mysql:mysql-connector-java:8.0.21"
runtime "org.hibernate:hibernate-core:${hibernateVersion}"
runtime "org.slf4j:slf4j-log4j12:${slf4jVersion}"
testCompile "com.jayway.jsonpath:json-path-assert:2.2.0"
testCompile "org.dbunit:dbunit:2.5.4"
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testCompile "org.junit.vintage:junit-vintage-engine:${junitVersion}"
testCompile "org.mockito:mockito-core:2.27.0"
testCompile "org.mockito:mockito-junit-jupiter:2.27.0"
testCompile "org.skyscreamer:jsonassert:1.5.0"
testCompile "org.springframework:spring-test:${springframeworkVersion}"
testRuntime "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}
final def mavenProps = new Properties() //Migrated maven properties
//Used to merge build and server properties file with replacement of inplace variables usage
final def buildProps = new Properties()
final def serverProps = new Properties()
final def tmpDir = "${buildDir}/tmp/" //Directory to hold temporary data
final def localizationLanguages = new HashMap<String, String>() //Translation Languages
task initParams() {
mavenProps.setProperty("log4j.threshold", "info")
mavenProps.setProperty("log4j.hibernate.level", "error")
mavenProps.setProperty("log4j.console-appender.threshold", "off")
localizationLanguages.put("", "en")
localizationLanguages.put("_sv", "sv")
file("build.properties").withInputStream { buildProps.load(it) }
buildProps.setProperty("imcms.version", project.version as String)
file("src/main/resources-conf/server.properties").withInputStream { serverProps.load it }
}
task explodedWar(type: Sync, dependsOn: war) {
into "${buildDir}/libs/exploded/${project.name}-${project.version}.war/"
with war
}
task mergeProperties() {
final def lines = file("src/main/resources-conf/server.properties").readLines()
final def mergedProperties = new ArrayList<String>()
final def customProps = buildProps.clone()
lines.each {
buildProps.each { final prop ->
if (it.matches("^" + prop.key + "\\s*= *.*\\s*\$")) {
it = prop.toString()
customProps.remove(prop.key)
}
}
mergedProperties.add(it)
}
mergedProperties.addAll(customProps.findAll())
doLast {
final def mergedPropertiesFile = file("${buildDir}/libs/exploded/${project.name}-${project.version}.war/WEB-INF/conf/server.properties")
mergedPropertiesFile.withWriter { final out ->
mergedProperties.each {
out.println it
}
}
}
}
task installWebDependencies(type: Exec) {
executable = 'npm'
args = ["install", "--prefix", "src/main/webapp/"]
}
task buildWeb(type: Exec, dependsOn: installWebDependencies) {
executable = 'npm'
args = ["run", "build:prod", "--prefix", "src/main/webapp/"]
}
task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
manifest {
from sharedManifest
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
task webZip(type: Zip) {
archiveClassifier = 'web'
archiveExtension = 'zip'
from 'src/main/webapp'
exclude "node_modules"
exclude "dist"
exclude "WEB-INF"
exclude "**/*.jsp"
}
tasks.war {
it.dependsOn initParams
it.dependsOn test
it.dependsOn buildWeb
}
explodedWar.finalizedBy mergeProperties
//Plugins setting up
lombok {
version = lombokVersion
sha256 = ""
}
idea {
module {
inheritOutputDirs = false
outputDir = compileJava.destinationDir
testOutputDir = compileTestJava.destinationDir
}
}
pmd {//Here is available list of rules - https://pmd.github.io/pmd-6.5.0/pmd_rules_java.html
ignoreFailures = true
}
jar {
doFirst {
manifest {
from sharedManifest
}
}
archiveClassifier = 'classes'
}
javadoc {
options.encoding = projectBuildSourceEncoding
}
test {
doFirst {
copy {
from "${buildDir}/resources/test"
into "${buildDir}/classes/java/test"
}
copy {
from "${buildDir}/resources/main"
into "${buildDir}/classes/java/test"
}
useJUnitPlatform()
}
}
war {
exclude "dependency_path_resolver.js"
exclude "node_modules"
exclude "js"
exclude ".babelrc"
exclude "package-lock.json"
exclude "base.config.js"
exclude "webpack.config.js"
exclude "prod.config.js"
manifest {
from sharedManifest
}
//Copying configuration files
webInf {
from "src/main/resources"
from "src/main/resources-conf"
include "server.properties"
include "imcms*.properties"
include "*.conf"
include "log4j.xml"
include "*.json"
into "/WEB-INF/conf"
filter(ReplaceTokens, tokens: serverProps)
filter(ReplaceTokens, tokens: buildProps)
filter(ReplaceTokens, tokens: mavenProps, beginToken: '${', endToken: '}')
}
//Copying ehcache configuration files
webInf {
from "src/main/resources"
include "ehcache.xml"
include "ehcache.xsd"
into "/WEB-INF/classes"
}
//Template localization
final def rootFolderForTemplates = "src/main/webapp/WEB-INF/templates/lang"
final def rootFolderForImcmsTemplates = "src/main/webapp/imcms/lang"
final def templatePatterns = new ArrayList()
templatePatterns.add("**/*.jsp")
templatePatterns.add("**/*.jspx")
templatePatterns.add("**/*.htm")
templatePatterns.add("**/*.html")
def langProperties
localizationLanguages.each { final lang ->
langProperties = new Properties()
file("src/main/resources/imcms${lang.key}.properties").withInputStream { langProperties.load(it) }
webInf {
from rootFolderForTemplates
include templatePatterns
filter(ReplaceTokens, tokens: langProperties, beginToken: "<? ", endToken: " ?>")
into "/WEB-INF/templates/${lang.value}"
}
webInf {
from rootFolderForTemplates
exclude templatePatterns
into "/WEB-INF/templates/${lang.value}"
}
webInf {
from rootFolderForImcmsTemplates
include templatePatterns
filter(ReplaceTokens, tokens: langProperties, beginToken: "<? ", endToken: " ?>")
into "/imcms/${lang.value}"
}
webInf {
from rootFolderForImcmsTemplates
exclude templatePatterns
into "/imcms/${lang.value}"
}
}
webInf {
final def versionFile = new File("${tmpDir}/version.txt")
doFirst {
versionFile.text = version
}
from versionFile
into "/WEB-INF/"
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifact webZip
//Ugly way to add war to publication with preserving correct final pom file
//Haven't found solution with using components.web
artifact war
}
}
repositories {
maven {
credentials {
username reposotiryUsername
password reposotiryPassword
}
url "sftp://repo.imcode.com:2022/srv/www/repo.imcode.com/maven2"
}
}
}