-
Notifications
You must be signed in to change notification settings - Fork 583
/
build.gradle
192 lines (159 loc) · 5.45 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
180
181
182
183
184
185
186
187
188
189
190
191
192
import static org.gradle.kotlin.dsl.KotlinDependencyExtensionsKt.embeddedKotlinVersion
buildscript {
ext.kotlin_version = embeddedKotlinVersion
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
classpath "io.johnsonlee.buildprops:buildprops-gradle-plugin:1.1.0"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.10.1"
}
}
def OSSRH_USERNAME = project.properties['OSSRH_USERNAME'] ?: System.getenv('OSSRH_USERNAME')
def OSSRH_PASSWORD = project.properties['OSSRH_PASSWORD'] ?: System.getenv('OSSRH_PASSWORD')
def OSSRH_STAGING_PROFILE_ID = project.properties['OSSRH_STAGING_PROFILE_ID'] ?: System.getenv('OSSRH_STAGING_PROFILE_ID')
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'io.github.gradle-nexus.publish-plugin'
allprojects { project ->
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'maven-publish'
group = 'com.didiglobal.booster'
version = findProperty('version').with { it != DEFAULT_VERSION ? it : null } ?: '1.0.0-SNAPSHOT'
repositories {
mavenLocal()
google()
mavenCentral()
}
sourceSets {
main {
kotlin {
srcDirs += ['src/main/kotlin', 'src/main/java', 'build/generated/source/buildprops/main/java']
}
}
test {
kotlin {
srcDirs += ['src/main/kotlin', 'src/main/java', 'build/generated/source/buildprops/main/java']
}
}
}
javadoc {
failOnError = false
}
task packageJavadoc(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
}
task packageSources(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives packageJavadoc, packageSources
}
test {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}
def configurePublication = { MavenPublication publication ->
groupId = project.group
artifactId = project.name
version = project.version
if ("mavenJava" == publication.name) {
from components.java
}
artifact project.packageSources {
archiveClassifier.set("sources")
}
artifact project.packageJavadoc {
archiveClassifier.set("javadoc")
}
pom {
name = project.name
url = 'https://github.com/didi/booster'
description = project.description ?: project.name
scm {
connection = 'scm:git:git://github.com/didi/booster.git'
developerConnection = 'scm:git:[email protected]:didi/booster.git'
url = 'https://github.com/didi/booster'
}
licenses {
license {
name = 'Apache License'
url = 'https://www.apache.org/licenses/LICENSE-2.0'
}
}
withXml { xml ->
(['git', 'log', '--format=%aN %aE'].execute() | ['sort', '-u'].execute()).with {
waitForOrKill(5000)
if (0 == exitValue()) {
def developers = xml.asNode().appendNode('developers')
text.eachLine { line ->
def sp = line.lastIndexOf(' ')
if (sp > 0) {
def id = line.substring(0, sp).trim()
def email = line.substring(sp + 1).trim()
developers.appendNode('developer').with {
appendNode('id', id)
appendNode('email', email)
}
}
}
}
}
}
}
if (!project.hasProperty("signing.skip")) {
apply plugin: 'signing'
def signingTasks = project.tasks.withType(Sign)
project.tasks.withType(PublishToMavenLocal) {
dependsOn signingTasks
}
project.tasks.withType(PublishToMavenRepository) {
dependsOn signingTasks
}
project.signing {
sign publication
}
}
}
project.afterEvaluate {
publishing {
publications {
if (project.plugins.hasPlugin('java-gradle-plugin')) {
withType(MavenPublication).configureEach(configurePublication)
} else {
mavenJava(MavenPublication, configurePublication)
}
}
}
}
}
subprojects { project ->
rootProject.clean.dependsOn project.clean
}
dependencies {
implementation project(':booster-gradle-plugin')
}
nexusPublishing {
packageGroup = "com.didiglobal"
repositories {
sonatype {
username = OSSRH_USERNAME
password = OSSRH_PASSWORD
stagingProfileId = OSSRH_STAGING_PROFILE_ID
}
}
clientTimeout = Duration.ofSeconds(300)
connectTimeout = Duration.ofSeconds(60)
transitionCheckOptions {
maxRetries.set(3000)
delayBetween.set(Duration.ofMillis(3000))
}
}