Skip to content

Commit 00bd9a2

Browse files
committed
Add tests and CI check
1 parent f65c305 commit 00bd9a2

File tree

15 files changed

+284
-546
lines changed

15 files changed

+284
-546
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
- Add upload functionality for size analysis ([#915](https://github.com/getsentry/sentry-android-gradle-plugin/pull/915))
8+
59
### Fixes
610

711
- Enable caching for BundleSourcesTask ([#894](https://github.com/getsentry/sentry-android-gradle-plugin/pull/894)

examples/android-gradle-kts/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ android {
2222

2323
sentry {
2424
autoUploadProguardMapping.set(CI.canAutoUpload())
25-
debug.set(true)
26-
sizeAnalysis.enabled.set(true)
2725

2826
telemetryDsn.set(CI.SENTRY_SDKS_DSN)
2927
tracingInstrumentation { enabled.set(false) }
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
defaults.project=sentry-android
22
defaults.org=sentry-sdks
3-
cli.executable=/Users/nelsonosacky/workspace/sentry-cli/bin/sentry-cli-dev

examples/android-gradle/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ android {
2323

2424
sentry {
2525
autoUploadProguardMapping = CI.INSTANCE.canAutoUpload()
26-
debug= true
27-
sizeAnalysis.enabled = true
2826

2927
telemetryDsn = CI.INSTANCE.SENTRY_SDKS_DSN
3028
tracingInstrumentation {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
defaults.project=sentry-android
22
defaults.org=sentry-sdks
3-
cli.executable=/Users/nelsonosacky/workspace/sentry-cli/bin/sentry-cli-dev
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
defaults.project=sentry-android
22
defaults.org=sentry-sdks
3-
cli.executable=/Users/nelsonosacky/workspace/sentry-cli/bin/sentry-cli-dev

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ autoServiceAnnotatons = { group = "com.google.auto.service", name = "auto-servic
4242
kotlinJunit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" }
4343
kotlinCompileTesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.7.0" }
4444
composeDesktop = { group = "org.jetbrains.compose.desktop", name = "desktop", version = "1.6.10" }
45+
truth = { module = "com.google.truth:truth", version = "1.4.4" }
4546

4647
# bytecode instrumentation
4748
asm = { group = "org.ow2.asm", name = "asm-util", version.ref = "asm" }

plugin-build/build.gradle.kts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
12
import io.sentry.android.gradle.internal.ASMifyTask
23
import io.sentry.android.gradle.internal.BootstrapAndroidSdk
34
import java.io.FileInputStream
@@ -29,11 +30,11 @@ val testImplementationAar by configurations.getting // this converts .aar into .
2930
val agp70: SourceSet by sourceSets.creating
3031
val agp74: SourceSet by sourceSets.creating
3132

32-
// val shade: Configuration by
33-
// configurations.creating {
34-
// isCanBeConsumed = false
35-
// isCanBeResolved = true
36-
// }
33+
val shade: Configuration by
34+
configurations.creating {
35+
isCanBeConsumed = false
36+
isCanBeResolved = true
37+
}
3738

3839
val fixtureClasspath: Configuration by configurations.creating
3940

@@ -61,8 +62,8 @@ dependencies {
6162

6263
// compileOnly since we'll be shading the common dependency into the final jar
6364
// but we still need to be able to compile it (this also excludes it from .pom)
64-
// compileOnly(project(":common"))
65-
implementation(project(":common"))
65+
compileOnly(project(":common"))
66+
shade(project(":common"))
6667

6768
testImplementation(gradleTestKit())
6869
testImplementation(kotlin("test"))
@@ -76,6 +77,7 @@ dependencies {
7677
testImplementation(libs.proguard)
7778
testImplementation(libs.junit)
7879
testImplementation(libs.mockitoKotlin)
80+
testImplementation(libs.truth)
7981

8082
testImplementation(libs.asm)
8183
testImplementation(libs.asmCommons)
@@ -191,19 +193,19 @@ tasks.withType<Jar>().configureEach {
191193
from(agp74.output)
192194
}
193195

194-
// tasks.withType<ShadowJar>().configureEach {
195-
// archiveClassifier.set("")
196-
// configurations = listOf(shade)
196+
tasks.withType<ShadowJar>().configureEach {
197+
archiveClassifier.set("")
198+
configurations = listOf(shade)
197199

198-
// exclude("/kotlin/**")
199-
// exclude("/groovy**")
200-
// exclude("/org/**")
201-
// }
200+
exclude("/kotlin/**")
201+
exclude("/groovy**")
202+
exclude("/org/**")
203+
}
202204

203-
// artifacts {
204-
// runtimeOnly(tasks.named("shadowJar"))
205-
// archives(tasks.named("shadowJar"))
206-
// }
205+
artifacts {
206+
runtimeOnly(tasks.named("shadowJar"))
207+
archives(tasks.named("shadowJar"))
208+
}
207209

208210
spotless {
209211
kotlin {

plugin-build/sentry-cli.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
#version = 2.46.0
2-
#repo = https://github.com/getsentry/sentry-cli
3-
cli.executable=/Users/nelsonosacky/workspace/sentry-cli/bin/sentry-cli-dev
1+
version = 2.46.0
2+
repo = https://github.com/getsentry/sentry-cli

plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ fun AndroidComponentsExtension<*, *, *>.configure(
6565
tmpDir.mkdirs()
6666

6767
configureVariants { variant ->
68-
val sentryTelemetryProvider =
69-
variant.configureTelemetry(project, extension, cliExecutable, sentryOrg, buildEvents)
7068
if (isVariantAllowed(extension, variant.name, variant.flavorName, variant.buildType)) {
7169
val paths = OutputPaths(project, variant.name)
70+
val sentryTelemetryProvider =
71+
variant.configureTelemetry(project, extension, cliExecutable, sentryOrg, buildEvents)
7272

7373
variant.configureDependenciesTask(project, extension, sentryTelemetryProvider)
7474

@@ -247,6 +247,8 @@ fun AndroidComponentsExtension<*, *, *>.configure(
247247
}
248248
}
249249
if (extension.sizeAnalysis.enabled.get() == true) {
250+
val sentryTelemetryProvider =
251+
variant.configureTelemetry(project, extension, cliExecutable, sentryOrg, buildEvents)
250252
variant.configureUploadAppTasks(
251253
project,
252254
extension,
@@ -427,6 +429,9 @@ private fun Variant.configureProguardMappingsTasks(
427429
}
428430
}
429431

432+
/**
433+
* Configure the upload AAB and APK tasks and set them up as finalizers on the respective producer tasks
434+
*/
430435
fun Variant.configureUploadAppTasks(
431436
project: Project,
432437
extension: SentryPluginExtension,
@@ -453,6 +458,7 @@ fun Variant.configureUploadAppTasks(
453458
sentryProperties = sentryProps,
454459
taskSuffix = name.capitalized,
455460
)
461+
// TODO we can use the listToArtifacts API in AGP 8.3+ https://github.com/android/gradle-recipes/tree/agp-8.10/listenToArtifacts
456462
project.afterEvaluate {
457463
getBundleTask(project, variant.name)!!.configure { it.finalizedBy(uploadBundleTask) }
458464
getAssembleTaskProvider(project, variant)!!.configure { it.finalizedBy(uploadApkTask) }

0 commit comments

Comments
 (0)