-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
executable file
·214 lines (187 loc) · 7.45 KB
/
build.gradle.kts
File metadata and controls
executable file
·214 lines (187 loc) · 7.45 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
213
214
import com.android.build.gradle.tasks.SourceJarTask
import com.strumenta.antlrkotlin.gradle.AntlrKotlinTask
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.roborazzi)
alias(libs.plugins.com.strumenta.antlr.kotlin)
alias(libs.plugins.kotlinx.serialization)
id("maven-publish")
}
val moduleId = "org.phoenixframework.liveview"
val antlrGeneratedDir = "generatedAntlr"
android {
namespace = moduleId
compileSdk = Constants.compileSdkVersion
defaultConfig {
minSdk = Constants.minSdkVersion
testApplicationId = "$moduleId.test"
testInstrumentationRunner = Constants.instrumentationRunnerClass
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
// Running screenshot tests
// Recording the image references
// ./gradlew recordRoborazziDebug -PisRecordingShotTest=true
// Testing
// ./gradlew verifyRoborazziDebug
// This param must be passed via command line in order to generated the reference images for
// screen shot tests.
val isRecordingShotTest: String by project
buildTypes.forEach {
it.buildConfigField("boolean", "IS_RECORDING_SHOT_TEST", isRecordingShotTest)
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = Constants.sourceCompatibilityVersion
targetCompatibility = Constants.targetCompatibilityVersion
}
kotlinOptions {
jvmTarget = Constants.jvmTargetVersion
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = Constants.kotlinCompilerExtVersion
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
testNamespace = "$moduleId.test"
testOptions.unitTests.isIncludeAndroidResources = true
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
// Adding ANTLR source dir to the source file dir
sourceSets.getByName("main") {
kotlin {
srcDir(layout.buildDirectory.dir(antlrGeneratedDir))
}
}
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.0")
// These dependencies are used internally, and not exposed to consumers on their own compile classpath.
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.material.icons.core)
implementation(libs.androidx.compose.material.icons.extended)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui.text.google.fonts)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.navigation.compose)
implementation(libs.antlr4.runtime)
implementation(libs.com.google.code.gson)
implementation(libs.com.google.code.gson)
implementation(libs.com.github.dsrees.javaphoenixclient)
implementation(libs.com.github.liveview.native.core.jetpack)
implementation(libs.com.strumenta.antlr.kotlin.runtime)
// TODO Is there a better way to include JNA *.so files to the AAR file? (instead of put them in jniLibs dir)
// Download the JAR from https://github.com/java-native-access/jna/tree/master/lib/native
// Extract the libjnidispatch.so file for each architecture using `jar xf android-aarch64.jar`
implementation(libs.net.java.dev.jna)
implementation(libs.org.jsoup)
implementation(libs.kotlinx.serialization.json)
implementation(platform(libs.koin.bom))
implementation(libs.koin.core)
implementation(libs.koin.android)
implementation(libs.koin.compose)
implementation(platform(libs.okhttp.bom))
implementation(libs.okhttp)
// These dependencies are exported to consumers, that is to say found on their compile classpath.
api(libs.org.jetbrains.kotlinx.collections.immutable)
// Test dependencies
testImplementation(project(Constants.moduleClientTestBase))
testImplementation(libs.androidx.test.ext.junit)
testImplementation(libs.androidx.compose.ui.test.junit4)
testImplementation(libs.io.github.takahirom.roborazzi)
testImplementation(libs.io.github.takahirom.roborazzi.compose)
testImplementation(libs.io.github.takahirom.roborazzi.junit.rule)
testImplementation(libs.junit)
testImplementation(libs.koin.test)
testImplementation(libs.org.robolectric)
}
// ./gradlew assembleRelease -PcomposeCompilerReports=true
// Run the command above in order to generate the compose stability diagnose report.
// https://developer.android.com/jetpack/compose/performance/stability/diagnose
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
val prefix = "plugin:androidx.compose.compiler.plugins.kotlin"
val output = layout.buildDirectory.dir("compose_compiler")
if (project.findProperty("composeCompilerReports") == "true") {
freeCompilerArgs += listOf(
"-P",
"$prefix:reportsDestination=$output"
)
}
if (project.findProperty("composeCompilerMetrics") == "true") {
freeCompilerArgs += listOf(
"-P",
"$prefix:metricsDestination=$output"
)
}
}
}
// Configuring Java Lib Path in order to find the native library before running the Unit Tests
tasks.withType<Test>().configureEach {
doFirst {
val coreVersion = project.extensions.getByType<VersionCatalogsExtension>()
.named("libs")
.findVersion("liveview-native-core-jetpack")
.get()
.toString()
copyDesktopJniLibs(rootDir, this@configureEach, coreVersion)
}
}
val generateKotlinGrammarSource = tasks.register<AntlrKotlinTask>("generateKotlinGrammarSource") {
dependsOn("cleanGenerateKotlinGrammarSource")
// ANTLR .g4 files are under antlr directory
// Only include *.g4 files. This allows tools (e.g., IDE plugins)
// to generate temporary files inside the base path
source = fileTree(layout.projectDirectory.dir("antlr")) {
include("**/*.g4")
}
// We want the generated source files to have this package name
val pkgName = "$moduleId.stylesheet"
packageName = pkgName
// We don't want visitors and listeners.
arguments = listOf("-no-visitor", "-no-listener")
// Generated files are outputted inside build/generatedAntlr/{package-name}
val outDir = "$antlrGeneratedDir/${pkgName.replace(".", "/")}"
outputDirectory = layout.buildDirectory.dir(outDir).get().asFile
}
tasks.withType<KotlinCompile<*>> {
dependsOn(generateKotlinGrammarSource)
}
tasks.withType<SourceJarTask> {
dependsOn(generateKotlinGrammarSource)
}
publishing {
publications {
register<MavenPublication>("release") {
groupId = Constants.publishGroupId
artifactId = Constants.publishArtifactClientId
version = Constants.publishVersion
afterEvaluate {
from(components["release"])
}
}
}
}