forked from h6ah4i/android-advancedrecyclerview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathandroid-maven-publish.gradle
111 lines (95 loc) · 3.5 KB
/
android-maven-publish.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
/*
* Copyright (C) 2015 Haruki Hasegawa
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'maven'
apply plugin: 'signing'
// Declare these properties in project's extension
// - ext.mavenPublishDestDir = [path to destination directory]
// - ext.mavenPublishDataFile = [path to data properties file]
// - ext.mavenPublishSigningSetting = [path to signing info properties file] (optional)
def repoDir = project.mavenPublishDestDir
def dataProps = new Properties()
dataProps.load(project.file(project.mavenPublishDataFile).newDataInputStream())
task cleanDocsOutDir(type: Delete) {
delete project.docsDir
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
excludes += '**/BuildConfig.java'
excludes += '**/R.java'
options.encoding "utf-8"
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
afterEvaluate {
androidJavadocs.classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
androidJavadocs.classpath += project.android.libraryVariants.toList().first().javaCompile.classpath
}
signing {
// load 'keyId', 'password' and 'secretKeyRingFile'
def propsFile = project.file(project.mavenPublishSigningSetting)
if (propsFile.exists()) {
def props = new Properties()
props.load(propsFile.newDataInputStream())
if (props.keyId != null &&
props.password != null &&
props.secretKeyRingFile != null) {
project.ext.keyId = props.keyId
project.ext.password = props.password
project.ext.secretKeyRingFile = props.secretKeyRingFile
}
}
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "file://${repoDir}")
pom.groupId = dataProps.POM_GROUP_ID
pom.artifactId = dataProps.POM_ARTIFACT_ID
pom.version = dataProps.VERSION_NAME
pom.project {
licenses {
license {
name dataProps.POM_APACHE_V2_LICENCE_NAME
url dataProps.POM_APACHE_V2_LICENCE_URL
distribution dataProps.POM_APACHE_V2_LICENCE_DIST
}
}
scm {
url dataProps.POM_SCM_URL
connection dataProps.POM_SCM_CONNECTION
developerConnection dataProps.POM_SCM_DEVELOPER_CONNECTION
}
developers {
developer {
id dataProps.POM_DEVELOPER_ID
name dataProps.POM_DEVELOPER_NAME
}
}
}
}
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}