-
-
Notifications
You must be signed in to change notification settings - Fork 616
/
gradle-release.gradle
112 lines (95 loc) · 3.78 KB
/
gradle-release.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
apply plugin: 'maven-publish'
apply plugin: 'signing'
ext["signing.keyId"] = project.hasProperty('sonatype.gpg.key') ? project.property('sonatype.gpg.key') : System.getenv('SONATYPE_GPG_KEY')
ext["signing.password"] = project.hasProperty('sonatype.gpg.password') ? project.property('sonatype.gpg.password') : System.getenv('SONATYPE_GPG_PASS')
ext["signing.secretKeyRingFile"] = project.hasProperty('sonatype.gpg.secretKeyRingFile') ? project.property('sonatype.gpg.secretKeyRingFile') : System.getenv('SONATYPE_GPG_FILE')
@SuppressWarnings("GroovyUnusedDeclaration")
def getRepositoryUsername() {
return project.hasProperty('NEXUS_USERNAME') ? project.property('NEXUS_USERNAME') : System.getenv('NEXUS_USERNAME')
}
@SuppressWarnings("GroovyUnusedDeclaration")
def getRepositoryPassword() {
return project.hasProperty('NEXUS_PASSWORD') ? project.property('NEXUS_PASSWORD') : System.getenv('NEXUS_PASSWORD')
}
afterEvaluate { project ->
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
task androidJavadocs(type: Javadoc) {
failOnError = false
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
archiveClassifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
archiveClassifier = 'sources'
from android.sourceSets.main.java.source
}
def pomConfig = {
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email '[email protected]'
}
}
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
}
afterEvaluate {
generateMetadataFileForReleasePublication.dependsOn androidSourcesJar
}
publishing {
publications {
release(MavenPublication) {
from components.release
groupId GROUP
artifactId POM_ARTIFACT_ID
version android.defaultConfig.versionName
artifact androidJavadocsJar
pom.withXml {
asNode().appendNode('name', POM_NAME)
asNode().appendNode('description', POM_DESCRIPTION)
asNode().appendNode('url', POM_SCM_URL)
asNode().children().last() + pomConfig
// we want dependencies as compile, to ensure they are transitively resolved
if (!POM_ARTIFACT_ID.endsWith("-typeface")) {
asNode().dependencies.'*'.findAll() { it.scope.text() == 'runtime' }.each { it.scope*.value = 'compile' }
}
}
}
}
repositories {
maven {
name = "sonatype"
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username getRepositoryUsername()
password getRepositoryPassword()
}
}
}
}
}
signing {
sign publishing.publications
}