forked from openremote/openremote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.gradle
236 lines (211 loc) · 7.52 KB
/
project.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
// Common configuration applied to all projects
import static org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS
import static org.apache.tools.ant.taskdefs.condition.Os.isFamily
import static org.jetbrains.gradle.ext.ShortenCommandLine.MANIFEST
import org.jetbrains.gradle.ext.Application
import org.jetbrains.gradle.ext.JUnit
// Build plugins
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1"
}
}
// Configure IDEA project (needs to be applied to the root project only)
if (project == rootProject) {
try {
apply plugin: "org.jetbrains.gradle.plugin.idea-ext"
} catch(Exception e) {
}
if (project.hasProperty("idea") && idea.project) {
// IDEA settings
idea.project.settings {
compiler {
javac {
javacAdditionalOptions "-parameters"
}
}
runConfigurations {
defaults(JUnit) {
shortenCommandLine = MANIFEST
workingDirectory = (isCustomProject() ? project(":openremote").projectDir.toString() : projectDir.toString())
}
defaults(Application) {
mainClass = 'org.openremote.manager.Main'
shortenCommandLine = MANIFEST
workingDirectory = (isCustomProject() ? project(":openremote").projectDir.toString() : projectDir.toString())
}
"Empty"(Application) {
moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.manager.main" : ".manager.main")
}
"Test Setup"(Application) {
moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.test.main" : ".test.main")
}
"Empty with Proxy"(Application) {
moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.manager.main" : ".manager.main")
envs = [
WEBSERVER_LISTEN_HOST: "0.0.0.0",
EXTERNAL_URL: "https://localhost:8443"
]
}
"Test Setup with Proxy"(Application) {
moduleName = getProject().idea.module.name + (isCustomProject() ? ".openremote.test.main" : ".test.main")
envs = [
WEBSERVER_LISTEN_HOST: "0.0.0.0",
EXTERNAL_URL: "https://localhost:8443"
]
}
}
}
if (isCustomProject()) {
idea.project.settings.runConfigurations {
"Custom Deployment"(Application) {
moduleName = "${getProject().idea.module.name}.deployment.main"
envs = [
MAP_SETTINGS_PATH: "../deployment/map/mapsettings.json",
MAP_TILES_PATH: "../deployment/map/mapdata.mbtiles",
LOGGING_CONFIG_FILE: "../deployment/manager/logging.properties",
CUSTOM_APP_DOCROOT: "../deployment/manager/app"
]
}
}
}
}
}
// Give test projects more memory (Gradle 5 reduced this to 512MB)
subprojects {
tasks.withType(Test) {
maxHeapSize = "2g"
}
}
// Default repositories for dependency resolution
repositories {
maven {
url = "https://repo.osgeo.org/repository/release/"
}
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "https://pkgs.dev.azure.com/OpenRemote/OpenRemote/_packaging/OpenRemote/maven/v1"
}
maven {
url "https://jitpack.io"
}
}
// Eclipse needs help
apply plugin: "eclipse"
// Intellij needs help
apply plugin: 'idea'
// Use the same output directories in IDE as in gradle
idea {
module {
outputDir file('build/classes/main')
testOutputDir file('build/classes/test')
excludeDirs += file(".node")
excludeDirs += file("node_modules")
excludeDirs += file("dist")
excludeDirs += file("build")
}
}
// Helper functions for project/task resolution when the main
// repo is checked out as a git submodule and therefore a subproject
def isCustomProject() {
findProject(":openremote") != null
}
def resolvePath(String path) {
isCustomProject() ? ":openremote" + path : path
}
def resolveProject(String path) {
project(resolvePath(path))
}
def resolveTask(String path) {
tasks.getByPath(resolvePath(path))
}
ext {
resolvePath = this.&resolvePath
resolveProject = this.&resolveProject
resolveTask = this.&resolveTask
isCustomProject = this.&isCustomProject
}
if (project.convention.findPlugin(JavaPluginConvention)) {
// Change the output directory for the main and test source sets back to the old path
sourceSets.main.java.outputDir = new File(buildDir, "classes/main")
sourceSets.test.java.outputDir = new File(buildDir, "classes/test")
}
// Configure versions in gradle.properties (putting a gradle.properties file
// in a subproject only overrides root properties of same name for the actual
// subproject, not for its children!)
version = hasProperty("openremoteVersion") ? openremoteVersion : projectVersion
// Add UI tasks
ext.npmCommand = {
cmd ->
isFamily(FAMILY_WINDOWS) ? "${cmd}.cmd" : cmd
}
// Add yarn tasks
task yarnInstall(type: Exec){
commandLine npmCommand("yarn"), "install"
}
task yarnInstallForce(type: Exec){
commandLine npmCommand("yarn"), "install", "--force"
}
// Add npm tasks
task npmInstall(type: Exec){
commandLine npmCommand("npm"), "install"
}
task npmClean(type: Exec){
commandLine npmCommand("npm"), "run-script", "clean"
}
task npmBuild(type: Exec){
mustRunAfter npmClean
dependsOn tasks.getByPath(":yarnInstall")
commandLine npmCommand("npm"), "run-script", "build"
}
task npmTest(type: Exec){
dependsOn tasks.getByPath(":yarnInstall")
commandLine npmCommand("npm"), "run-script", "test"
}
task npmServe(type: Exec){
dependsOn tasks.getByPath(":yarnInstall")
commandLine npmCommand("npm"), "run-script", "serve"
}
task npmPrepare(type: Exec){
dependsOn tasks.getByPath(":yarnInstall")
commandLine npmCommand("npm"), "run-script", "prepublishOnly"
}
task npmPublish(type: Exec){
dependsOn tasks.getByPath(":yarnInstall")
commandLine npmCommand("npm"), "publish"
}
task npmServeProduction(type: Exec){
dependsOn tasks.getByPath(":yarnInstall")
commandLine npmCommand("npm"), "run-script", "serveProduction"
}
// Add typescript tasks
task tscWatch(type: Exec) {
commandLine npmCommand("npx"), "tsc", "-b", "--watch"
}
// Configure Java build
plugins.withType(JavaPlugin).whenPluginAdded {
// Use Java 8
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
def warnLogFile = file("$buildDir/${name}Warnings.log")
logging.addStandardErrorListener(new StandardOutputListener() {
void onOutput(CharSequence output) {
warnLogFile << output
}
})
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
options.encoding = 'UTF-8'
}
// JAR/ZIP base name is the fully qualified subproject name
archivesBaseName = "${rootProject.name}${path.replaceAll(":", "-")}"
}