forked from BladeRunnerJS/brjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
257 lines (201 loc) · 7.36 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
import static org.bladerunnerjs.BuildVersionCalculator.*
apply from: 'wrapper.gradle'
def projectBuildVersion = org.bladerunnerjs.BuildVersionCalculator.calculateVersion(project)
def projectVersionIsDirty = org.bladerunnerjs.BuildVersionCalculator.isVersionDirty(project)
def projectBuildDate = org.bladerunnerjs.BuildVersionCalculator.calculateBuildDate(project)
def projectBuildHostname = org.bladerunnerjs.BuildVersionCalculator.calculateBuildHostname(project)
logger.info "Build version calculated as: ${projectBuildVersion}"
logger.info "Build date is: ${projectBuildDate}"
logger.info "Build hostname is: ${projectBuildHostname}"
allprojects {
ext {
buildVersion = projectBuildVersion
buildDate = projectBuildDate
buildHostname = projectBuildHostname
}
def projectContainingSharedLogic = (project.parent) ? project.parent : project
apply from: projectContainingSharedLogic.file('dependencies.gradle')
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'base'
repositories {
mavenCentral()
maven { url "http://bladerunnerjs.github.io/brjs-build-dependencies/repo" }
}
buildscript {
repositories {
mavenCentral()
}
}
tasks.withType(Copy) {
fileMode = 0755
includeEmptyDirs = false
}
tasks.withType(Sync) {
fileMode = 0755
includeEmptyDirs = false
}
tasks.withType(Zip) {
fileMode = 0755
includeEmptyDirs = false
}
}
subprojects { p ->
version = buildVersion
group = 'org.bladerunnerjs'
afterEvaluate { project ->
if (project.plugins.hasPlugin(JavaPlugin)) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
project.tasks.withType(Test) { testTask ->
test {
testLogging {
events 'skipped', 'failed'
exceptionFormat 'full'
info {
displayGranularity = 0
}
}
}
}
project.tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:all']
options.encoding = 'UTF-8'
}
}
}
}
task runAllJavaTests << { throw new GradleException("runAllJavaTests has been renamed to testJava") }
task testJava {
description "Runs 'test' for all Java projects."
}
subprojects {
afterEvaluate { project ->
project.tasks.withType(Test) { testTask ->
testJava.dependsOn testTask
}
}
}
task cleanJava {
description "Runs clean for all Java projects."
}
subprojects {
afterEvaluate { project ->
if (project.plugins.hasPlugin(JavaPlugin.class)) {
cleanJava.dependsOn project.clean
}
}
}
task build {
description "Builds and tests the distribution. Runs 'build' on all subprojects."
}
def parentBuildTask = build
subprojects {
afterEvaluate { subProject ->
parentBuildTask.dependsOn subProject.getTasksByName('build',false)
}
}
task buildAndTestIE {
description "Runs the 'build' task and also includes IE tests"
}
afterEvaluate { project ->
buildAndTestIE.dependsOn build
buildAndTestIE.dependsOn ':cutlass-sdk:testIE'
}
task buildAndTestIE_NoSysApps {
description "Runs the 'build' task and also includes IE tests, ignoring the IE tests for systems apps"
}
afterEvaluate { project ->
buildAndTestIE_NoSysApps.dependsOn build
buildAndTestIE_NoSysApps.dependsOn ':cutlass-sdk:testJsIE'
}
def getProperty = { project, property ->
if (!project.hasProperty(property)) {
throw new GradleException("${property} property must be set")
}
return project.property(property)
}
/* Automated release stuff */
def getGitHubToken = { project ->
return getProperty(project,"githubToken")
}
def getReleaseNoteJson = { project, tagVersion ->
def releaseDataFile = file("releases/${tagVersion}.json")
def releaseNoteJson = new groovy.json.JsonSlurper().parseText( releaseDataFile.text )
return releaseNoteJson
}
import org.bladerunnerjs.github.*
task generateReleaseNotes, {
def assembledReleaseNotesFile = file("${buildDir}/release-note.txt")
inputs.property "projectBuildVersion", projectBuildVersion
outputs.file assembledReleaseNotesFile
doFirst {
def gitHubToken = getGitHubToken(project)
def githubApi = new GitHubAPIBridge(project, "BladeRunnerJS", "brjs", gitHubToken)
def tagVersion = org.bladerunnerjs.BuildVersionCalculator.calculateMajorVersion(project)
def releaseNoteFile = file("releases/${tagVersion}.md")
def milestoneId = getReleaseNoteJson(project,tagVersion).milestone
def includeIssueLabels = ["bug", "feature", "enhancement", "experience"]
def issueIncludeLabelsString = includeIssueLabels.join(", ").replaceAll(/^(.*),(.*)$/,'$1 or$2'); /* regex replaces the last ',' with 'or' */
def excludeIssueLabels = ["invalid", "duplicate"]
List<Issue> issues = githubApi.getClosedIssuesForMilestone(milestoneId)
List<Issue> releaseNoteIssues = new LinkedList<Issue>()
issues.each {
if (it.labels.intersect(includeIssueLabels) && !it.labels.intersect(excludeIssueLabels)) {
releaseNoteIssues.add(it)
}
}
assembledReleaseNotesFile.parentFile.mkdirs()
assembledReleaseNotesFile.createNewFile()
assembledReleaseNotesFile.text = releaseNoteFile.text
assembledReleaseNotesFile.text += "\n\n"
assembledReleaseNotesFile.text += "-------------\n"
assembledReleaseNotesFile.text += "### Closed Issues\n"
assembledReleaseNotesFile.text += "<sup>${issues.size} issues closed; ${releaseNoteIssues.size} labelled ${issueIncludeLabelsString} - <a href=\"@milestoneURL@\">@milestoneURL@</a><sup>\n\n"
releaseNoteIssues.each {
assembledReleaseNotesFile.text += "- ${it.toString()}\n"
}
assembledReleaseNotesFile.text += "\n"
assembledReleaseNotesFile.text += '<sub>Parts of this release note have been auto-generated. If you notice any problems with it, <a href="https://github.com/BladeRunnerJS/brjs/issues/new">tell us</a></sub>\n\n'
ant.replace(file: assembledReleaseNotesFile) {
replacefilter(token:"@tagVersion@", value:tagVersion)
replacefilter(token:"@buildVersion@", value:buildVersion)
replacefilter(token:"@milestonesURL@", value:githubApi.getMilestonesUrl())
replacefilter(token:"@milestoneURL@", value:githubApi.getMilestoneUrl(milestoneId))
}
}
}
task githubRelease, dependsOn:[generateReleaseNotes, ':cutlass-sdk:distZip', build], {
doLast {
def cutlassSdkProject = project(':cutlass-sdk')
def brjsZipPattern = "**/BladeRunnerJS-${projectBuildVersion}.zip"
def brjsZip = fileTree(dir:cutlassSdkProject.buildDir, include:brjsZipPattern).singleFile
if (projectVersionIsDirty)
{
throw new GradleException("Project version is dirty, this version (${projectBuildVersion}) cannot be released.")
}
def gitHubToken = getGitHubToken(project)
def githubApi = new GitHubAPIBridge(project, "BladeRunnerJS", "brjs", gitHubToken)
def tagVersion = org.bladerunnerjs.BuildVersionCalculator.calculateMajorVersion(project)
def releaseNoteFile = generateReleaseNotes.outputs.files.singleFile
Release release = githubApi.createReleaseForTag(tagVersion, getReleaseNoteJson(project,tagVersion), releaseNoteFile.text)
githubApi.uploadAssetForRelease(brjsZip, release)
}
}
if (org.bladerunnerjs.OSCalculator.isWin32())
{
configurations {
curlDep
}
dependencies {
curlDep dependency('curl-win32')
}
task downloadCurl, type:Copy, dependsOn:configurations.curlDep, {
from { configurations.curlDep.collect { zipTree(it) } }
into "${buildDir}/curl"
}
githubRelease.doFirst {
GitHubAPIBridge.CURL_PATH = fileTree(dir:downloadCurl.outputs.files.singleFile, include:"**/curl.exe").singleFile.path
}
githubRelease.dependsOn downloadCurl
}