forked from Leanplum/Leanplum-Android-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon-methods.gradle
More file actions
128 lines (113 loc) · 4.92 KB
/
common-methods.gradle
File metadata and controls
128 lines (113 loc) · 4.92 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Export methods by turning them into closures
ext {
COMPILE_SDK_VERSION = 27
BUILD_TOOLS_VERSION = '27.0.2'
SUPPORT_LIBRARY_VERSION = '27.0.2'
LEANPLUM_GROUP_ID = 'com.leanplum'
LEANPLUM_ARTIFACT_ID = 'leanplum'
LEANPLUM_CORE_ARTIFACT_ID = 'leanplum-core'
LEANPLUM_PUSH_ARTIFACT_ID = 'leanplum-push'
LEANPLUM_FCM_ARTIFACT_ID = 'leanplum-fcm'
LEANPLUM_GCM_ARTIFACT_ID = 'leanplum-gcm'
LEANPLUM_LOCATION_ARTIFACT_ID = 'leanplum-location'
LEANPLUM_SDK_VERSION = "$System.env.ANDROID_VERSION_STRING"
PROGUARD_FILES = 'proguard-rules.pro'
CONSUMER_PROGUARD_FILES = 'consumer-proguard-rules.pro'
pomWithXml = this.&pomWithXml
publishing_task = this.&publishing_task
pomConfig = this.&pomConfig
}
def publishing_task(libraryArtifactId, packageName) {
task makeJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('build/outputs/jar/')
include('classes.jar')
rename('classes.jar', packageName + '-release.jar')
}
publishing {
publications {
aar(MavenPublication) {
groupId LEANPLUM_GROUP_ID
version LEANPLUM_SDK_VERSION
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/" + packageName + "-release.aar")
// The publication doesn't know about our dependencies,
// so we have to manually add them to the pom.
pomWithXml(pom, 'aar')
}
jar(MavenPublication) {
groupId LEANPLUM_GROUP_ID
version LEANPLUM_SDK_VERSION
artifactId libraryArtifactId
artifact("$buildDir/outputs/jar/" + packageName + "-release.jar")
// The publication doesn't know about our dependencies,
// so we have to manually add them to the pom.
pomWithXml(pom, 'jar')
}
}
}
if (project.hasProperty('artifactoryUsername') && project.hasProperty('artifactoryPassword')) {
artifactory {
contextUrl = 'http://artifactory-upload.leanplum.com'
publish {
repository {
repoKey = 'libs-snapshot-local'
username = artifactoryUsername
password = artifactoryPassword
}
defaults {
publications('aar', 'jar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
publishPom = true
}
}
}
}
}
def pomWithXml(pom, libraryType) {
pom.withXml {
if('jar'==libraryType){
asNode().appendNode('packaging', 'aar') // Default to aar packaging.
}
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the compile dependencies (we don't want the test ones),
// adding a <dependency> node for each.
configurations.api.allDependencies.each {
pomConfig(it, dependenciesNode)
}
configurations.releaseApi.allDependencies.each {
pomConfig(it, dependenciesNode)
}
}
}
def pomConfig(itParam, dependenciesNode) {
if (itParam.group != null && itParam.name != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
if (itParam.name == 'AndroidSDKCore') {
dependencyNode.appendNode('groupId', LEANPLUM_GROUP_ID)
dependencyNode.appendNode('artifactId', LEANPLUM_CORE_ARTIFACT_ID)
dependencyNode.appendNode('version', LEANPLUM_SDK_VERSION)
} else if (itParam.name == 'AndroidSDKLocation') {
dependencyNode.appendNode('groupId', LEANPLUM_GROUP_ID)
dependencyNode.appendNode('artifactId', LEANPLUM_LOCATION_ARTIFACT_ID)
dependencyNode.appendNode('version', LEANPLUM_SDK_VERSION)
} else if (itParam.name == 'AndroidSDKPush') {
dependencyNode.appendNode('groupId', LEANPLUM_GROUP_ID)
dependencyNode.appendNode('artifactId', LEANPLUM_PUSH_ARTIFACT_ID)
dependencyNode.appendNode('version', LEANPLUM_SDK_VERSION)
} else if (itParam.name == 'AndroidSDKGcm') {
dependencyNode.appendNode('groupId', LEANPLUM_GROUP_ID)
dependencyNode.appendNode('artifactId', LEANPLUM_GCM_ARTIFACT_ID)
dependencyNode.appendNode('version', LEANPLUM_SDK_VERSION)
} else if (itParam.name == 'AndroidSDKFcm') {
dependencyNode.appendNode('groupId', LEANPLUM_GROUP_ID)
dependencyNode.appendNode('artifactId', LEANPLUM_FCM_ARTIFACT_ID)
dependencyNode.appendNode('version', LEANPLUM_SDK_VERSION)
} else {
dependencyNode.appendNode('groupId', itParam.group)
dependencyNode.appendNode('artifactId', itParam.name)
dependencyNode.appendNode('version', itParam.version)
}
}
}