-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
228 lines (201 loc) · 6.54 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
// Apply the java-library plugin to add support for Java Library
plugins {
id 'maven-publish'
id 'java-library'
id 'java'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.sherter.google-java-format' version '0.9'
}
println("Notice: current gradle version is " + gradle.gradleVersion)
// Additional attribute definition
repositories {
mavenCentral()
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
ext {
if (!project.hasProperty("ossrhUsername")) {
ossrhUsername = "xxx"
}
if (!project.hasProperty("ossrhPassword")) {
ossrhPassword = "xxx"
}
// jackson version
jacksonVersion = '2.17.0'
javapoetVersion = '1.13.0'
picocliVersion = '4.7.6'
junitVersion = '4.13.2'
commonsLang3Version = '3.14.0'
javaSDKVersion3 = "3.8.0"
javaSDKVersion2 = "2.10.0"
slf4jVersion = "1.7.36"
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/resources'
}
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
// check.dependsOn integrationTest
// integrationTest.mustRunAfter test
allprojects {
group = 'org.fisco-bcos.code-generator'
version = '1.6.0'
apply plugin: 'maven-publish'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'signing'
sourceCompatibility = 1.8
targetCompatibility = 1.8
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }
maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
api("org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:${javaSDKVersion2}") {
transitive = false
}
api("org.fisco-bcos.java-sdk:fisco-bcos-java-sdk-v3:${javaSDKVersion3}") {
transitive = false
}
api("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")
api("com.squareup:javapoet:${javapoetVersion}")
api("info.picocli:picocli:${picocliVersion}")
api("org.slf4j:slf4j-api:${slf4jVersion}")
api("org.apache.commons:commons-lang3:${commonsLang3Version}")
testImplementation("junit:junit:${junitVersion}")
testImplementation('org.mockito:mockito-core:5.11.0')
}
clean.doLast {
file("dist/apps/").deleteDir()
file("dist/conf/").deleteDir()
file("dist/lib/").deleteDir()
}
}
googleJavaFormat {
toolVersion = '1.7'
options style: 'AOSP'
source = sourceSets*.allJava
include '**/*.java'
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId "bcos-" + project.name
groupId project.group
version project.version
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'fisco-bcos'
description = 'fisco-bcos ABI code generator.'
url = 'http://www.fisco-bcos.org'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'zhangsan'
name = 'zhangsan'
email = '[email protected]'
}
}
scm {
connection = 'https://github.com/FISCO-BCOS/ABICodeGenerator.git'
url = 'https://github.com/FISCO-BCOS/ABICodeGenerator.git'
}
}
}
}
repositories {
maven {
def releasesRepoURL = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoURL = "https://oss.sonatype.org/content/repositories/snapshots"
url = !version.endsWith("SNAPSHOT") ? releasesRepoURL : snapshotsRepoURL
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
signing {
sign publishing.publications.mavenJava
}
}
jar {
// destinationDir file('dist/apps')
archiveName "bcos-" + project.name + '-' + project.version + '.jar'
exclude '**/*.xml'
exclude '**/*.properties'
manifest {
try {
def repo = grgit.open(currentDir: project.rootDir)
if (repo != null) {
def date = new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
def branch = repo.branch.getCurrent().getName()
def commit = repo.head().getAbbreviatedId(40)
attributes(["Implementation-Timestamp": date,
"Git-Branch" : branch,
"Git-Commit" : commit
])
logger.info(" Commit : ")
logger.info(" => date: {}", date)
logger.info(" => branch: {}", branch)
logger.info(" => commit: {}", commit)
}
} catch (Exception e) {
logger.warn(' .git not exist, cannot found commit info, e: {}', e)
}
} from sourceSets.main.output
doLast {
copy {
from destinationDirectory
into 'dist/apps'
}
copy {
from configurations.runtimeClasspath
into 'dist/lib'
}
copy {
from file('src/test/resources/log4j.properties')
into 'dist/conf'
}
}
}