-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
149 lines (130 loc) · 4.73 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
// 编译脚本
buildscript {
ext {
depVersion = [
springBoot: "2.7.2",
jaxb : "2.3.1",
okhttp : "4.10.0",
fastjson2 : "2.0.10",
log4j2 : "2.18.0",
lombok : "1.18.24"
]
}
// 仓库配置
repositories {
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/spring' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${depVersion.springBoot}")
}
}
allprojects {
group = "cool.doudou"
version = "2.0.0-SNAPSHOT"
}
// 子模块配置
subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'io.spring.dependency-management'
// 仓库配置
repositories {
mavenLocal()
mavenCentral()
maven { url "https://maven.aliyun.com/repository/central" }
maven { url "https://maven.aliyun.com/repository/spring" }
maven { url "https://maven.aliyun.com/repository/google" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
configurations {
all*.exclude group: "spring-boot-starter-logging"
all*.exclude module: "spring-boot-starter-tomcat"
}
// 依赖管理
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${depVersion.springBoot}"
}
}
dependencies {
compileOnly("org.apache.logging.log4j:log4j-core:${depVersion.log4j2}")
compileOnly("org.apache.logging.log4j:log4j-slf4j-impl:${depVersion.log4j2}")
// lombok
compileOnly("org.projectlombok:lombok:${depVersion.lombok}")
annotationProcessor("org.projectlombok:lombok:${depVersion.lombok}")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc
classifier = 'javadoc'
}
// 解决javadoc打包乱码
javadoc {
options.encoding = "UTF-8"
options.charSet = "UTF-8"
options.author = true
options.version = true
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.name
version "${version}"
// components.java jar包 || components.auth war包
from components.java
artifact sourcesJar
artifact javadocJar
// 添加 pom 相关信息
// https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html
pom {
name = "wechat-assistant"
description = "Wechat Assistant"
url = "https://github.com/jiangchengshi/wechat-assistant"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "jiangcs"
name = "这么诚实"
email = "[email protected]"
}
}
// 版本控制仓库地址
scm {
url = 'https://github.com/jiangchengshi/wechat-assistant.git'
connection = 'scm:git:git://github.com/jiangchengshi/wechat-assistant.git'
developerConnection = 'scm:git:ssh://[email protected]:jiangchengshi/wechat-assistant.git'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
}