-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
76 lines (64 loc) · 1.87 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
buildscript {
ext {
tagsoupVersion = '1.2.1'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.ccil.cowan.tagsoup:tagsoup:$tagsoupVersion"
}
}
plugins {
id 'groovy'
id 'com.moowork.node' version '1.2.0'
id 'com.github.ben-manes.versions' version '0.20.0'
}
group 'daggerok'
version '1.0.2'
node {
download = true
version = '10.15.0'
npmVersion = '5.10.0'
}
defaultTasks 'clean', 'build'
build.dependsOn npm_i, npm_t
static def fixPathOnWindows(def path) {
path.replaceAll('\\\\', '/')
}
import groovy.xml.StreamingMarkupBuilder
import org.ccil.cowan.tagsoup.Parser
build.doLast {
def reports = project
.file(fixPathOnWindows("$projectDir/newman"))
.listFiles()
.collect({ file -> file.absolutePath })
.findAll({ absolutePath -> absolutePath.endsWith('.html') })
.collect({ pathToHtmlReport -> fixPathOnWindows(pathToHtmlReport) })
.collect({ fixedPathToReport -> file(fixedPathToReport) })
.collect({ htmlReport -> htmlReport.text })
.collect({ html ->
def parser = new Parser()
parser.setFeature('http://xml.org/sax/features/namespaces', false)
def root = new XmlSlurper(parser).parseText(html)
new StreamingMarkupBuilder().bindNode(root.body.div[0]).toString()
})
.join('<br/>')
def templatePath = fixPathOnWindows("$projectDir/src/main/html/report.html")
def template = file(templatePath).text
def reportDir = file(fixPathOnWindows("$buildDir/postman"))
reportDir.mkdirs()
file("$reportDir/index.html").text = template.replace('%REPLACEMENT%', reports)
println("""report located here: ${fixPathOnWindows("$buildDir/postman/index.html")}""")
}
clean.doFirst {
[
"$projectDir/newman",
"$projectDir/node_modules"
].each { delete "$it" }
}
wrapper {
gradleVersion = '5.1.1'
distributionType = Wrapper.DistributionType.BIN
}