-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathbuild.gradle
More file actions
149 lines (134 loc) · 5.41 KB
/
build.gradle
File metadata and controls
149 lines (134 loc) · 5.41 KB
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
plugins {
id 'idea'
id 'eclipse'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.jk1.dependency-license-report' version '2.0' // 2.1 requires Java 11
id "com.github.ben-manes.versions" version "0.46.0"
id 'distribution'
}
// NOTE: version is specified in gradle.properties
// NOTE: All dependencies should be specified in platform/build.gradle
defaultTasks ':distZip'
// A resolvable configuration to collect test reports data from subprojects
configurations {
testReportData {
canBeResolved = true
canBeConsumed = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'test-report-data'))
}
}
}
project.ext {
// to exclude storage plugins, set project property storage.excludes with a list of storage plugin short-names separated by comma
// e.g. -Pstorage.excludes="nfs,azure"
storageIncludes = []
// exclude nfs storage-plugin by default due to CVEs introduced by transient dependency (Netty 3.10.6.Final) from com.emc.ecs:nfs-client
storageExcludes = ['nfs']
if (project.hasProperty('storage.excludes')) {
storageExcludes = []
storageExcludes.addAll(project.property('storage.excludes').split(','))
}
file("${rootProject.projectDir}/storage-plugins").eachDir {
if (storageExcludes.contains(it.name.split('-storage')[0])) {
logger.warn("storage-plugin project ${it.name} is excluded.")
} else {
storageIncludes.add(it.name.split('-model')[0])
logger.info("Added storage-plugin project ${it.name}.")
}
}
storageIncludes.unique()
// to exclude filter plugins, set project property filter.excludes with a list of plugin names separated by comma
// e.g. -Pfilter.excludes="cas-extractors,fs-filters"
filterIncludes = []
filterExcludes = []
if (project.hasProperty('filter.excludes')) {
filterExcludes.addAll(project.property('filter.excludes').split(','))
}
file("${rootProject.projectDir}/filter-plugins").eachDir {
if (filterExcludes.contains(it.name.split('-model')[0])) {
logger.warn("filter-plugin project ${it.name} is excluded.")
} else {
filterIncludes.add(it.name.split('-model')[0])
logger.info("Added filter-plugin project ${it.name}.")
}
}
filterIncludes.unique()
}
// depend on testReportData from all subprojects
dependencies {
testReportData project(':ecs-sync-cli')
testReportData project(':ecs-sync-core')
testReportData project(':ecs-sync-ctl')
testReportData project(':ecs-sync-model')
file('storage-plugins').eachDir {
testReportData project(":storage-plugins:${it.name}")
}
file('filter-plugins').eachDir {
testReportData project(":filter-plugins:${it.name}")
}
}
// use the "testReport" task to generate an aggregated JUnit report
tasks.register('testReport', TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Use test results from testReportData configuration
testResultDirs.from(configurations.testReportData)
}
import com.github.jk1.license.render.*
licenseReport {
renderers = [new InventoryHtmlReportRenderer(), new CsvReportRenderer()]
}
generateLicenseReport.dependsOn subprojects.collect { it.tasks.withType(JavaCompile) }
distributions {
main {
contents {
from 'readme.txt'
from 'license.txt'
from 'license'
into('3rd-party-licenses') {
from generateLicenseReport
}
from { project(':ecs-sync-cli').shadowJar }
from { customPluginListFile }
from { project(':ecs-sync-ctl').shadowJar }
from 'script'
into('samples') {
from 'sample'
}
/*
into('docker') {
from 'docker'
}
*/
}
}
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
dependencyUpdates {
revision = 'release'
checkForGradleUpdate = true
gradleReleaseChannel = 'current'
checkConstraints = true
checkBuildEnvironmentConstraints = true
rejectVersionIf {
isNonStable(it.candidate.version) || it.candidate.version == '20040117.000000' // bogus commons-cli version
}
}
task customPluginListFile {
def outputFile = new File(buildDir, "custom-plugin-package.txt")
if (outputFile.exists()) outputFile.delete()
outputs.file(outputFile)
doLast {
if (!project.ext.storageExcludes.isEmpty() || !project.ext.filterExcludes.isEmpty()) {
outputFile.write("Storage-Plugin-Includes: " + project.ext.storageIncludes.toString().replace("[", "").replace("]", "").replace("-storage", "") + "\n")
outputFile.append("Storage-Plugin-Excludes: " + project.ext.storageExcludes.toString().replace("[", "").replace("]", "") + "\n")
outputFile.append("Filter-Plugin-Includes: " + project.ext.filterIncludes.toString().replace("[", "").replace("]", "") + "\n")
outputFile.append("Filter-Plugin-Excludes: " + project.ext.filterExcludes.toString().replace("[", "").replace("]", "") + "\n")
}
}
}