-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
161 lines (135 loc) · 4.94 KB
/
build.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
apply plugin: 'maven-publish'
apply plugin: 'signing'
if (!project.ext.has('pubName'))
project.ext.set('pubName', false)
if (!project.ext.has('pubSources'))
project.ext.set('pubSources', true)
if (!project.ext.has('pubComponent'))
project.ext.set('pubComponent', null)
}
rootProject.ext.set('pubVersion', '0.9.14')
rootProject.ext.set('groupId', 'com.spreedly')
rootProject.ext.set('groupId', 'com.spreedly')
rootProject.buildDir = 'build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
task clean_all(type: Delete) {
delete rootProject.buildDir
}
gradle.projectsEvaluated {
def exportedProjects = [
":core-sdk",
]
task alljavadoc(type: Javadoc) {
source exportedProjects.collect { project(it).sourceSets.main.allJava }
classpath = files(exportedProjects.collect { project(it).sourceSets.main.compileClasspath })
destinationDir = file("docs")
}
subprojects {
if (project.pubName) {
print("adding pub info ${project.pubName}")
if (project.plugins.hasPlugin('android') && project.pubSources) {
task generateSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives sourcesJar
}
}
publishing {
publications {
maven(MavenPublication) {
groupId = rootProject.groupId
artifactId = project.pubName
version = rootProject.pubVersion
from(project.pubComponent ?: components.findByName('release') ?: components.findByName('java'))
}
}
repositories {
maven {
// change URLs to point to your repos, e.g. http://my.org/repo
def releasesRepoUrl = "${rootProject.buildDir}/repos/releases"
def snapshotsRepoUrl = "${rootProject.buildDir}/repos/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
maven {
name = "github"
url = uri("https://maven.pkg.github.com/spreedly/mobile-sdk-android")
credentials {
def properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
username = properties.getProperty("gpr.user") ?: System.getenv("USERNAME")
password = properties.getProperty("gpr.key") ?: System.getenv("TOKEN")
}
}
maven {
name = "branch"
url = "${rootProject.buildDir}/maven"
}
}
}
}
}
}
task cleanupMaven(type:Delete) {
delete "${rootProject.buildDir}/maven/"
followSymlinks = true
doFirst {
def buildDir = new File("${rootProject.buildDir}")
if (!buildDir.exists())
buildDir.mkdirs()
}
}
task cloneMaven(type:Exec, dependsOn:[cleanupMaven]) {
commandLine 'sh', '-c', "cd ${rootProject.buildDir}; git clone https://github.com/spreedly/mobile-sdk-android.git --no-checkout maven"
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}
task checkoutMavenBranch(type:Exec, dependsOn: [cloneMaven]) {
commandLine 'sh', '-c', "cd ${rootProject.buildDir}/maven; git checkout maven"
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}
task addMavenBranch(type:Exec) {
commandLine 'sh', '-c', "cd ${rootProject.buildDir}/maven; git add ."
}
task commitMavenBranch(type:Exec, dependsOn: [addMavenBranch]) {
commandLine 'sh', '-c', "cd ${rootProject.buildDir}/maven; git commit -m maven"
}
task pushMavenBranch(type:Exec, dependsOn: [commitMavenBranch]) {
commandLine 'sh', '-c', "cd ${rootProject.buildDir}/maven; git push"
}
task doPub(type: GradleBuild, dependsOn: checkoutMavenBranch) {
tasks = ['publishAllPublicationsToBranchRepository']
}
addMavenBranch.mustRunAfter doPub
task release(type: GradleBuild) {
tasks = ['checkoutMavenBranch', 'doPub', 'pushMavenBranch']
}
task environment(type: Exec) {
//environment 'PATH', "${environment.PATH}:/bin"
commandLine 'sh'
}