-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle
95 lines (79 loc) · 2.79 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
subprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
group = 'com.alkaidmc.alkaid'
// 正式版本号在 publish 设置块中
version = '@{{COMMIT_SHORT_SHA}}-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
// https://mvnrepository.com/artifact/org.jetbrains/annotations
compileOnly 'org.jetbrains:annotations:23.0.0'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
test {
useJUnitPlatform()
}
compileJava {
options.encoding = 'UTF-8'
}
compileTestJava {
options.encoding = 'UTF-8'
}
javadoc {
options.addBooleanOption('html5', true)
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding('utf-8')
}
tasks.register('sourcesJar', Jar) {
from sourceSets.main.allSource
archiveClassifier.convention('sources')
archiveClassifier.set('sources')
}
tasks.register('javadocJar', Jar) {
from javadoc
archiveClassifier.convention('javadocs')
archiveClassifier.set('javadocs')
}
publishing {
repositories {
maven {
// 处理 Release 情况下发布的包
if (project.version.toString().contains('COMMIT_SHORT_SHA')) {
// 如果 version 字符串没有被替换则表明正在 Release 发布或本地发布
// 进行重新替换版本号
version = '1.0.0'
}
url = uri((project.findProperty("repository_root_url") ?: System.getenv("REPOSITORY_ROOT_URL"))
+ (project.version.toString().endsWith('-SNAPSHOT') ? 'snapshots' : 'releases'))
credentials {
username = project.findProperty("repository_user") ?: System.getenv("REPOSITORY_USER")
password = project.findProperty("repository_token") ?: System.getenv("REPOSITORY_TOKEN")
}
}
}
publications {
mavenJava(MavenPublication) {
artifact(jar)
artifact(sourcesJar)
artifact(javadocJar)
}
}
}
}
tasks.register('collect', Copy) {
destinationDir = file('build/libs')
subprojects.each { project ->
from project.file('build/libs')
}
}