forked from Qihoo360/RePlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maven_gradle.gradle
87 lines (74 loc) · 2.44 KB
/
maven_gradle.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
def static replaceVariables(File file, String key, String value) {
if (!file.exists()) return
// 正则匹配:(?<=VER\s*=\s*\")\S*(?=\")
def regex = "(?<=${key}\\s{0,5}=\\s{0,5}\\\")\\S*(?=\\\")"
file.write((file.text =~ /${regex}/).replaceAll(value))
}
def pbUpdateVariables() {
[
"src/main/kotlin/com/qihoo360/replugin/Constants.kt"
].forEach {
replaceVariables(project.file(it), "VER", RP_VERSION)
}
}
pbUpdateVariables()
java {
withJavadocJar()
withSourcesJar()
}
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") : ""
}
publishing {
publications {
release(MavenPublication) {
from(components['java'])
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 {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
group = rootProject.ext.RP_GROUP
version = rootProject.ext.RP_VERSION
pluginBundle {
website = rootProject.ext.RP_SITE
vcsUrl = rootProject.ext.RP_GIT_URL
tags = ['Android', 'plugin', 'pluggable', '360']
}