-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: moved to maven plugin for publishing
- Loading branch information
1 parent
93a3782
commit 760ca2d
Showing
3 changed files
with
42 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ out/ | |
.idea/ | ||
*.log | ||
*-dev.properties | ||
gradle.properties | ||
.pitest/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ plugins { | |
} | ||
|
||
apply plugin: "java-library" | ||
apply plugin: "maven-publish" | ||
apply plugin: "maven" | ||
apply plugin: "signing" | ||
|
||
ext { springBootVersion = "2.1.7.RELEASE" } | ||
|
@@ -70,7 +70,6 @@ task javadocJar(type: Jar, dependsOn: javadoc) { | |
} | ||
|
||
artifacts { | ||
archives jar | ||
archives sourceJar | ||
archives javadocJar | ||
} | ||
|
@@ -84,7 +83,6 @@ jacoco { | |
} | ||
|
||
test { | ||
ignoreFailures = true | ||
useJUnitPlatform() | ||
finalizedBy jacocoTestReport | ||
} | ||
|
@@ -96,110 +94,53 @@ jacocoTestReport { | |
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
customizePom(pom) | ||
groupId project.group | ||
artifactId 'spring-boot-starter-prometheus-alerts' | ||
version project.version | ||
from components.java | ||
|
||
pom.withXml { | ||
def pomFile = file("${project.buildDir}/generated-pom.xml") | ||
writeTo(pomFile) | ||
def pomAscFile = signing.sign(pomFile).signatureFiles[0] | ||
artifact(pomAscFile) { | ||
classifier = null | ||
extension = 'pom.asc' | ||
} | ||
} | ||
// Build, sign, and upload | ||
uploadArchives { | ||
repositories { | ||
mavenDeployer { | ||
|
||
// Sign POM | ||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | ||
|
||
artifact(sourceJar) { | ||
classifier = 'sources' | ||
} | ||
artifact(javadocJar) { | ||
classifier = 'javadoc' | ||
// Destination | ||
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") { | ||
authentication(userName: sonatypeUsername, password: sonatypePassword) | ||
} | ||
|
||
project.tasks.signArchives.signatureFiles.each { | ||
artifact(it) { | ||
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/ | ||
if (matcher.find()) { | ||
classifier = matcher.group(1) | ||
} else { | ||
classifier = null | ||
// Add required metadata to POM | ||
pom.project { | ||
name "spring-boot-starter-prometheus-alerts" | ||
packaging "jar" | ||
description "Starter for spring boot application witch catch alerts from Prometheus Alertmanager" | ||
url "https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts" | ||
organization { | ||
name "com.github.mikesafonov" | ||
url "https://github.com/MikeSafonov" | ||
} | ||
issueManagement { | ||
system "GitHub" | ||
url "https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/issues" | ||
} | ||
licenses { | ||
license { | ||
name "MIT" | ||
url "https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/blob/master/LICENSE" | ||
distribution "repo" | ||
} | ||
extension = 'jar.asc' | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
url "https://oss.sonatype.org/service/local/staging/deploy/maven2" | ||
credentials { | ||
username sonatypeUsername | ||
password sonatypePassword | ||
} | ||
} | ||
} | ||
} | ||
|
||
def customizePom(pom) { | ||
pom.withXml { | ||
def root = asNode() | ||
|
||
// eliminate test-scoped dependencies (no need in maven central POMs) | ||
root.dependencies.removeAll { dep -> | ||
dep.scope == "test" | ||
} | ||
|
||
// add all items necessary for maven central publication | ||
root.children().last() + { | ||
resolveStrategy = Closure.DELEGATE_FIRST | ||
|
||
description 'Starter for spring boot application witch catch alerts from Prometheus Alertmanager' | ||
name 'spring-boot-starter-prometheus-alerts' | ||
url 'https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts' | ||
organization { | ||
name 'com.github.mikesafonov' | ||
url 'https://github.com/MikeSafonov' | ||
} | ||
issueManagement { | ||
system 'GitHub' | ||
url 'https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/issues' | ||
} | ||
licenses { | ||
license { | ||
name 'MIT' | ||
url 'https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts/blob/master/LICENSE' | ||
distribution 'repo' | ||
scm { | ||
url "https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts" | ||
connection "scm:git:git://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts.git" | ||
developerConnection "scm:git:ssh://[email protected]:MikeSafonov/spring-boot-starter-prometheus-alerts.git" | ||
} | ||
} | ||
scm { | ||
url 'https://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts' | ||
connection 'scm:git:git://github.com/MikeSafonov/spring-boot-starter-prometheus-alerts.git' | ||
developerConnection 'scm:git:ssh://[email protected]:MikeSafonov/spring-boot-starter-prometheus-alerts.git' | ||
} | ||
developers { | ||
developer { | ||
name 'Mike Safonov' | ||
developers { | ||
developer { | ||
name "Mike Safonov" | ||
organization "com.github.mikesafonov" | ||
organizationUrl "https://github.com/MikeSafonov" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
model { | ||
tasks.generatePomFileForMavenJavaPublication { | ||
destination = file("$buildDir/generated-pom.xml") | ||
} | ||
tasks.publishMavenJavaPublicationToMavenLocal { | ||
dependsOn project.tasks.signArchives | ||
} | ||
tasks.publishMavenJavaPublicationToMavenRepository { | ||
dependsOn project.tasks.signArchives | ||
} | ||
} | ||
} |