-
Notifications
You must be signed in to change notification settings - Fork 15
/
publishing.gradle
155 lines (141 loc) · 5.46 KB
/
publishing.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import java.text.SimpleDateFormat
Date buildTimeAndDate = new Date()
ext {
buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
projectUrl = "https://github.com/springfox/springfox-javadoc"
bintrayUser = project.hasProperty('bintrayUsername') ?
project.property('bintrayUsername') :
System.getenv('BINTRAY_USER_NAME')
bintrayApiKey = project.hasProperty('bintrayApiKey') ?
project.property('bintrayApiKey') :
System.getenv('BINTRAY_PASSWORD')
passphrase = project.hasProperty('gpgPassphrase') ?
project.property('gpgPassphrase') :
System.getenv('GPG_PASSPHRASE')
sonatypeUser = project.hasProperty('ossUser') ?
project.property('ossUser') :
System.getenv('SONATYPE_USER_NAME')
sonatypePassword = project.hasProperty('ossPassword') ?
project.property('ossPassword') :
System.getenv('SONATYPE_PASSWORD')
}
jar {
manifest {
attributes(
'Built-By': 'Springfox',
'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")",
'Build-Date': project.buildDate,
'Build-Time': project.buildTime,
'Specification-Title': project.name,
'Specification-Version': project.version,
'Implementation-Title': project.name,
'Implementation-Version': project.name
)
//TODO: handle the package export
// instruction 'Export-Package', '!springfox.*.internal,*'
instruction 'Import-Package', "!${project.osgiManifest().symbolicName}.*,*"
instruction 'Bundle-Description', 'A library to generate documentation from javadocs'
instruction 'Bundle-DocURL', 'https://github.com/springfox/springfox-javadoc'
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
bintray {
user = project.bintrayUser
key = project.bintrayApiKey
dryRun = false //Whether to run this as dry-run, without deploying
publish = true //If version should be auto published after an upload
publications = ['mavenJava']
pkg {
repo = 'maven-repo'
name = "${project.name}"
userOrg = "springfox"
websiteUrl = "${projectUrl}"
issueTrackerUrl = "$projectUrl/issues"
vcsUrl = "${projectUrl}.git"
desc = project.description
licenses = ['Apache-2.0']
version {
vcsTag = project.version
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
//Optional. The passphrase for GPG signing'
passphrase = project.passphrase
}
mavenCentralSync {
sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
user = project.sonatypeUser
password = project.sonatypePassword
}
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom.withXml {
def devs = ['dilipkrish': '',
'rgoers' : 'Ralph Goers',
'neumaennl' : 'Martin Neumann']
def root = asNode()
root.dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each() {
it.scope*.value = 'compile'
}
root.appendNode('name', project.name)
root.appendNode('packaging', 'jar')
root.appendNode('url', project.projectUrl)
root.appendNode('description', project.description)
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', 'Apache-2.0')
license.appendNode('url', "${project.projectUrl}/LICENSE")
license.appendNode('distribution', 'repo')
root.appendNode('scm').appendNode('url', "${project.projectUrl}.git")
def developers = root.appendNode('developers')
devs.each {
def d = developers.appendNode('developer')
d.appendNode('id', it.key)
d.appendNode('name', it.value)
}
}
artifact sourcesJar
artifact javadocJar
}
}
}
artifactory {
contextUrl = 'https://oss.jfrog.org'
resolve {
repository {
repoKey = 'libs-release'
maven = true
}
}
publish {
repository {
repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
//when using oss.jfrog.org the credentials are from Bintray. For local build we expect them to be found in
//~/.gradle/gradle.properties, otherwise to be set in the build server
username = project.bintrayUser
password = project.bintrayApiKey
}
defaults {
publications('mavenJava')
}
}
}