forked from randoop/randoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradle-mvn-push.gradle
102 lines (87 loc) · 2.89 KB
/
gradle-mvn-push.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
93
94
95
96
97
98
99
100
101
102
apply plugin: 'maven-publish'
apply plugin: 'signing'
final isSnapshot = version.contains('SNAPSHOT')
final sharedPublicationConfiguration(publication) {
publication.pom {
url = 'https://randoop.github.io/randoop/'
developers {
// These are the lead developers, not all the contributors.
developer {
id = 'mernst'
name = 'Michael Ernst'
email = '[email protected]'
url = 'https://homes.cs.washington.edu/~mernst/'
organization = 'University of Washington'
organizationUrl = 'https://www.cs.washington.edu/'
}
}
scm {
url = 'https://github.com/randoop/randoop'
connection = 'scm:git:git://github.com/randoop/randoop.git'
developerConnection = 'scm:git:ssh://[email protected]/randoop/randoop.git'
}
licenses {
license {
name = 'The MIT License'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
}
}
publishing {
publications {
remote(MavenPublication) {
sharedPublicationConfiguration it
}
local(MavenPublication) {
sharedPublicationConfiguration it
}
}
repositories {
maven {
url = (isSnapshot
? project.properties.getOrDefault('SNAPSHOT_REPOSITORY_URL', 'https://oss.sonatype.org/content/repositories/snapshots/')
: project.properties.getOrDefault('RELEASE_REPOSITORY_URL', 'https://oss.sonatype.org/service/local/staging/deploy/maven2/')
)
credentials {
username = project.properties.get('SONATYPE_NEXUS_USERNAME')
password = project.properties.get('SONATYPE_NEXUS_PASSWORD')
}
}
maven {
name = 'fakeRemote'
url = "file://$rootProject.buildDir/maven-fake-remote-repository"
}
}
}
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 publications sent to remote repositories; local install installations are unsigned.
// The `sign` invocation below causes eager creation of three tasks per subproject:
// `signRemotePublication` is created immediately and `generateMetadataFileForRemotePublication`
// and `generatePomFileForRemotePublication` are created during configuration. Creating these
// lazily instead will require a fix to <https://github.com/gradle/gradle/issues/8796>.
sign publishing.publications.remote
}
// Only sign releases; snapshots are unsigned.
tasks.withType(Sign).configureEach {
onlyIf {
!isSnapshot
}
}
tasks.withType(PublishToMavenRepository).configureEach {
onlyIf {
publication == publishing.publications.remote
}
}
tasks.withType(PublishToMavenLocal).configureEach {
onlyIf {
publication == publishing.publications.local
}
}