1
+ /*
2
+ * Copyright 2013 Chris Banes
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
apply plugin : ' maven'
2
18
apply plugin : ' signing'
3
19
4
- configurations {
5
- archives {
6
- extendsFrom configurations. default
7
- }
20
+ def isReleaseBuild () {
21
+ return VERSION_NAME . contains(" SNAPSHOT" ) == false
8
22
}
9
23
10
- def sonatypeRepositoryUrl
11
- if (isReleaseBuild()) {
12
- println ' RELEASE BUILD'
13
- sonatypeRepositoryUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
14
- } else {
15
- println ' DEBUG BUILD'
16
- sonatypeRepositoryUrl = " https://oss.sonatype.org/content/repositories/snapshots/"
24
+ def getReleaseRepositoryUrl () {
25
+ return hasProperty(' RELEASE_REPOSITORY_URL' ) ? RELEASE_REPOSITORY_URL
26
+ : " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
17
27
}
18
28
19
- if (ext. properties. containsKey(' signing.keyId' ) && ! ext. properties. containsKey(' signing.password' )) {
20
- if (System . console())
21
- ext. set(' signing.password' , System . console(). readPassword(" \n\$ Type in GPG key password: " ))
22
- else
23
- ext. set(' signing.password' , ' dummy' )
29
+ def getSnapshotRepositoryUrl () {
30
+ return hasProperty(' SNAPSHOT_REPOSITORY_URL' ) ? SNAPSHOT_REPOSITORY_URL
31
+ : " https://oss.sonatype.org/content/repositories/snapshots/"
24
32
}
25
33
26
- if (System . env. TERM != ' dumb' && ! ext. properties. containsKey(' nexusPassword' )) {
27
- if (System . console())
28
- ext. set(' nexusPassword' , new String (System . console(). readPassword(" \n\$ Type in password for Sonatype nexus account ${ nexusUsername} : " )))
29
- else
30
- ext. set(' nexusPassword' , ' dummy' )
34
+ def getRepositoryUsername () {
35
+ return hasProperty(' NEXUS_USERNAME' ) ? NEXUS_USERNAME : " "
36
+ }
37
+
38
+ def getRepositoryPassword () {
39
+ return hasProperty(' NEXUS_PASSWORD' ) ? NEXUS_PASSWORD : " "
31
40
}
32
41
33
42
afterEvaluate { project ->
@@ -36,10 +45,15 @@ afterEvaluate { project ->
36
45
mavenDeployer {
37
46
beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
38
47
48
+ pom. groupId = GROUP
39
49
pom. artifactId = POM_ARTIFACT_ID
50
+ pom. version = VERSION_NAME
40
51
41
- repository(url : sonatypeRepositoryUrl) {
42
- authentication(userName : nexusUsername, password : nexusPassword)
52
+ repository(url : getReleaseRepositoryUrl()) {
53
+ authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
54
+ }
55
+ snapshotRepository(url : getSnapshotRepositoryUrl()) {
56
+ authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
43
57
}
44
58
45
59
pom. project {
@@ -64,12 +78,8 @@ afterEvaluate { project ->
64
78
65
79
developers {
66
80
developer {
67
- id " loopj"
68
- name " James Smith"
69
- }
70
- developer {
71
- id " smarek"
72
- name " Marek Sebera"
81
+ id POM_DEVELOPER_ID
82
+ name POM_DEVELOPER_NAME
73
83
}
74
84
}
75
85
}
@@ -82,9 +92,14 @@ afterEvaluate { project ->
82
92
sign configurations. archives
83
93
}
84
94
85
- task androidJavadocsJar(type : Jar , dependsOn : generateReleaseJavadoc) {
95
+ task androidJavadocs(type : Javadoc ) {
96
+ source = android. sourceSets. main. allJava
97
+ classpath + = project. files(android. getBootClasspath(). join(File . pathSeparator))
98
+ }
99
+
100
+ task androidJavadocsJar(type : Jar , dependsOn : androidJavadocs) {
86
101
classifier = ' javadoc'
87
- from generateReleaseJavadoc . destinationDir
102
+ from androidJavadocs . destinationDir
88
103
}
89
104
90
105
task androidSourcesJar(type : Jar ) {
@@ -93,7 +108,6 @@ afterEvaluate { project ->
93
108
}
94
109
95
110
artifacts {
96
- archives androidReleaseJar
97
111
archives androidSourcesJar
98
112
archives androidJavadocsJar
99
113
}
0 commit comments