-
Notifications
You must be signed in to change notification settings - Fork 28
/
deployment.gradle
92 lines (84 loc) · 3.2 KB
/
deployment.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
import org.gradle.plugins.signing.Sign
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
allprojects { ext."signing.keyId" = System.getenv('GPG_KEY_ID') }
allprojects { ext."signing.secretKeyRingFile" = System.getenv('GPG_KEY_LOCATION') }
allprojects { ext."signing.password" = System.getenv('GPG_PASSPHRASE') }
}
// Do not sign archives by default (a local build without gpg keyring should succeed)
if (taskGraph.allTasks.any { it.name == 'build' || it.name == 'assemble' }) {
tasks.findAll { it.name == 'signArchives' || it.name == 'signDocsJar' || it.name == 'signTestJar' }.each { task ->
task.enabled = false
}
}
}
signing
{
sign publishing.publications
}
project.afterEvaluate {
publishing
{
publications
{
mavenJava(MavenPublication)
{
from components.java
artifact javadocJar
artifact sourcesJar
artifact shaded
artifact fat
pom
{
name = project_name
packaging = 'jar'
// optionally artifactId can be defined here
description = project_description
url = project_url
scm {
connection = project_scm
developerConnection = project_scm
url = project_url
}
licenses {
license {
name = project_license_slug
url = project_license_url
}
}
developers {
developer {
id = project_developer
name = project_developer
}
}
}
}
}
repositories {
maven {
url = layout.buildDirectory.dir("deploy")
}
}
}
}
// Scripted hack, inpired from:
// https://github.com/h2oai/sparkling-water/tree/3f8fcf387a2bcc080343a8fafdc81aebc0d99fa1/gradle/publish
// and
// https://github.com/h2oai/sparkling-water/blob/73d2e2bd11ce35c6379f6961188fb2af1a7bc04b/build.gradle#L228
// and
// https://support.sonatype.com/hc/en-us/articles/213465868-Uploading-to-a-Staging-Repository-via-REST-API
// and
// https://support.sonatype.com/hc/en-us/articles/213465448-Automatically-dropping-old-staging-repositories
// Until either this one works for us: https://github.com/marcphilipp/nexus-publish-plugin
// or this issue is fixed another way:
// https://github.com/travis-ci/travis-ci/issues/9555
def uploadAndRelease(def username, def password, def repoDir) {
def proc = ['./uploadAndRelease.sh', username, password, repoDir].execute([], file("${rootDir.toString()}/gradle"))
proc.waitForProcessOutput(System.out, System.err)
}
task publishToNexusAndClose(dependsOn: 'publish'){
doLast {
uploadAndRelease(System.getenv('SONATYPE_USERNAME'), System.getenv('SONATYPE_PASSWORD'), "$rootDir/build/deploy")
}
}