-
Notifications
You must be signed in to change notification settings - Fork 10
/
publish.gradle
74 lines (68 loc) · 2.52 KB
/
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
apply plugin: 'maven'
apply plugin: 'maven-publish'
if (project.plugins.hasPlugin("com.android.library")) {
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
} else if (project.plugins.hasPlugin("java")) {
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.java.srcDirs
}
} else if (project.plugins.hasPlugin("groovy")) {
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.groovy.srcDirs
}
}
if (project.tasks['sourcesJar']) {
artifacts {
archives sourcesJar
}
}
publishing {
repositories {
mavenLocal()
}
publications {
maven(MavenPublication) {
Properties properties = new Properties()
InputStream inputStream = project.file('local.properties').newDataInputStream()
properties.load(inputStream)
artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar"
groupId properties.getProperty("sdk_groupId")
artifactId properties.getProperty("sdk_artifactId")
version properties.getProperty("sdk_version")
}
}
}
uploadArchives {
repositories {
Properties properties = new Properties()
InputStream inputStream = project.file('local.properties').newDataInputStream()
properties.load(inputStream)
def localMaven = Boolean.valueOf(properties.getProperty("localBuild"))
mavenDeployer {
if (localMaven) {
snapshotRepository(url: uri("${rootDir}/.publish"))
repository(url: uri("${rootDir}/.publish"))
} else {
def USERNAME = properties.getProperty("user_name")
def PASSWORD = properties.getProperty("user_pwd")
if (USERNAME != null && PASSWORD != null) {
snapshotRepository(url: properties.getProperty("SNAPSHOT_REPOSITORY_URL")) {
authentication(userName: USERNAME, password: PASSWORD)
}
repository(url: properties.getProperty("RELEASE_REPOSITORY_URL")) {
authentication(userName: USERNAME, password: PASSWORD)
}
}
}
pom.packaging = 'aar'
pom.version = properties.getProperty("sdk_version")
pom.groupId = properties.getProperty("sdk_groupId")
pom.artifactId = properties.getProperty("sdk_artifactId")
}
}
}