-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
179 lines (163 loc) · 5.68 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
plugins {
id 'java'
/** 可对外暴露 api dependencies */
id 'java-library'
id 'maven-publish'
id 'signing'
}
group 'com.sherlocky'
version app_version
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
maven {
url huawei_cloud_maven_url
}
maven {
url maven_url
}
}
dependencies {
api 'org.slf4j:slf4j-api:1.7.26'
api 'org.apache.commons:commons-lang3:3.9'
api 'org.apache.commons:commons-collections4:4.4'
api 'org.apache.httpcomponents.client5:httpclient5-fluent:5.0'
api 'commons-codec:commons-codec:1.12'
api 'commons-io:commons-io:2.6'
// 弃用安全问题频繁的fastjson,使用jackson性能相差 20% 左右,可以接受
api 'com.fasterxml.jackson.core:jackson-databind:2.10.4'
api 'com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.4'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.4'
api 'com.fasterxml.jackson.datatype:jackson-datatype-guava:2.10.4'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.4'
api 'org.hashids:hashids:1.0.3'
api 'com.google.guava:guava:28.1-jre'
// javax.annotation.Nullable
api 'com.google.code.findbugs:jsr305:3.0.2'
api 'javax.validation:validation-api:2.0.1.Final'
api 'net.dongliu:apk-parser:2.6.10'
api 'dom4j:dom4j:1.6.1'
// logback日志实现,使用 implementation 不把依赖传递给使用者
implementation 'ch.qos.logback:logback-classic:1.2.3'
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-junit:2.0.0.0'
}
test {
enabled(false)
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
javadoc {
description = "生成jar格式的javadoc。"
// 只显示 protected 和 public 的类和成员
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
options.author = true
options.version = true
options.header = project.name
// 静默javadoc检查(比如不支持@date会报错等),jdk 8+
options.addStringOption('Xdoclint:none', '-quiet')
/**
* <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
* 防止本地打开中文乱码
*/
options.addStringOption("charset", "UTF-8")
// suppress warnings due to cross-module @see and @link references;
// note that global 'api' task does display all warnings.
logging.captureStandardError LogLevel.INFO
// suppress "## warnings" message
logging.captureStandardOutput LogLevel.INFO
// 编码一定要配置否则直接出错
options.encoding = "UTF-8"
options.charSet = "UTF-8"
}
publishing {
publications {
mavenJava(MavenPublication) {
/** 默认使用项目的group/name/version信息 */
/**
groupId = 'org.sherlocky'
artifactId = 'sherlocky-commons'
version = '0.0.1'
*/
/**
* 如果是war包填写components.web,
* 如果是jar包填写components.java,
* 不过该方法没有manifest信息(会自动附带pom依赖信息)
*/
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'sherlocky-commons'
description = 'Sherlock\'s simple common library. Need JDK 8+.'
url = 'https://github.com/sherlocky/sherlocky-commons'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
comments = 'A business-friendly OSS license'
}
}
developers {
developer {
id = 'sherlock'
name = 'Sherlock'
roles = ['Java Developer']
}
}
scm {
url = 'https://github.com/sherlocky/sherlocky-commons'
connection = 'scm:git:https://[email protected]/sherlocky/sherlocky-commons.git'
developerConnection = 'scm:git:[email protected]:sherlocky/sherlocky-commons.git'
}
}
}
}
// 发布到oss sonatype,非SNAPSHOT版必须GPG签名
repositories {
maven {
name = 'oss'
url = oss_sonatype_maven_url
credentials {
username oss_sonatype_maven_username
password oss_sonatype_maven_password
}
}
// oss snapshot 仓库,版本必须携带 -SNAPSHOT 后缀
maven {
name = 'oss-snapshot'
url = oss_sonatype_snapshot_maven_url
credentials {
username = oss_sonatype_maven_username
password = oss_sonatype_maven_password
}
}
}
/** 发布到自建maven仓库,无需签名
repositories {
maven {
url = sherlock_maven_url
credentials {
username sherlock_maven_username
password sherlock_maven_password
}
}
}
*/
/**
* GPG 签名jar包配置,注意顺序,必须在 publications 配置之后
* (因为使用了 publications 中定义的 mavenJava)
*/
signing {
sign publishing.publications.mavenJava
}
}