Skip to content

Commit 760ca2d

Browse files
committed
build: moved to maven plugin for publishing
1 parent 93a3782 commit 760ca2d

File tree

3 files changed

+42
-100
lines changed

3 files changed

+42
-100
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ out/
55
.idea/
66
*.log
77
*-dev.properties
8+
gradle.properties
89
.pitest/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ addons:
66
sonarcloud:
77
organization: "mikesafonov-github"
88
install:
9-
- ./gradlew build
9+
- ./gradlew build -x signArchives
1010
script:
1111
- sonar-scanner
1212

build.gradle

Lines changed: 40 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
apply plugin: "java-library"
8-
apply plugin: "maven-publish"
8+
apply plugin: "maven"
99
apply plugin: "signing"
1010

1111
ext { springBootVersion = "2.1.7.RELEASE" }
@@ -70,7 +70,6 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
7070
}
7171

7272
artifacts {
73-
archives jar
7473
archives sourceJar
7574
archives javadocJar
7675
}
@@ -84,7 +83,6 @@ jacoco {
8483
}
8584

8685
test {
87-
ignoreFailures = true
8886
useJUnitPlatform()
8987
finalizedBy jacocoTestReport
9088
}
@@ -96,110 +94,53 @@ jacocoTestReport {
9694
}
9795
}
9896

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 {
117101

102+
// Sign POM
103+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
118104

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)
124108
}
125109

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"
133129
}
134-
extension = 'jar.asc'
135130
}
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"
179135
}
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+
}
189142
}
190143
}
191144
}
192145
}
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

Comments
 (0)