1
- // 打包: gradlew -x test clean build 成功后发布:gradlew -x test publish
1
+ // 打包: gradlew -x test clean build shadowJar 成功后发布:gradlew -x test publish
2
2
// 然后登录https://oss.sonatype.org/#stagingRepositories来查看,你的提交在未处理前,是`open`状态,然后点击`Close`按钮;然后等一会点击`Release`来发布
3
3
4
- buildscript {
5
- repositories {
6
- mavenLocal()
7
- maven { url " https://plugins.gradle.org/m2/" }
8
- mavenCentral()
9
- jcenter()
10
- }
11
- dependencies {
12
- classpath ' com.github.jengelman.gradle.plugins:shadow:2.0.4'
13
- }
4
+ plugins {
5
+ id ' com.github.johnrengelman.shadow' version ' 7.1.0'
6
+ id ' java'
7
+ id ' maven-publish'
8
+ id ' signing' // 使用signing plugin做数字签名
14
9
}
15
10
16
- apply plugin : ' java'
17
- apply plugin : ' maven-publish'
18
- apply plugin : ' com.github.johnrengelman.shadow'
19
- apply plugin : ' signing' // 使用signing plugin做数字签名
20
-
21
11
// 密码,GPG签名信息在此文件里,格式如下
22
12
/*
23
13
ext.'signing.keyId' = '密钥keyId'
@@ -33,18 +23,20 @@ defaultTasks 'shadowJar'
33
23
34
24
group = ' com.github.wjw465150' // Sonatype上的Issue里填写的`Group Id`,可以跟package路径完全不一样
35
25
version = " 2.11.4"
26
+ [compileJava, compileTestJava, javadoc]* . options* . encoding = ' UTF-8'
36
27
37
28
repositories {
38
29
mavenLocal()
39
- maven { url " https://maven.aliyun.com/nexus/content/groups/public/" } // 优先使用阿里的镜像 mavenCentral()
30
+ maven { url " https://maven.aliyun.com/nexus/content/groups/public/" } // 优先使用阿里的镜像
31
+ mavenCentral()
40
32
// flatDir(dirs: file('jarsDerectory'))
41
33
}
42
34
43
35
44
36
dependencies {
45
- compile " com.fasterxml.jackson.core:jackson-core:${ project.version} "
46
- compile " com.fasterxml.jackson.core:jackson-annotations:${ project.version} "
47
- compile " com.fasterxml.jackson.core:jackson-databind:${ project.version} "
37
+ implementation " com.fasterxml.jackson.core:jackson-core:${ project.version} "
38
+ implementation " com.fasterxml.jackson.core:jackson-annotations:${ project.version} "
39
+ implementation " com.fasterxml.jackson.core:jackson-databind:${ project.version} "
48
40
49
41
// 或者: compile fileTree(dir: "lib", includes: ["*.jar"])
50
42
}
@@ -81,12 +73,14 @@ task javadocJar(type: Jar, dependsOn: [shadowJar]) {
81
73
task sourcesJar (type : Jar ) {
82
74
from sourceSets. main. allSource
83
75
classifier = ' sources'
76
+
77
+ duplicatesStrategy = ' EXCLUDE'
84
78
}
85
79
86
80
shadowJar {
87
- baseName = project. name
88
- classifier = null
89
- version = project. version
81
+ archiveBaseName . set( project. name)
82
+ archiveClassifier . set( ' ' )
83
+ archiveVersion . set( project. version)
90
84
91
85
relocate ' com.fasterxml.jackson' , ' org.wjw.efjson.deps.com.fasterxml.jackson'
92
86
@@ -101,8 +95,7 @@ shadowJar {
101
95
attributes " Build-Version" : " ${ project.version} "
102
96
}
103
97
104
- javadoc. execute()
105
-
98
+ dependsOn javadoc
106
99
}
107
100
108
101
publishing {
0 commit comments