-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.gradle
340 lines (288 loc) · 10.6 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.19"
// optional dependencies for using Spock
classpath "org.hamcrest:hamcrest-core:1.3" // only necessary if Hamcrest matchers are used
classpath "net.bytebuddy:byte-buddy:1.9.7" // allows mocking of classes (in addition to interfaces)
classpath "org.objenesis:objenesis:2.5.1" // allows mocking of classes without default constructor (together with CGLIB)
// https://mvnrepository.com/artifact/org.asciidoctor/asciidoctor-gradle-plugin
// classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.6.1'
classpath 'org.ajoberstar.git-publish:gradle-git-publish:3.0.1'
// JAX-B dependencies for JDK 9+
classpath 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.0'
classpath 'com.sun.xml.bind:jaxb-impl:3.0.0'
classpath 'javax.annotation:javax.annotation-api:1.3.2'
}
}
plugins {
id 'java-library'
id 'groovy'
id 'com.google.protobuf' version "0.8.19"
id 'idea'
id 'project-report'
id 'org.ajoberstar.git-publish' version "3.0.1"
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'signing'
id 'maven-publish'
}
group 'org.lightningj'
version '0.17.4-Beta'
description = "LightningJ - Lightning APIs for Java"
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
//gRPC
implementation 'com.google.api.grpc:proto-google-common-protos:2.31.0'
implementation 'io.netty:netty-tcnative-boringssl-static:2.0.62.Final'
api "io.grpc:grpc-netty-shaded:$grpcVersion"
implementation "io.grpc:grpc-protobuf:$grpcVersion"
implementation "io.grpc:grpc-stub:$grpcVersion"
// JSON-P
implementation 'javax.json:javax.json-api:1.1.4'
implementation 'org.glassfish:javax.json:1.1.4'
// JAX-B dependencies for JDK 9+
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.0'
implementation 'com.sun.xml.bind:jaxb-impl:3.0.0'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
// JMacaroon
// implementation 'com.github.nitram509:jmacaroons:0.3.1'
testImplementation 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.0'
testImplementation 'com.sun.xml.bind:jaxb-impl:3.0.0'
testImplementation 'javax.annotation:javax.annotation-api:1.3.2'
// mandatory dependencies for using Spock
testImplementation platform("org.spockframework:spock-bom:2.1-groovy-3.0")
testImplementation "org.spockframework:spock-core"
// optional dependencies for using Spock
testImplementation 'org.hamcrest:hamcrest-core:2.2' // only necessary if Hamcrest matchers are used
testRuntimeOnly 'net.bytebuddy:byte-buddy:1.12.17' // allows mocking of classes (in addition to interfaces)
testRuntimeOnly 'org.objenesis:objenesis:3.3' // allows mocking of classes without default constructor (together with CGLIB)
}
/*
Task for generating Lowlevel LND GRPC API
*/
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}
/**
* Adds generated High Level APIs to the list of source directories to compile.
*/
compileJava {
source += ['build/generated/source/wrapper/main/java']
}
test {
useJUnitPlatform()
}
/*
Generate High Level LDN API using custom WrapperClassGenerator in buildSrc
*/
task generateWrappers(type: WrapperClassGenerator, dependsOn:compileJava){
// When adding new protocols, remember to also add in WrapperFactory.
protocols = ["lnrpc","autopilot","chainnotifier","chainkit","invoices","router","signer","walletkit","watchtower","wtclient",
"verrpc", "walletunlocker","stateservice","dev","peers","neutrino"]
}
/*
Compile High Level LND API Java classes.
*/
task compileWrapperMessages(type: JavaCompile, dependsOn: generateWrappers){
source = compileJava.source
//classpath = files('build/classes/main')
classpath = compileJava.classpath + files('build/classes/java/main')
destinationDirectory.set(compileJava.destinationDirectory.get())
}
compileTestGroovy.dependsOn(compileWrapperMessages)
javadoc.dependsOn(compileWrapperMessages)
/*
Generate XSD of all generated High Level Message classes, fist dependency configuration then
the actual task.
*/
configurations{
xsdClassPathConf
}
dependencies {
xsdClassPathConf 'javax.json:javax.json-api:1.1.4'
xsdClassPathConf 'org.glassfish:javax.json:1.1.4'
}
task generateXSD(type: XSDGenerator, dependsOn: compileWrapperMessages){
classpath=compileJava.classpath.asPath
protocols = ["lnrpc","autopilot","chainnotifier","chainkit","invoices","router","signer","walletkit","watchtower","wtclient",
"verrpc","walletunlocker","stateservice","dev","peers","neutrino"]
}
/*
Indicates that all high level api and XSD generation should be done before 'jar' task is executed.
*/
jar.dependsOn.add(generateXSD)
//sourcesJar.dependsOn(generateProto)
/*
Adds generated source directories to be included in javadoc generation.
*/
javadoc {
source += ['build/generated/source/proto/main/grpc','build/generated/source/proto/main/java','build/generated/source/wrapper/main/java']
failOnError= false
options.outputLevel = JavadocOutputLevel.QUIET
options.addBooleanOption('Xdoclint:none', true)
}
asciidoctor {
sourceDir = file('docs')
outputDir = file('build/docs')
attributes= [stylesheet: "$projectDir/docs/stylesheets/colony.css",
toc: 'left', 'toc-title': 'Table of Contents'
]
}
task ('doc',type: Copy,dependsOn: [javadoc, asciidoctor, htmlDependencyReport, test, generateXSD]){
from('build/docs/'){
include('index.html')
}
from('build/reports/project/'){
include('dependencies/**')
}
from('build/docs/'){
include('javadoc/**')
}
from('build/reports/tests'){
include('test/**')
}
from('build/resources/main'){
include('*.xsd')
}
from('LICENSE.txt'){
}
from('docs'){
include('CNAME')
}
from('docs'){
include('lightningj-release-pubkey.asc')
}
into('build/docs/html5')
}
/*
Task for specifying for Intellij which source directories to use.
*/
idea {
module {
sourceDirs += new File('build/generated/source/proto/main/grpc')
sourceDirs += new File('build/generated/source/proto/main/java')
sourceDirs += new File('build/generated/source/wrapper/main/java')
sourceDirs += new File('build/resources/main')
sourceDirs += new File('src/examples')
contentRoot = project.projectDir
}
}
gitPublish {
// where to publish to (repo must exist)
repoUri = '[email protected]:lightningj-org/lightningj.git'
// (or 'https://github.com/ajoberstar/test-repo.git', depending on authentication)
// branch will be created if it doesn't exist
branch = 'gh-pages'
// generally, you don't need to touch this
//repoDir = file("$buildDir/somewhereelse") // defaults to $buildDir/gitPublish
// what to publish, this is a standard CopySpec
contents {
from 'build/docs/html5'
}
// what to keep in the existing branch (include=keep)
// preserve {
// include '1.0.0/**'
// exclude '1.0.0/temp.txt'
// }
// message used when committing changes
commitMessage = 'Publishing a new page' // defaults to 'Generated by gradle-git-publish'
}
task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}
javadocJar.dependsOn(asciidoctor)
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
from 'build/generated/source/proto/main/grpc'
from 'build/generated/source/proto/main/java'
from 'build/generated/source/wrapper/main/java'
}
sourcesJar.dependsOn(compileWrapperMessages)
artifacts {
archives javadocJar, sourcesJar
}
// Add integration test task, with source sets etc.
apply from: 'integrationTest.gradle'
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact tasks.sourcesJar
artifact tasks.javadocJar
pom {
name = 'lightningj'
packaging = 'jar'
// optionally artifactId can be defined here
description = 'LightningJ - Lightning APIs for Java'
url ='http://www.lightningj.org'
scm {
connection = 'https://github.com/lightningj-org/lightningj.git'
developerConnection = 'https://github.com/lightningj-org/lightningj.git'
url ='https://github.com/lightningj-org/lightningj'
}
licenses {
license {
name = 'GNU Lesser General Public License v3.0'
url = 'http://www.gnu.org/licenses/lgpl.txt'
}
}
developers {
developer {
id = 'herrvendil'
name = 'Philip Vendil'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
// Currently is only releaes published.
// To add support for snapshot releases add following logic
//url = isReleaseBuild() ? "https://oss.sonatype.org/service/local/staging/deploy/maven2/": "https://oss.sonatype.org/content/repositories/snapshots/"
url = (project.version =~ "SNAPSHOT"? "https://oss.sonatype.org/content/repositories/snapshots/" : "https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
// Use external gpg2 command to support signing by hardware keys (i.e. SmartCard) and sign only
// if build should be uploaded to Maven Central.
signing {
required { gradle.taskGraph.hasTask(publish) }
useGpgCmd()
sign publishing.publications.maven
}
signMavenPublication.onlyIf {gradle.taskGraph.hasTask(publish)}
publish.dependsOn.add(signMavenPublication)
afterEvaluate {
generateTestProto.dependsOn(compileWrapperMessages)
extractIncludeTestProto.dependsOn(compileWrapperMessages)
extractIncludeIntegrationTestProto.dependsOn(compileWrapperMessages)
compileIntegrationTestGroovy.dependsOn(compileWrapperMessages)
}