-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
194 lines (159 loc) · 6.51 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
import java.nio.file.Files
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
apply plugin: 'java'
apply from: LOGSTASH_CORE_PATH + "/../rubyUtils.gradle"
// ===========================================================================
// plugin info
// ===========================================================================
group 'com.ibm.guardium.saphana' // must match the package of the main plugin class
version "${file("VERSION").text.trim()}" // read from required VERSION file
description = "saphana-Guardium filter plugin"
pluginInfo.licenses = ['Apache-2.0'] // list of SPDX license IDs
pluginInfo.longDescription = "This gem is a Logstash saphana filter plugin required to be installed as part of IBM Security Guardium, Guardium Universal connector configuration. This gem is not a stand-alone program."
pluginInfo.authors = ['IBM']
pluginInfo.email = ['']
pluginInfo.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
pluginInfo.pluginType = "filter"
pluginInfo.pluginClass = "SapHanaGuardiumPluginFilter"
pluginInfo.pluginName = "saphana_guardium_plugin_filter" // must match the @LogstashPlugin annotation in the main plugin class
// ===========================================================================
sourceCompatibility = 1.8
targetCompatibility = 1.8
def jacocoVersion = '0.8.4'
// minimumCoverage can be set by Travis ENV
def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%"
if (minimumCoverageStr.endsWith("%")) {
minimumCoverageStr = minimumCoverageStr.substring(0, minimumCoverageStr.length() - 1)
}
def minimumCoverage = Float.valueOf(minimumCoverageStr) / 100
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2"
}
}
repositories {
mavenCentral()
}
tasks.register("vendor"){
dependsOn shadowJar
doLast {
String vendorPathPrefix = "vendor/jar-dependencies"
String projectGroupPath = project.group.replaceAll('\\.', '/')
File projectJarFile = file("${vendorPathPrefix}/${projectGroupPath}/${pluginInfo.pluginFullName()}/${project.version}/${pluginInfo.pluginFullName()}-${project.version}.jar")
projectJarFile.mkdirs()
Files.copy(file("$buildDir/libs/${project.name}-${project.version}.jar").toPath(), projectJarFile.toPath(), REPLACE_EXISTING)
validatePluginJar(projectJarFile, project.group)
}
}
apply plugin: 'com.github.johnrengelman.shadow'
shadowJar {
classifier = null
}
dependencies {
implementation group: 'commons-validator', name: 'commons-validator', version: '1.7'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'com.google.code.gson:gson:2.8.9'
//implementation fileTree(dir: LOGSTASH_CORE_PATH, include: "build/libs/logstash-core-*.*.*.jar")
implementation fileTree(dir: LOGSTASH_BIN_PATH, include: "logstash-core/lib/jars/logstash-core.jar")
//implementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "common-*.*.*.jar")
//implementation 'com.google.code.gson:gson:2.8.9'
testImplementation 'junit:junit:4.12'
testImplementation 'org.jruby:jruby-complete:9.2.7.0'
testImplementation group: 'com.github.javafaker', name: 'javafaker', version: '0.15'
//testImplementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "guardium-universalconnector-commons-?.?.?.jar")
}
clean {
delete "${projectDir}/Gemfile"
delete "${projectDir}/" + pluginInfo.pluginFullName() + ".gemspec"
delete "${projectDir}/lib/"
delete "${projectDir}/vendor/"
new FileNameFinder().getFileNames(projectDir.toString(), pluginInfo.pluginFullName() + "-*.*.*.gem").each { filename ->
delete filename
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.register("generateRubySupportFiles") {
doLast {
generateRubySupportFilesForPlugin(project.description, project.group, version)
}
}
tasks.register("removeObsoleteJars") {
doLast {
new FileNameFinder().getFileNames(
projectDir.toString(),
"vendor/**/" + pluginInfo.pluginFullName() + "*.jar",
"vendor/**/" + pluginInfo.pluginFullName() + "-" + version + ".jar").each { f ->
delete f
}
}
}
tasks.register("gem"){
dependsOn = [downloadAndInstallJRuby, removeObsoleteJars, vendor, generateRubySupportFiles]
doLast {
buildGem(projectDir, buildDir, pluginInfo.pluginFullName() + ".gemspec")
}
}
apply plugin: 'jacoco'
//apply plugin: 'org.barfuin.gradle.jacocolog' version '2.0.0'
apply plugin: "org.barfuin.gradle.jacocolog"
// ------------------------------------
// JaCoCo is a code coverage tool
// ------------------------------------
jacoco {
toolVersion = "${jacocoVersion}"
reportsDir = file("$buildDir/reports/jacoco")
}
jacocoTestReport {
// You will see "Report -> file://...." at the end of a JaCoCo build
// If no output, run this first: ./gradlew test
reports {
html.enabled true
xml.enabled true
csv.enabled true
html.destination file("${buildDir}/reports/jacoco")
csv.destination file("${buildDir}/reports/jacoco/all.csv")
}
executionData.from fileTree(dir: "${buildDir}/jacoco/", includes: [
'**/*.exec'
])
afterEvaluate {
// objective is to test TicketingService class
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [])
}))
}
doLast {
println "Report -> file://${buildDir}/reports/jacoco/index.html"
}
}
test.finalizedBy jacocoTestReport
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = minimumCoverage
}
}
}
executionData.from fileTree(dir: "${buildDir}/jacoco/", includes: [
'**/*.exec'
])
afterEvaluate {
// objective is to test TicketingService class
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [])
}))
}
}
project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport)