forked from opendxl/opendxl-streaming-client-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
265 lines (228 loc) · 7.06 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath 'org.owasp:dependency-check-gradle:6.2.2'
}
}
plugins {
id 'checkstyle'
id 'java-library'
id 'distribution'
id 'maven-publish'
id 'signing'
id "com.github.johnrengelman.shadow" version "4.0.3"
id "kr.motd.sphinx" version "2.3.1"
id "jacoco"
id "org.owasp.dependencycheck" version "6.2.2"
}
apply plugin: 'base'
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'org.owasp.dependencycheck'
group 'com.opendxl'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencyCheck {
suppressionFile = file("${projectDir}/config/dependency-check/owasp-suppression.xml")
}
jacoco {
toolVersion = "0.8.6"
reportsDir = file("$buildDir/reports/coverage")
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("$buildDir/reports/coverage")
}
}
dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.23.2'
testImplementation 'org.mockito:mockito-all:1.10.19'
implementation 'com.e-movimento.tinytools:privilegedaccessor:1.2.2'
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.apache.logging.log4j:log4j-api:2.16.0'
implementation 'org.apache.logging.log4j:log4j-core:2.16.0'
}
// Jar Manifest info
jar {
manifest {
attributes 'Main-Class': 'com.opendxl.streaming.cli.CommandLineInterface',
'Implementation-Title': project.name,
'Implementation-Version': project.version
}
}
// Task for creating a jar with the source files
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
// Task for creating a jar with JavaDoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
source = sourceSets.main.allJava
options.memberLevel = JavadocMemberLevel.PUBLIC
}
artifacts {
archives jar
archives sourceJar
archives javadocJar
}
// Set up the distribution zip
distributions {
main {
baseName = 'dxlstreamingclient-java-sdk'
contents {
from(jar) {
into('lib')
}
from(shadowJar) {
into("lib")
}
from(configurations.compileClasspath) {
into("lib/3rdparty")
}
from(sphinx) {
into('doc')
}
from('sample') {
into 'sample'
}
from(shadowJar) {
into("sample/lib")
}
from('distribution')
}
}
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/java'
}
}
sample {
java {
srcDir 'sample/src'
}
compileClasspath += main.output + configurations.compileClasspath
runtimeClasspath += main.output + configurations.runtimeClasspath
}
test {
resources {
srcDir 'src/test/resources'
}
}
}
// Make check style run before creating a jar
jar.dependsOn(checkstyleMain)
// Force distZip to be dependent on javadocJar and sourceJar
distZip.dependsOn javadocJar
distZip.dependsOn sourceJar
sphinx {
// Change the source directory.
sourceDirectory = "${projectDir}/docs"
// Change the output directory.
outputDirectory = "${project.buildDir}/docs"
}
task versionFile() {
doLast {
new File("${projectDir}/VERSION").text = """$version"""
}
}
checkstyle {
sourceSets = []
toolVersion '8.39'
}
publishing {
publications {
maven(MavenPublication) {
groupId = group
pom {
name = 'OpenDXL Streaming Java Client'
description = 'An OpenDXL streaming client library for Java'
url = 'https://github.com/opendxl/opendxl-streaming-client-java'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/opendxl/opendxl-streaming-client-java.git'
developerConnection = 'scm:git:ssh://github.com/opendxl/opendxl-streaming-client-java.git'
url = 'https://github.com/opendxl/opendxl-streaming-client-java'
}
}
from components.java
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
}
}
repositories {
maven {
url = "$buildDir/repo"
// def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
// def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
// credentials {
// username sonatypeUsername
// password sonatypePassword
// }
}
}
}
// Replace version string in some files that contains version reference
task replaceVersionInREADME() {
if (!version.endsWith('SNAPSHOT')) {
// Maven
ant.replaceregexp(match: '<version>(.+)</version>', replace: "<version>${version}</version>", flags: 'g', byline: true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(match: '<version>(.+)</version>', replace: "<version>${version}</version>", flags: 'g', byline: true) {
fileset(dir: 'docs', includes: 'index.rst')
}
// Gradle
ant.replaceregexp(match: "com\\.opendxl\\.:dxlstreamingclient\\:(.+)", replace: "com.opendxl:dxlstreamingclient:${version}'", flags: 'g', byline: true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(match: "com\\.opendxl\\:dxlstreamingclient\\:(.+)", replace: "com.opendxl:dxlstreamingclient:${version}'", flags: 'g', byline: true) {
fileset(dir: 'docs', includes: 'index.rst')
}
}
}
signing {sign publishing.publications.maven}
check.dependsOn dependencyCheckAnalyze
distZip.dependsOn javadocJar
distZip.dependsOn sourceJar
sphinx.dependsOn(versionFile)
assemble.dependsOn(replaceVersionInREADME)