This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
133 lines (111 loc) · 3.54 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
plugins {
id 'org.sonarqube' version '2.6'
id 'org.ajoberstar.grgit' version '2.2.0'
id "com.moowork.node" version "1.2.0"
}
apply plugin: 'base' // Requirede by the clean task if no other plugin that extends it exists (e.g. the Java plugin)
apply plugin: 'idea'
apply plugin: 'com.moowork.node'
apply plugin: 'jacoco'
group = 'org.sitmun'
if (project.hasProperty("customVersion")) {
version = project.customVersion
} else {
version = "${sitmun_version}"
}
repositories {
mavenLocal()
mavenCentral()
}
//bootRepackage {
// enabled = false
//}
// Dependencies to other SITMUN plugins must declared all here to facilitate using them
// in different places of this script
ext {
// Node modules
sitmunmodules = [:]
}
sonarqube {
properties {
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.organization', 'sitmun'
// I assume the default source folder is src/main/java because of the java plugin
// If that folder does not exist, adding another source (the else) does not work
// properly
properties["sonar.sources"] = 'src'
// Excluding some code which, at least most if it, is a library that probably should not have been included as code
property "sonar.exclusions", "src/main/angular-library/projects/sitmun-plugin-demo/src/lib/**/*"
}
}
/*sourceSets {
main {
resources {
srcDirs = ["$projectDir/dist", "$projectDir/src/main/resources"]
}
}
}*/
def cloneDir = file("$buildDir/plugins-src")
task clonePlugins {
description = 'Clone SITMUN plugins from GitHub".'
doLast {
if (!cloneDir.exists()) {
mkdir cloneDir
}
sitmunmodules.each { k, v ->
def targetDir = file("$cloneDir/${v.artifactId}")
if (!targetDir.exists()) {
grgit.clone {
dir = targetDir
uri = "${v.gitrepo}"
refToCheckout = "${v.version}"
}
}
}
}
}
clonePlugins.mustRunAfter clean
task installPlugins(dependsOn: clonePlugins) {
description = 'Install Plugins.'
doLast {
// It creates a temporary GradleBuild task for each sitmun dependency in sitmunmodules
// and runs the specified tasks for each
sitmunmodules.each { k,v ->
def targetDir = file("$cloneDir/${v.artifactId}/dist")
if (!targetDir.exists()) {
def tempTask = tasks.create(name: "install_module_${v.artifactId}", type: GradleBuild)
tempTask.dir = file("$cloneDir/${v.artifactId}")
tempTask.startParameter.projectProperties["customVersion"] = v.version
tempTask.tasks = [ "install" ]
tempTask.execute()
}
}
}
}
installPlugins.mustRunAfter clonePlugins
task installModules(dependsOn: [installPlugins, npmInstall]) {
doLast {
sitmunmodules.values().each {
def sourceDir = "$cloneDir/${it.artifactId}/dist"
ant.copy(todir: "node_modules") {
fileset(dir: sourceDir)
}
}
}
}
installModules.mustRunAfter installPlugins
installModules.mustRunAfter npmInstall
task npmBuildSitmunPluginDemo(type: NpmTask, dependsOn: npmInstall) {
description = 'Build module sitmun-plugin-demo.'
args = ['run-script', 'build-sitmun-plugin-demo']
}
npmBuildSitmunPluginDemo.mustRunAfter installModules
//processResources.dependsOn npmBuildSitmunPluginDemo
//processResources.mustRunAfter npmBuildSitmunPluginDemo
task install(dependsOn: 'npmBuildSitmunPluginDemo')
def cacheDir = project.hasProperty("cacheDir")? project.properties.cacheDir : "${project.buildDir}"
clean {
delete "node_modules"
delete "dist"
delete "${cacheDir}"
}