forked from tunjid/Android-Extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
157 lines (134 loc) · 6.5 KB
/
build.gradle
File metadata and controls
157 lines (134 loc) · 6.5 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
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
import groovy.json.JsonSlurper
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:2.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
project.ext {
buildToolsVersion = "29.0.2"
compileSdkVersion = 29
targetSdkVersion = 29
minSdkVersion = 21
appCompat = 'androidx.appcompat:appcompat:1.2.0'
cardView = 'androidx.cardview:cardview:1.0.0'
constraintLayout = 'androidx.constraintlayout:constraintlayout:2.0.4'
dynamicAnimations = 'androidx.dynamicanimation:dynamicanimation:1.1.0-alpha03'
dynamicAnimationsKtx = 'androidx.dynamicanimation:dynamicanimation-ktx:1.0.0-alpha03'
espressoContrib = 'androidx.test.espresso:espresso-contrib:3.5.1'
espressoCore = 'androidx.test.espresso:espresso-core:3.5.1'
espressoIdlingResource = 'androidx.test.espresso.idling:idling-concurrent:3.5.1'
fragment = 'androidx.fragment:fragment:1.3.3'
fragmentKtx = 'androidx.fragment:fragment-ktx:1.3.3'
kotlin = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
ktxCore = 'androidx.core:core-ktx:1.3.2'
lifeCycleReactiveStreams = 'androidx.lifecycle:lifecycle-reactivestreams:2.3.1'
lifecycleSavedState = 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1'
lifecycleViewModel = 'androidx.lifecycle:lifecycle-viewmodel:2.3.1'
material = 'com.google.android.material:material:1.3.0'
mockitoAndroid = 'org.mockito:mockito-android:2.23.0'
mockitoCore = 'org.mockito:mockito-core:2.23.0'
palette = 'androidx.palette:palette:1.0.0'
recyclerView = 'androidx.recyclerview:recyclerview:1.2.0'
savedState = 'androidx.savedstate:savedstate:1.1.0'
supportAnnotations = 'androidx.annotation:annotation:1.2.0'
swipeRefreshLayout = 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
testCore = 'androidx.test:core:1.3.0'
viewpager2 = 'androidx.viewpager2:viewpager2:1.0.0'
// Artifactory publishing params
libProps = new Properties()
signingProps = new Properties()
localProps = new Properties()
libProps.load(new FileInputStream(file("libraryVersion.properties")))
groupId = libProps['groupId']
artifactoryUrl = libProps['artifactoryUrl']
def publishInfoFile = file("publishInfo.json")
def publishInfoProperty = project.findProperty('publishInfoJson')
publishInfo = publishInfoFile.exists()
? new JsonSlurper().parse(publishInfoFile)
: publishInfoProperty
? new JsonSlurper().parseText(publishInfoProperty)
: [:]
versionSuffix = publishInfo['versionSuffix'] ?: ''
publishRepositories = publishInfo['repositories'] ?: []
}
}
// Plugin used to upload authenticated files to BinTray through Gradle
plugins {
id 'signing'
}
allprojects {
repositories {
google()
jcenter()
}
}
project.afterEvaluate {
tasks.register('incrementalPublish') {
if (!file("publishInfo.json").exists()) {
throw new GradleException("publishInfo.json not found. Check the README for instructions")
}
def libProps = project.ext.libProps
def artifactExists = { params ->
// githubUrl, moduleName, version, true
def group = libProps['groupId'].replace(".", "/")
def moduleName = params['moduleName']
def version = params['version']
def url = "${params['downloadUrl']}/${group}/${moduleName}/${version}/${moduleName}-${version}"
def fileTypes = ['aar', 'pom']
try {
// Check AAR AND POM
for (String fileType : fileTypes) {
def urlWithType = "${url}.${fileType}"
HttpURLConnection connection = (HttpURLConnection) new URL(urlWithType).openConnection()
connection.setRequestProperty("Authorization", params['auth'])
connection.setRequestMethod("HEAD")
connection.connect()
def exists = connection.getResponseCode() == HttpURLConnection.HTTP_OK
println "Artifact check for ${moduleName}-${version}: ${fileType} exists: ${exists}"
if (exists) {
return true
}
}
return false
}
catch (exception) {
println "Unable to configure incremental publish ${exception}"
return null
}
}
libProps.stringPropertyNames()
.findAll { name -> name.contains('version') }
.each { name ->
project.ext.publishRepositories.each { repo ->
def moduleName = name - '_version'
def versionSuffix = repo["versionSuffix"] ?: ""
def username = repo['credentials']['username']
def password = repo['credentials']['password']
def encoded = Base64.getEncoder().encodeToString(("${username}:${password}").getBytes("UTF-8"))
def auth = "Basic ${encoded}"
def params = [
publishUrl : repo['publishUrl'],
downloadUrl: repo['downloadUrl'],
moduleName : moduleName,
version : libProps[name] + (versionSuffix.isEmpty() ? "" : "-${versionSuffix}"),
auth : auth
]
def existsOnGitHub = artifactExists(params)
def publishGithub = existsOnGitHub != null && !existsOnGitHub
if (publishGithub) {
println "Adding task ${moduleName} to publish on ${repo['name']}"
dependsOn ":${moduleName}:assemble"
dependsOn ":${moduleName}:publishLibPublicationTo${repo['name']}Repository"
}
}
}
}
}