Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
212 lines (184 loc) · 6.5 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
212 lines (184 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import java.util.Locale
buildscript {
repositories {
google()
mavenCentral()
}
}
repositories {
mavenLocal()
mavenCentral()
google()
}
plugins {
`java-library`
`maven-publish`
signing
alias(libs.plugins.publish)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.jlleitschuh.ktlint)
alias(libs.plugins.ben.manes.versions)
}
group = "dev.gitlive"
version = project.property("version") as String
java {
sourceCompatibility = JavaVersion.VERSION_17
}
val aar by configurations.creating
val copyAars by tasks.registering(Copy::class) {
mkdir("build/aar")
from(configurations["aar"]) {
include("*.aar")
}
into("build/aar")
}
val extractClasses by tasks.registering(Copy::class) {
dependsOn(copyAars)
configurations["aar"].forEach { aarFile ->
copy {
from(zipTree(aarFile))
include("classes.jar")
fileMode = 0b01110110000
rename("classes.jar", aarFile.nameWithoutExtension + ".jar")
into("build/jar")
}
}
}
tasks {
compileKotlin {
dependsOn(extractClasses)
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
withType<Sign>().configureEach {
onlyIf { !project.gradle.startParameter.taskNames.any { "MavenLocal" in it } }
}
javadoc {
exclude("android/**", "libcore/util/**")
}
test {
// Tests keep Firebase's data in per-test folders here until the next run
val testData = layout.buildDirectory.dir("test-data")
doFirst { delete(testData) }
}
}
val jar by tasks.getting(Jar::class) {
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter {
it.path.startsWith("${projectDir.path}${File.separator}build${File.separator}jar")
}.map { zipTree(it) }
})
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
val sourceSets = project.the<SourceSetContainer>()
val cleanLibs by tasks.creating(Delete::class) {
delete("$${layout.buildDirectory.asFile.get().path}/libs")
}
mavenPublishing {
publishToMavenCentral(automaticRelease = true)
signAllPublications()
coordinates("dev.gitlive", "firebase-java-sdk", project.version.toString())
pom {
name.set("Firebase Java SDK")
description.set("A pure Java port of the Firebase Android SDK for client-side Java environments.")
url.set("https://github.com/GitLiveApp/firebase-java-sdk")
inceptionYear.set("2023")
scm {
url.set("https://github.com/GitLiveApp/firebase-java-sdk")
connection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git")
developerConnection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git")
tag.set("HEAD")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/GitLiveApp/firebase-java-sdk/issues")
}
developers {
developer {
name.set("Nicholas Bransby-Williams")
email.set("nbransby@gmail.com")
}
}
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
comments.set("A business-friendly OSS license")
}
}
}
}
dependencies {
compileOnly(libs.robolectric.android.all)
testImplementation(libs.junit)
testImplementation(libs.kotlinx.coroutines.play.services)
testImplementation(libs.kotlinx.coroutines.swing)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.okhttp.mockwebserver)
// firebase aars
aar(platform(libs.google.firebase.bom))
aar(libs.google.firebase.firestore)
aar(libs.google.firebase.functions)
aar(libs.google.firebase.database)
aar(libs.google.firebase.config)
aar(libs.google.firebase.installations)
aar(libs.google.firebase.storage)
// extracted aar dependencies
// exclude lifecycle libs due to https://github.com/GitLiveApp/firebase-java-sdk/pull/15 - remove the exclude once the dependencies in the aars are updated to the required version
api(fileTree(mapOf("dir" to "build/jar", "include" to listOf("*.jar"), "exclude" to listOf("lifecycle-*"))))
// polyfill dependencies
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.xerial.sqlite.jdbc)
// firebase dependencies
implementation(libs.javax.inject)
implementation(libs.okhttp)
implementation(libs.io.grpc.protobuf.lite)
implementation(libs.io.grpc.stub)
implementation(libs.androidx.collection)
// firebase-common 22 keeps its heartbeat store in a preferences DataStore (see com.google.firebase.datastorage.JavaDataStorage)
implementation(libs.androidx.datastore.core)
implementation(libs.androidx.datastore.preferences.core)
implementation(libs.io.grpc.okhttp)
implementation(libs.androidx.lifecycle.common)
implementation(libs.androidx.lifecycle.viewmodel)
// Plain-jar dependencies of the bumped libraries that the aar configuration resolves but does not ship: Functions
// 22 returns a Reactive Streams Publisher from HttpsCallableReference.stream(), Firestore 26 evaluates regex and
// like filters with re2j.
api(libs.reactive.streams)
implementation(libs.re2j)
}
tasks.named("publishToMavenLocal").configure {
dependsOn(cleanLibs, jar)
}
tasks.named("publish").configure {
dependsOn(cleanLibs)
}
ktlint {
version.set(libs.versions.ktlint.get())
}
tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA")
.any { version.uppercase(Locale.ROOT).contains(it) }
val versionMatch = "^[0-9,.v-]+(-r)?$".toRegex().matches(version)
return (stableKeyword || versionMatch).not()
}
rejectVersionIf {
isNonStable(candidate.version)
}
checkForGradleUpdate = true
outputFormatter = "plain,html"
outputDir = "build/dependency-reports"
reportfileName = "dependency-updates"
}