-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaven_upload.gradle
68 lines (67 loc) · 2.34 KB
/
maven_upload.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
def RELEASE_REPOSITORY_URL = "http://localhost:8081/nexus/content/repositories/releases/"
def SNAPSHOT_REPOSITORY_URL = "http://localhost:8081/nexus/content/repositories/snapshots/"
def NEXUS_USERNAME = "admin"
def NEXUS_PASSWORD = "admin123"
afterEvaluate {
publishing {
repositories {
maven {
allowInsecureProtocol(true)
name("AndroidReleaseMaven")
url = RELEASE_REPOSITORY_URL
credentials {
username = NEXUS_USERNAME
password = NEXUS_PASSWORD
}
}
maven {
allowInsecureProtocol(true)
name("AndroidSnapshotMaven")
url = SNAPSHOT_REPOSITORY_URL
credentials {
username = NEXUS_USERNAME
password = NEXUS_PASSWORD
}
}
}
publications {
Production(MavenPublication) {
from components.release
artifact androidSourcesJar //打包源码,去除这行打的包将看不到源码
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME
}
Develop(MavenPublication) {
from components.debug
artifact androidSourcesJar //打包源码,去除这行打的包将看不到源码
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = "${VERSION_NAME}-SNAPSHOT"
}
}
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
// 用于打包源代码的任务
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
archiveClassifier.set('javadoc')
from androidJavadocs.destinationDir
}
//解决 JavaDoc 中文注释生成失败的问题
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}