This repository has been archived by the owner on Dec 10, 2019. It is now read-only.
forked from square/wire-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gradle-jcenter-push.gradle
141 lines (119 loc) · 4.69 KB
/
gradle-jcenter-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
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
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
task javaDocJars(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task groovyDocJars(type: Jar, dependsOn: groovydoc) {
classifier = 'groovydoc'
from groovydoc.destinationDir
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives jar
archives javaDocJars
archives groovyDocJars
archives sourcesJar
}
publishing {
publications {
maven(MavenPublication) {
groupId GROUP
version VERSION_NAME
artifactId POM_ARTIFACT_ID
artifact jar
artifact javaDocJars
artifact groovyDocJars
artifact sourcesJar
pom.withXml {
Node root = asNode()
root.appendNode('name', POM_ARTIFACT_ID)
root.appendNode('description', POM_DESCRIPTION)
root.appendNode('url', POM_URL)
def issues = root.appendNode('issueManagement')
issues.appendNode('system', 'github')
issues.appendNode('url', ISSUE_URL)
def scm = root.appendNode('scm')
scm.appendNode('url', POM_SCM_URL)
scm.appendNode('connection', POM_SCM_CONNECTION)
scm.appendNode('developerConnection', POM_SCM_DEV_CONNECTION)
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', POM_LICENCE_NAME)
license.appendNode('url', POM_LICENCE_URL)
license.appendNode('distribution', POM_LICENCE_DIST)
def developer = root.appendNode('developers').appendNode('developer')
developer.appendNode('id', POM_DEVELOPER_ID)
developer.appendNode('name', POM_DEVELOPER_NAME)
developer.appendNode('email', POM_DEVELOPER_EMAIL)
developer.appendNode('url', POM_DEVELOPER_URL)
// def properties = root.appendNode('properties')
// properties.appendNode('maven.javadoc.skip',true)
def dependenciesNode = asNode().appendNode('dependencies')
//Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.compile.allDependencies.each {
if (it.group != null && it.version != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
def getBintrayUserProperty() {
return hasProperty('BINTRAY_USER') ? BINTRAY_USER : ""
}
def getBintrayApiKeyProperty() {
return hasProperty('BINTRAY_APIKEY') ? BINTRAY_APIKEY : ""
}
def getGpgPassphraseProperty() {
return hasProperty('GPG_PASSPHRASE') ? GPG_PASSPHRASE : ""
}
def getUserTokenProperty() {
return hasProperty('USERTOKEN') ? USERTOKEN : ""
}
def getUserPasswordProperty() {
return hasProperty('USERPASSWORD') ? USERPASSWORD : ""
}
// gradle bintrayUpload
bintray {
user = getBintrayUserProperty()
key = getBintrayApiKeyProperty()
def passphrase = getGpgPassphraseProperty()
def userToken = getUserTokenProperty()
def userPassword = getUserPasswordProperty()
publications = ['maven']
dryRun = false
publish = true
pkg {
repo = 'maven'
name = POM_ARTIFACT_ID
desc = POM_NAME
websiteUrl = POM_URL
issueTrackerUrl = ISSUE_URL
vcsUrl = GIT_URL
licenses = ['Apache-2.0']
labels = ['java', 'jar', 'proto']
publicDownloadNumbers = true
version {
name = VERSION_NAME
vcsTag = VERSION_NAME
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = 'passphrase' //Optional. The passphrase for GPG signing'
}
mavenCentralSync {
sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
user = userToken //OSS user token
password = userPassword //OSS user password
close = '1'
//Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
}
}
}
}