-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathmaven.gradle
More file actions
99 lines (87 loc) · 2.59 KB
/
Copy pathmaven.gradle
File metadata and controls
99 lines (87 loc) · 2.59 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
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
apply plugin: "maven-publish"
apply plugin: "signing"
import org.gradle.plugins.signing.Sign
def isReleaseBuild() {
return mavenVersionName.contains("SNAPSHOT") == false
}
def getReleaseRepositoryUrl() {
return hasProperty('mavenReleaseRepositoryUrl') ? mavenReleaseRepositoryUrl
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
if(hasProperty('mavenLocalRepositoryPrefix')) {
return "${mavenLocalRepositoryPrefix}${buildDir}/${mavenSnapshotRepositoryUrl}"
} else {
return hasProperty('mavenSnapshotRepositoryUrl') ? mavenSnapshotRepositoryUrl
: "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
def getRepositoryUsername() {
return hasProperty('nexusUsername') ? nexusUsername : ""
}
def getRepositoryPassword() {
return hasProperty('nexusPassword') ? nexusPassword : ""
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
allprojects { ext."signing.keyId" = "${signingKeyId}" }
allprojects { ext."signing.secretKeyRingFile" = "${signingKeyRingFile}" }
allprojects { ext."signing.password" = "${signingKeyPassword}" }
}
}
afterEvaluate { project ->
publishing {
publications {
mavenJava(MavenPublication) {
from components.release
groupId = mavenGroup
artifactId = mavenArtifactId
version = mavenVersionName
pom {
name = mavenArtifactId
description = mavenPomDescription
url = mavenPomUrl
licenses {
license {
url = mavenLicenseUrl
}
}
developers {
developer {
name = mavenDeveloperName
email = mavenDeveloperEmail
}
}
scm {
connection = mavenScmConnection
developerConnection = mavenScmDeveloperConnection
url = mavenScmUrl
}
}
}
}
repositories {
maven {
def repoUrl = isReleaseBuild()
? getReleaseRepositoryUrl()
: getSnapshotRepositoryUrl()
url = repoUrl
credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
}
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("publish") }
sign publishing.publications.mavenJava
}
task androidSourcesJar(type: Jar) {
classifier = "sources"
from android.sourceSets.main.java.sourceFiles
}
artifacts {
archives androidSourcesJar
}
}