-
Notifications
You must be signed in to change notification settings - Fork 437
Expand file tree
/
Copy pathgradle-mvn-push.gradle
More file actions
37 lines (31 loc) · 1.07 KB
/
gradle-mvn-push.gradle
File metadata and controls
37 lines (31 loc) · 1.07 KB
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
apply plugin: "maven-publish"
apply plugin: "signing"
final isSnapshot = version.contains("SNAPSHOT")
publishing {
repositories {
maven {
url = (isSnapshot
? project.properties.getOrDefault("SNAPSHOT_REPOSITORY_URL", "https://central.sonatype.com/repository/maven-snapshots/")
: project.properties.getOrDefault("RELEASE_REPOSITORY_URL", "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/")
)
credentials {
username = project.properties.get("SONATYPE_NEXUS_USERNAME")
password = project.properties.get("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
signing {
// Use external gpg cmd. This makes it easy to use gpg-agent,
// to avoid being prompted for a password once per artifact.
useGpgCmd()
// If anything about signing is misconfigured, fail loudly rather than quietly continuing with
// unsigned artifacts.
required = true
}
// Only sign releases; snapshots are unsigned.
tasks.withType(Sign).configureEach {
onlyIf {
!isSnapshot && project.hasProperty("release")
}
}