This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathbuild.gradle
141 lines (120 loc) · 5.84 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
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.5.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
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.3"
compileSdkVersion = 30
targetSdkVersion = 30
minSdkVersion = 21
appCompat = 'androidx.appcompat:appcompat:1.3.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.3.0'
espressoCore = 'androidx.test.espresso:espresso-core:3.3.0'
espressoIdlingResource = 'androidx.test.espresso.idling:idling-concurrent:3.3.0'
fragment = 'androidx.fragment:fragment:1.3.5'
fragmentKtx = 'androidx.fragment:fragment-ktx:1.3.5'
kotlin = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
ktxCore = 'androidx.core:core-ktx:1.5.0'
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.1'
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()
}
}
task incrementalPublish {
def libProps = project.ext.libProps
def artifactExists = { params ->
// githubUrl, moduleName, version, true
def group = libProps['groupId'].replace(".", "/")
def url = "${params['downloadUrl']}/${group}/${params['moduleName']}/${params['version']}/${params['moduleName']}-${params['version']}.pom"
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
connection.setRequestProperty("Authorization", params['auth'])
connection.connect()
def exists = connection.getResponseCode() == HttpURLConnection.HTTP_OK
println "pom for ${params['moduleName']} exists on $url}: ${exists}"
return exists
}
catch (ignored) {
println "Unable to configure incremental publish for ${name}, check your internet connection"
return null
}
}
project.afterEvaluate {
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"
}
}
}
}
}