forked from openremote/openremote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.gradle
167 lines (149 loc) · 4.88 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
// 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
// Build plugins
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
}
}
// Default repositories for dependency resolution
repositories {
maven {
url = "http://download.osgeo.org/webdav/geotools/"
}
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "http://m2repo.openremote.com/content/groups/public/"
}
}
// 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")
}
}
if (project.convention.findPlugin(JavaPluginConvention)) {
// Change the output directory for the main and test source sets back to the old path
sourceSets.main.output.classesDirs = new File(buildDir, "classes/main")
sourceSets.test.output.classesDirs = 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 NodeJS plugin configuration and tasks
apply plugin: com.moowork.gradle.node.NodePlugin
node {
download = true
version = "8.9.0"
workDir = file("${rootDir}/.node")
}
ext.nodeDir = {
def osName = com.moowork.gradle.node.util.PlatformHelper.INSTANCE.getOsName()
def osArch = com.moowork.gradle.node.util.PlatformHelper.INSTANCE.getOsArch()
def version = node.version
node.workDir.absolutePath + File.separator + "node-v${version}-${osName}-${osArch}"
}
ext.nodeModuleDir = {
isFamily(FAMILY_WINDOWS) ? "${nodeDir()}/node_modules" : "${nodeDir()}/lib/node_modules"
}
ext.nodeModuleGlobal = {
dir, mod ->
file("${nodeModuleDir()}/${dir}/bin/${mod}")
}
ext.nodeModuleLocal = {
dir, mod ->
file("${projectDir}/node_modules/${dir}/bin/${mod}")
}
task npmInstall(overwrite: true, type: NpmTask, dependsOn: 'npmSetup') {
inputs.file('package.json')
outputs.upToDateWhen { file('node_modules').exists() }
npmCommand = ['install']
}
// Add bower tasks
task bowerInstall(type: NpmTask) {
dependsOn nodeSetup
args = ['install', '-g', 'bower']
outputs.upToDateWhen {
nodeModuleGlobal('bower', 'bower').exists()
}
}
task bowerUpdate(type: NodeTask) {
dependsOn bowerInstall
script = nodeModuleGlobal('bower', 'bower')
args = ['update']
inputs.file("${project.projectDir}/bower.json")
outputs.dir("${project.projectDir}/bower_components")
}
task bowerPrune(type: NodeTask) {
dependsOn bowerInstall
script = nodeModuleGlobal('bower', 'bower')
args = ['prune']
inputs.file("${project.projectDir}/bower.json")
outputs.dir("${project.projectDir}/bower_components")
}
// TODO Test this... Add polymer tasks, we really only want to compile ES6 to ES5, maybe some minification!
/*
task polymerInstall(type: NpmTask) {
dependsOn nodeSetup
args = ['install', '-g', 'polymer-cli']
outputs.upToDateWhen {
nodeModuleGlobal('polymer-cli', 'polymer-cli').exists()
}
}
task polymerServe(type: NodeTask) {
dependsOn polymerInstall
script = nodeModuleGlobal('polymer-cli', 'polymer-cli')
args = ['serve']
}
*/
// 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(":", "-")}"
}
// Helper functions for project/task resolution when the main
// repo is checked out as a git submodule and therefore a subproject
def resolvePath(String path) {
findProject(":openremote") != null ? ":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
}