-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
152 lines (129 loc) · 4.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
import static java.lang.Boolean.parseBoolean
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven {url 'https://repo.grails.org/grails/core'}
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
classpath "org.grails.plugins:hibernate5:$grailsHibernatePluginVersion"
classpath "co.uzzu.dotenv:gradle:$dotEnvGradlePluginVersion"
}
}
version xhAppVersion
group xhAppPackage
apply plugin:'idea'
apply plugin:'war'
apply plugin:'org.grails.grails-web'
// Must be applied to root project - matters when running Toolbox in a wrapper project mode w/hoist-core.
// See README.md for more details on this configuration, including contents of top-level build.gradle file.
gradle.rootProject {
apply plugin:'co.uzzu.dotenv.gradle'
}
repositories {
mavenCentral()
maven {url 'https://repo.grails.org/grails/core'}
maven {url 'https://repo.xh.io/content/groups/public/'}
}
configurations {
all {
// Ensure any SNAPSHOT dependencies are always resolved to the latest available version.
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
springBoot {
mainClass = xhAppPackage + ".Application"
}
if (parseBoolean(runHoistInline)) {
println "${xhAppName}: running with Hoist Core INLINE...."
grails.plugins {
implementation project(":hoist-core")
}
} else {
println "${xhAppName}: running with Hoist Core PACKAGED at v${hoistCoreVersion}...."
dependencies {
implementation "io.xh:hoist-core:$hoistCoreVersion"
}
}
dependencies {
// For server-side JWT validation.
implementation "org.bitbucket.b_c:jose4j:0.9.6"
// Database drivers - H2 for temporary in-memory DB with `useH2: true` in instanceConfig YAML
// MySQL for deployed instances, or more stateful local workstation setups.
runtimeOnly "com.h2database:h2:2.2.224"
runtimeOnly "mysql:mysql-connector-java:8.0.33"
// For hot reloading
developmentOnly "io.methvin:directory-watcher:0.15.0"
if (parseBoolean(enableHotSwap)) {
developmentOnly "io.xh:groovyReset:1.0"
}
}
// Avoid unexpected errors with overly-long classpath on Windows development machines.
grails {
pathingJar = true
}
Map hoistMetaData = [
'info.xh.appCode': xhAppCode,
'info.xh.appName': xhAppName,
'info.xh.appPackage': xhAppPackage,
'info.xh.appBuild': findProperty('xhAppBuild') ?: 'UNKNOWN'
]
def allJvmArgs = [
'-Dspring.output.ansi.enabled=always',
'-XX:TieredStopAtLevel=1',
'-Xmx' + localDevXmx,
"--add-modules=java.se",
"--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens=java.management/sun.management=ALL-UNNAMED",
"--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED"
]
if (parseBoolean(enableHotSwap)) {
def groovyReset = configurations.developmentOnly.resolve().find {it.name.contains("groovyReset")}
allJvmArgs += [
'-XX:HotswapAgent=fatjar',
'-XX:+AllowEnhancedClassRedefinition',
'-javaagent:' + groovyReset.absolutePath
]
}
bootRun {
ignoreExitValue true
systemProperties System.properties
jvmArgs(allJvmArgs)
sourceResources sourceSets.main
systemProperties hoistMetaData
// Bring .env sourced environment variables into bootRun JVM process.
environment env.allVariables()
}
tasks.withType(GroovyCompile) {
configure(groovyOptions) {
forkOptions.jvmArgs = allJvmArgs
}
}
// Ask IntelliJ to download sources and javadocs for Gradle-managed dependencies.
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
//--------------------------------------------------
// Extensions to build.info (Hoist-Core requirement)
//--------------------------------------------------
tasks.war.doFirst {
File infoFile = layout.buildDirectory.file('resources/main/META-INF/grails.build.info').get().asFile
Properties properties = new Properties()
infoFile.withInputStream {properties.load(it)}
properties.putAll(hoistMetaData)
infoFile.withOutputStream {properties.store(it, null)}
}
// Ensure that all variables defined in .env.template are set in local .env
tasks.bootRun.doFirst {
def missingEnvVars = env.allVariablesOrNull().findAll {it.value == null}.collect {it.key}
if (missingEnvVars) {
throw new GradleException("Environment variables listed in .env.template not set in local .env file as required: ${missingEnvVars}")
}
}