11plugins {
22 id ' java'
3+ id ' java-library'
4+ id ' maven-publish'
5+ id ' signing'
36}
47
58group ' cn.byteforge.openqq'
6- version ' 1.0.0-SNAPSHOT'
9+ version ' 0.1.0'
10+
11+ [compileJava, compileTestJava, javadoc]* . options* . encoding = ' UTF-8'
12+ sourceCompatibility = 1.8
13+ targetCompatibility = 1.8
714
815repositories {
916 mavenLocal()
@@ -27,4 +34,116 @@ dependencies {
2734
2835test {
2936 useJUnitPlatform()
37+ }
38+
39+ task sourcesJar (type : Jar ) {
40+ from sourceSets. main. allJava
41+ classifier = ' sources'
42+ }
43+
44+ task javadocJar (type : Jar ) {
45+ from javadoc
46+ classifier = ' javadoc'
47+ }
48+
49+ tasks. withType(Jar ). configureEach { task ->
50+ task. doLast {
51+ ant. checksum algorithm : ' md5' , file : it. archivePath
52+ ant. checksum algorithm : ' sha1' , file : it. archivePath
53+ }
54+ }
55+
56+ javadoc {
57+ description = " 生成jar格式的javadoc。"
58+ // 只显示 protected 和 public 的类和成员
59+ options. memberLevel = JavadocMemberLevel . PROTECTED
60+ options. author = true
61+ options. version = true
62+ options. header = project. name
63+ // 静默javadoc检查(比如不支持@date会报错等),jdk 8+
64+ options. addStringOption(' Xdoclint:none' , ' -quiet' )
65+ /**
66+ * <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
67+ * 防止本地打开中文乱码
68+ */
69+ options. addStringOption(" charset" , " UTF-8" )
70+ // suppress warnings due to cross-module @see and @link references;
71+ // note that global 'api' task does display all warnings.
72+ logging. captureStandardError LogLevel . INFO
73+ // suppress "## warnings" message
74+ logging. captureStandardOutput LogLevel . INFO
75+ // 编码一定要配置否则直接出错
76+ options. encoding = " UTF-8"
77+ options. charSet = " UTF-8"
78+ }
79+
80+ publishing {
81+ publications {
82+ mavenJava(MavenPublication ) {
83+ /* * 默认使用项目的group/name/version信息 */
84+ /**
85+ groupId = ''
86+ artifactId = ''
87+ version = ''
88+ */
89+ /**
90+ * 如果是war包填写components.web,
91+ * 如果是jar包填写components.java,
92+ * 不过该方法没有manifest信息(会自动附带pom依赖信息)
93+ */
94+ from components. java
95+ artifact sourcesJar
96+ artifact javadocJar
97+ pom {
98+ name = project. name
99+ description = ' openqq-protocol 是在与官方qq机器人协议对接的基础上,额外onebot、satori等社区协议进行的适配sdk实现。'
100+ url = ' https://github.com/IUnlimit/openqq-protocol'
101+ licenses {
102+ license {
103+ name = ' AGPLv3'
104+ url = ' https://www.gnu.org/licenses/agpl-3.0'
105+ }
106+ }
107+ developers {
108+ developer {
109+ id = ' IllTamer'
110+ email = ' mail@illtamer.com'
111+ }
112+ }
113+ scm {
114+ url = ' https://github.com/IUnlimit/openqq-protocol'
115+ connection = ' scm:git:https://github.com/IUnlimit/openqq-protocol.git'
116+ }
117+ }
118+ }
119+ }
120+
121+ repositories {
122+ // 发布到oss sonatype,非SNAPSHOT版必须GPG签名
123+ maven {
124+ name = ' oss'
125+ url = oss_sonatype_maven_url
126+ credentials {
127+ username oss_sonatype_maven_username
128+ password oss_sonatype_maven_password
129+ }
130+ }
131+ // oss snapshot 仓库,必须携带 -SNAPSHOT 后缀
132+ maven {
133+ name = ' oss-snapshot'
134+ url = oss_sonatype_snapshot_maven_url
135+ credentials {
136+ username = oss_sonatype_maven_username
137+ password = oss_sonatype_maven_password
138+ }
139+ }
140+ }
141+
142+ /**
143+ * GPG 签名jar包配置,注意顺序,必须在 publishing 配置之后
144+ * (因为使用了 publishing 中定义的 mavenJava)
145+ */
146+ signing {
147+ sign publishing. publications. mavenJava
148+ }
30149}
0 commit comments