Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Jetpack Compose Navigation support #2136

Merged
merged 4 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ targets:
maven:io.sentry:sentry-apollo:
maven:io.sentry:sentry-jdbc:
maven:io.sentry:sentry-graphql:
maven:io.sentry:sentry-android-navigation:
maven:io.sentry:sentry-compose:
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

### Features

- New package `sentry-android-navigation` for AndroidX Navigation support ([#2136](https://github.com/getsentry/sentry-java/pull/2136))
- New package `sentry-compose` for Jetpack Compose support (Navigation) ([#2136](https://github.com/getsentry/sentry-java/pull/2136))

## 6.1.4

### Fixes
Expand Down
10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.diffplug.spotless.LineEnding
import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.MavenPublishPluginExtension
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

Expand Down Expand Up @@ -34,6 +35,7 @@ buildscript {
// classpath("io.sentry:sentry-android-gradle-plugin:{version}")

classpath(Config.QualityPlugins.binaryCompatibilityValidatorPlugin)
classpath(Config.BuildPlugins.composeGradlePlugin)
}
}

Expand Down Expand Up @@ -88,6 +90,14 @@ allprojects {
}

subprojects {
plugins.withId(Config.QualityPlugins.detektPlugin) {
configure<DetektExtension> {
buildUponDefaultConfig = true
allRules = true
config.setFrom("${rootProject.rootDir}/detekt.yml")
}
}

if (!this.name.contains("sample") && !this.name.contains("integration-tests") && this.name != "sentry-test-support") {
apply<DistributionPlugin>()

Expand Down
18 changes: 16 additions & 2 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import java.math.BigDecimal

object Config {
val kotlinVersion = "1.5.31"
val kotlinVersion = "1.6.10"
val kotlinStdLib = "stdlib-jdk8"

val springBootVersion = "2.6.8"
val kotlinCompatibleLanguageVersion = "1.4"

val composeVersion = "1.1.1"

object BuildPlugins {
val androidGradle = "com.android.tools.build:gradle:7.2.0"
val kotlinGradlePlugin = "gradle-plugin"
Expand All @@ -19,14 +21,16 @@ object Config {
val grettyVersion = "4.0.0"
val gradleMavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.18.0"
val dokkaPlugin = "org.jetbrains.dokka:dokka-gradle-plugin:$kotlinVersion"
val composeGradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$composeVersion"
}

object Android {
private val sdkVersion = 31
private val sdkVersion = 32

val minSdkVersion = 14
val minSdkVersionOkHttp = 21
val minSdkVersionNdk = 16
val minSdkVersionCompose = 21
val targetSdkVersion = sdkVersion
val compileSdkVersion = sdkVersion

Expand Down Expand Up @@ -104,6 +108,16 @@ object Config {
val graphQlJava = "com.graphql-java:graphql-java:17.3"

val kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect"
val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib"

private val navigationVersion = "2.4.2"
val navigationRuntime = "androidx.navigation:navigation-runtime:$navigationVersion"
// compose deps
val composeNavigation = "androidx.navigation:navigation-compose:$navigationVersion"
val composeActivity = "androidx.activity:activity-compose:1.4.0"
val composeFoundation = "androidx.compose.foundation:foundation:$composeVersion"
val composeFoundationLayout = "androidx.compose.foundation:foundation-layout:$composeVersion"
val composeMaterial = "androidx.compose.material3:material3:1.0.0-alpha13"
}

object AnnotationProcessors {
Expand Down
3 changes: 3 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
style:
ReturnCount:
max: 3
6 changes: 0 additions & 6 deletions sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension

plugins {
id("com.android.library")
Expand Down Expand Up @@ -79,8 +78,3 @@ tasks.withType<Detekt> {
// Target version of the generated JVM bytecode. It is used for type resolution.
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

configure<DetektExtension> {
buildUponDefaultConfig = true
allRules = true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import net.ltgt.gradle.errorprone.errorprone

plugins {
Expand Down Expand Up @@ -122,11 +121,6 @@ tasks.withType<Detekt> {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

configure<DetektExtension> {
buildUponDefaultConfig = true
allRules = true
}

kotlin {
explicitApi()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import net.ltgt.gradle.errorprone.errorprone

plugins {
Expand Down Expand Up @@ -120,11 +119,6 @@ tasks.withType<Detekt> {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

configure<DetektExtension> {
buildUponDefaultConfig = true
allRules = true
}

kotlin {
explicitApi()
}
1 change: 1 addition & 0 deletions sentry-android-navigation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
22 changes: 22 additions & 0 deletions sentry-android-navigation/api/sentry-android-navigation.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
public final class io/sentry/android/navigation/BuildConfig {
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
public fun <init> ()V
}

public final class io/sentry/android/navigation/SentryNavigationListener : androidx/navigation/NavController$OnDestinationChangedListener {
public static final field Companion Lio/sentry/android/navigation/SentryNavigationListener$Companion;
public static final field NAVIGATION_OP Ljava/lang/String;
public fun <init> ()V
public fun <init> (Lio/sentry/IHub;)V
public fun <init> (Lio/sentry/IHub;Z)V
public fun <init> (Lio/sentry/IHub;ZZ)V
public synthetic fun <init> (Lio/sentry/IHub;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun onDestinationChanged (Landroidx/navigation/NavController;Landroidx/navigation/NavDestination;Landroid/os/Bundle;)V
}

public final class io/sentry/android/navigation/SentryNavigationListener$Companion {
}

89 changes: 89 additions & 0 deletions sentry-android-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import io.gitlab.arturbosch.detekt.Detekt

plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}

android {
compileSdk = Config.Android.compileSdkVersion

defaultConfig {
targetSdk = Config.Android.targetSdkVersion
minSdk = Config.Android.minSdkVersion

// for AGP 4.1
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

buildTypes {
getByName("debug")
getByName("release") {
consumerProguardFiles("proguard-rules.pro")
}
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
kotlinOptions.languageVersion = Config.kotlinCompatibleLanguageVersion
}

testOptions {
animationsDisabled = true
unitTests.apply {
isReturnDefaultValues = true
isIncludeAndroidResources = true
}
}

lint {
warningsAsErrors = true
checkDependencies = true

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
}

variantFilter {
if (Config.Android.shouldSkipDebugVariant(buildType.name)) {
ignore = true
}
}
}
romtsn marked this conversation as resolved.
Show resolved Hide resolved

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}

dependencies {
api(projects.sentry)

compileOnly(Config.Libs.navigationRuntime)

// tests
testImplementation(Config.Libs.navigationRuntime)

testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
testImplementation(Config.TestLibs.mockitoInline)

testImplementation(Config.TestLibs.robolectric)
testImplementation(Config.TestLibs.androidxCore)
testImplementation(Config.TestLibs.androidxRunner)
testImplementation(Config.TestLibs.androidxJunit)
testImplementation(Config.TestLibs.androidxCoreKtx)
}

tasks.withType<Detekt> {
// Target version of the generated JVM bytecode. It is used for type resolution.
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
7 changes: 7 additions & 0 deletions sentry-android-navigation/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##---------------Begin: proguard configuration for Compose ----------

# To ensure that stack traces is unambiguous
# https://developer.android.com/studio/build/shrink-code#decode-stack-trace
-keepattributes LineNumberTable,SourceFile

##---------------End: proguard configuration for Compose ----------
2 changes: 2 additions & 0 deletions sentry-android-navigation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.sentry.android.navigation"/>