-
Notifications
You must be signed in to change notification settings - Fork 48
/
build.gradle
85 lines (69 loc) · 2.58 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
import org.ajoberstar.grgit.*
import org.apache.tools.ant.filters.ReplaceTokens
import groovy.json.JsonSlurper
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath group: 'org.ajoberstar', name: 'grgit', version: '2.2.1'
classpath group: 'com.moowork.gradle', name:'gradle-node-plugin', version: '1.2.0'
}
}
ext {
version = "3.1.0.RELEASE"
outputDirectory = "build@master.org"
}
defaultTasks 'docs'
def loadPackageJsonInformation() {
def packageSlurper = new JsonSlurper()
def packageJson = packageSlurper.parse file('package.json')
project.ext.version = packageJson.version
println 'Derived version ' + project.ext.version
}
apply plugin: 'com.moowork.node'
node {
version = '8.10.0'
npmVersion = '5.7.1'
nodeModulesDir = file("${projectDir}")
npmWorkDir = file("${projectDir}")
download = true
// Load information for package.json
loadPackageJsonInformation()
project.ext.outputDirectory = "${buildDir}/sitewhere.github.io/docs/" + project.ext.version
}
apply plugin: 'java'
// Prepare by pulling sitewhere gh-pages repository.
task beforeVuePressBuild() {
// Load username/password from Gradle properties or ENV variables.
def username = project.hasProperty('docgenUser') ? docgenUser : System.getenv('DOCGEN_USER')
def password = project.hasProperty('docgenPassword') ? docgenPassword : System.getenv('DOCGEN_PASSWORD')
// Clone SiteWhere repository.
delete "${buildDir}/sitewhere.github.io"
project.ext.gitRepository = Grgit.clone(dir: "${buildDir}/sitewhere.github.io",
uri: 'https://github.com/sitewhere/sitewhere.github.io.git', refToCheckout: 'master',
credentials: new Credentials(username, password))
// Remove existing documentation for generated version.
delete "${buildDir}/sitewhere.github.io/docs/" + project.ext.version
}
task buildVuePress(type: NpmTask, dependsOn: npmInstall) {
args = ['run', 'docs:build']
}
task buildVuePressConfig(type: Copy) {
from 'dist'
into outputDirectory
}
task docs(dependsOn: ['beforeVuePressBuild', 'buildVuePress', 'buildVuePressConfig']) {
doLast {
project.ext.gitRepository.add(patterns: ["docs/" + project.ext.version], update: false)
project.ext.gitRepository.add(patterns: ["docs/" + project.ext.version], update: true)
project.ext.gitRepository.commit(message: 'Automated documentation update.')
project.ext.gitRepository.push(refsOrSpecs: ['master'])
// Close repository.
project.ext.gitRepository.close()
}
}