forked from Qihoo360/RePlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maven_publish.gradle
88 lines (74 loc) · 2.62 KB
/
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
task androidJavadocs(type: Javadoc) {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompileProvider.get().classpath
}
}
exclude '**/R.html', '**/R.*.html', '**/index.html'
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
archiveClassifier.set('javadoc')
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.hasProperty("android")) {
from android.sourceSets.main.java.srcDirs
} else {
from sourceSets.main.allSource
}
}
def getLocalProperties() {
Properties localProperties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream();
localProperties.load(inputStream)
return localProperties
}
def getReleaseRepositoryUrl() {
Properties localProperties = getLocalProperties()
return localProperties.containsKey('RELEASE_REPOSITORY_URL') ? localProperties.get("RELEASE_REPOSITORY_URL") : ""
}
def getSnapshotRepositoryUrl() {
Properties localProperties = getLocalProperties()
return localProperties.containsKey('SNAPSHOT_REPOSITORY_URL') ? localProperties.get("SNAPSHOT_REPOSITORY_URL") : ""
}
def getRepositoryUsername() {
Properties localProperties = getLocalProperties()
return localProperties.containsKey('SONATYPE_NEXUS_USERNAME') ? localProperties.get("SONATYPE_NEXUS_USERNAME") : ""
}
def getRepositoryPassword() {
Properties localProperties = getLocalProperties()
return localProperties.containsKey('SONATYPE_NEXUS_PASSWORD') ? localProperties.get("SONATYPE_NEXUS_PASSWORD") : ""
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
artifact androidJavadocsJar
artifact androidSourcesJar
groupId = rootProject.ext["RP_GROUP"]
artifactId = project.name
version = rootProject.ext["RP_VERSION"]
}
}
repositories {
maven {
url getSnapshotRepositoryUrl()
credentials {
username getRepositoryUsername()
password getRepositoryPassword()
}
}
}
}
// signing {
// sign publishing.publications.release
// }
// javadoc {
// }
}