-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.gradle
181 lines (154 loc) · 5.32 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
import java.text.SimpleDateFormat
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.9.24'
id "application"
id "distribution"
id "idea"
id "jacoco"
id "com.github.johnrengelman.shadow" version "8.1.1"
id "com.diffplug.spotless" version "6.25.0"
id "de.undercouch.download" version "4.1.2"
id "de.marcphilipp.nexus-publish" version "0.4.0"
id 'io.codearte.nexus-staging' version '0.30.0'
}
description 'Web3j command line tools'
mainClassName = 'org.web3j.console.Web3j'
applicationName = 'web3j'
ext {
web3jVersion = '4.12.3'
picocli = '4.7.6'
slf4jVersion = '2.0.13'
junitVersion = '5.9.3'
mockitoVersion = '5.12.0'
mockitoInline = '5.2.0'
gsonVersion = '2.11.0'
wireMockVersion = '3.6.0'
kotlinLoggin = '3.0.5'
dockerJavaVersion = '3.3.6'
log4jVersion = '2.23.1'
semverVersion = '0.10.2'
commonsLangVersion = '3.14.0'
jansiVersion = '2.4.1'
kotlinPoetVersion = '1.18.1'
javaPoetVersion = '1.13.0'
}
apply {
[
'jacoco',
'java',
'javadoc',
'repositories',
'publish',
'spotless'
].each { buildScript ->
download {
src "https://raw.githubusercontent.com/web3j/build-tools/master/gradle/$buildScript/build.gradle"
dest "$rootDir/gradle/$buildScript/build.gradle"
overwrite false
quiet true
onlyIfModified true
}
from("$rootDir/gradle/$buildScript/build.gradle")
}
}
repositories {
mavenCentral()
mavenLocal()
maven { url "https://dl.bintray.com/ethereum/maven/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
distZip {
archiveFileName.set("web3j-${project.version}.zip")
}
distTar {
archiveFileName.set("web3j-${project.version}.tar")
}
dependencies {
api "org.web3j:abi:$web3jVersion"
implementation "org.web3j:codegen:$web3jVersion",
"org.web3j:contracts:$web3jVersion",
"org.web3j:core:$web3jVersion",
"org.web3j:crypto:$web3jVersion",
"org.web3j:hosted-providers:$web3jVersion",
"info.picocli:picocli:$picocli",
"com.squareup:kotlinpoet:$kotlinPoetVersion",
"com.squareup:javapoet:$javaPoetVersion",
files('libs/smartcheck.jar'),
"com.google.code.gson:gson:$gsonVersion",
"org.apache.commons:commons-lang3:$commonsLangVersion",
"com.github.zafarkhaja:java-semver:$semverVersion",
"org.apache.logging.log4j:log4j-core:$log4jVersion",
"io.github.microutils:kotlin-logging:$kotlinLoggin",
"com.github.docker-java:docker-java:$dockerJavaVersion",
"org.fusesource.jansi:jansi:$jansiVersion"
runtimeOnly "org.slf4j:slf4j-nop:$slf4jVersion"
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion",
"org.mockito:mockito-core:$mockitoVersion",
"org.mockito:mockito-inline:$mockitoInline",
"org.wiremock:wiremock:$wireMockVersion"
}
task createProperties(dependsOn: processResources) doLast {
// if resources dir is empty we need to create this ourselves
new File("$buildDir/resources/main/").mkdirs()
new File("$buildDir/resources/main/web3j-version.properties").withWriter { w ->
Properties p = new Properties()
p['version'] = project.version.toString()
p['timestamp'] = getTimestamp()
p.store w, null
}
}
def getTimestamp() {
Date today = new Date()
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(today)
}
classes { dependsOn createProperties }
task shadowBugWorkaround(type: Jar) {
archiveBaseName.set('nested-gradle-jar')
from files(file("${rootDir}/gradle/wrapper/gradle-wrapper.jar"))
destinationDirectory.set(file('build/shadow-bug-workaround'))
}
shadowJar {
dependsOn shadowBugWorkaround
zip64 = true
// Shadow plugin bug: explodes the nested jar.
// Workaround: double-nest the jar.
// Refer https://github.com/johnrengelman/shadow/issues/111
from shadowBugWorkaround
}
sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
}
compileKotlin {
kotlinOptions.jvmTarget = "17"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "17"
}
sourceCompatibility = 17
def generatedResources = "$buildDir/generated-resources/main"
sourceSets {
main {
// Register an output folder on the main source set:
output.dir(generatedResources, builtBy: 'generateVersionProperties')
}
}
task generateVersionProperties {
description 'Creates a version.properties file with build info that is added to the root of the JAR'
doLast {
new File(generatedResources).mkdirs()
def generated = new File(generatedResources, "version.properties")
generated.write("version=$rootProject.version\n")
generated.append("timestamp=${System.currentTimeMillis()}\n")
}
}
tasks.named("spotlessJava").configure { dependsOn("javadoc","sourcesJar","compileTestJava","compileTestKotlin") }
tasks.named("spotlessKotlin").configure { dependsOn("compileKotlin","sourcesJar","compileTestKotlin") }