-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaven_upload.gradle
More file actions
68 lines (66 loc) · 2.26 KB
/
maven_upload.gradle
File metadata and controls
68 lines (66 loc) · 2.26 KB
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"
def RELEASE_REPOSITORY_URL = ""
def SNAPSHOT_REPOSITORY_URL = ""
def NEXUS_USERNAME = ""
def NEXUS_PASSWORD = ""
apply plugin: 'maven-publish'
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
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME
artifacts {
if (!project.plugins.hasPlugin('kotlin-android')) {
artifact tasks.named("androidSourcesJar").get()
}
}
}
Develop(MavenPublication) {
from components.debug
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = "${VERSION_NAME}-SNAPSHOT"
artifacts {
if (!project.plugins.hasPlugin('kotlin-android')) {
artifact tasks.named("androidSourcesJar").get()
}
}
}
}
}
// 显式声明任务依赖关系
tasks.matching { it.name.startsWith("generateMetadataFileFor") }.configureEach {
dependsOn tasks.named("androidSourcesJar")
}
}
// 用于打包源代码的任务
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}