@@ -5,7 +5,7 @@ plugins {
5
5
}
6
6
7
7
apply plugin : " java-library"
8
- apply plugin : " maven-publish "
8
+ apply plugin : " maven"
9
9
apply plugin : " signing"
10
10
11
11
ext { springBootVersion = " 2.1.7.RELEASE" }
@@ -70,7 +70,6 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
70
70
}
71
71
72
72
artifacts {
73
- archives jar
74
73
archives sourceJar
75
74
archives javadocJar
76
75
}
@@ -84,7 +83,6 @@ jacoco {
84
83
}
85
84
86
85
test {
87
- ignoreFailures = true
88
86
useJUnitPlatform()
89
87
finalizedBy jacocoTestReport
90
88
}
@@ -96,110 +94,53 @@ jacocoTestReport {
96
94
}
97
95
}
98
96
99
- publishing {
100
- publications {
101
- mavenJava(MavenPublication ) {
102
- customizePom(pom)
103
- groupId project. group
104
- artifactId ' spring-boot-starter-prometheus-alerts'
105
- version project. version
106
- from components. java
107
-
108
- pom. withXml {
109
- def pomFile = file(" ${ project.buildDir} /generated-pom.xml" )
110
- writeTo(pomFile)
111
- def pomAscFile = signing. sign(pomFile). signatureFiles[0 ]
112
- artifact(pomAscFile) {
113
- classifier = null
114
- extension = ' pom.asc'
115
- }
116
- }
97
+ // Build, sign, and upload
98
+ uploadArchives {
99
+ repositories {
100
+ mavenDeployer {
117
101
102
+ // Sign POM
103
+ beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
118
104
119
- artifact(sourceJar) {
120
- classifier = ' sources'
121
- }
122
- artifact(javadocJar) {
123
- classifier = ' javadoc'
105
+ // Destination
106
+ repository(url : " https://oss.sonatype.org/service/local/staging/deploy/maven2" ) {
107
+ authentication(userName : sonatypeUsername, password : sonatypePassword)
124
108
}
125
109
126
- project. tasks. signArchives. signatureFiles. each {
127
- artifact(it) {
128
- def matcher = it. file =~ / -(sources|javadoc)\. jar\. asc$/
129
- if (matcher. find()) {
130
- classifier = matcher. group(1 )
131
- } else {
132
- classifier = null
110
+ // Add required metadata to POM
111
+ pom. project {
112
+ name " spring-boot-starter-prometheus-alerts"
113
+ packaging " jar"
114
+ description " Starter for spring boot application witch catch alerts from Prometheus Alertmanager"
115
+ url " https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts"
116
+ organization {
117
+ name " com.github.mikesafonov"
118
+ url " https://github.com/MikeSafonov"
119
+ }
120
+ issueManagement {
121
+ system " GitHub"
122
+ url " https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/issues"
123
+ }
124
+ licenses {
125
+ license {
126
+ name " MIT"
127
+ url " https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/blob/master/LICENSE"
128
+ distribution " repo"
133
129
}
134
- extension = ' jar.asc'
135
130
}
136
- }
137
- }
138
- }
139
- repositories {
140
- maven {
141
- url " https://oss.sonatype.org/service/local/staging/deploy/maven2"
142
- credentials {
143
- username sonatypeUsername
144
- password sonatypePassword
145
- }
146
- }
147
- }
148
- }
149
-
150
- def customizePom (pom ) {
151
- pom. withXml {
152
- def root = asNode()
153
-
154
- // eliminate test-scoped dependencies (no need in maven central POMs)
155
- root. dependencies. removeAll { dep ->
156
- dep. scope == " test"
157
- }
158
-
159
- // add all items necessary for maven central publication
160
- root. children(). last() + {
161
- resolveStrategy = Closure . DELEGATE_FIRST
162
-
163
- description ' Starter for spring boot application witch catch alerts from Prometheus Alertmanager'
164
- name ' spring-boot-starter-prometheus-alerts'
165
- url ' https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts'
166
- organization {
167
- name ' com.github.mikesafonov'
168
- url ' https://github.com/MikeSafonov'
169
- }
170
- issueManagement {
171
- system ' GitHub'
172
- url ' https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/issues'
173
- }
174
- licenses {
175
- license {
176
- name ' MIT'
177
- url ' https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/blob/master/LICENSE'
178
- distribution ' repo'
131
+ scm {
132
+ url " https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts"
133
+ connection " scm:git:git://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts.git"
134
+ developerConnection
" scm:git:ssh://[email protected] :MikeSafonov/spring-boot-starter-prometheus-alerts.git"
179
135
}
180
- }
181
- scm {
182
- url ' https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts'
183
- connection ' scm:git:git://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts.git'
184
- developerConnection
' scm:git:ssh://[email protected] :MikeSafonov/spring-boot-starter-prometheus-alerts.git'
185
- }
186
- developers {
187
- developer {
188
- name ' Mike Safonov'
136
+ developers {
137
+ developer {
138
+ name " Mike Safonov"
139
+ organization " com.github.mikesafonov"
140
+ organizationUrl " https://github.com/MikeSafonov"
141
+ }
189
142
}
190
143
}
191
144
}
192
145
}
193
- }
194
-
195
- model {
196
- tasks. generatePomFileForMavenJavaPublication {
197
- destination = file(" $buildDir /generated-pom.xml" )
198
- }
199
- tasks. publishMavenJavaPublicationToMavenLocal {
200
- dependsOn project. tasks. signArchives
201
- }
202
- tasks. publishMavenJavaPublicationToMavenRepository {
203
- dependsOn project. tasks. signArchives
204
- }
205
- }
146
+ }
0 commit comments