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: Make upstream dependencies compileOnly in integrations #2175

Merged
merged 7 commits into from Jul 18, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Switch upstream dependencies to `compileOnly` in integrations ([#2175](https://github.com/getsentry/sentry-java/pull/2175))

### Fixes

- Lazily retrieve HostnameCache in MainEventProcessor ([#2170](https://github.com/getsentry/sentry-java/pull/2170))
Expand Down
3 changes: 2 additions & 1 deletion sentry-android-core/build.gradle.kts
Expand Up @@ -49,7 +49,6 @@ android {

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

// needed because of Kotlin 1.4.x
Expand Down Expand Up @@ -107,4 +106,6 @@ dependencies {
testImplementation(projects.sentryTestSupport)
testImplementation(projects.sentryAndroidFragment)
testImplementation(projects.sentryAndroidTimber)
testRuntimeOnly(Config.Libs.timber)
testRuntimeOnly(Config.Libs.fragment)
}
Expand Up @@ -31,6 +31,10 @@ public final class SentryAndroid {
static final String SENTRY_TIMBER_INTEGRATION_CLASS_NAME =
"io.sentry.android.timber.SentryTimberIntegration";

private static final String TIMBER_CLASS_NAME = "timber.log.Timber";
private static final String FRAGMENT_CLASS_NAME =
"androidx.fragment.app.FragmentManager$FragmentLifecycleCallbacks";

private SentryAndroid() {}

/**
Expand Down Expand Up @@ -84,10 +88,17 @@ public static synchronized void init(
OptionsContainer.create(SentryAndroidOptions.class),
options -> {
final LoadClass classLoader = new LoadClass();
final boolean isTimberUpstreamAvailable =
classLoader.isClassAvailable(TIMBER_CLASS_NAME, options);
final boolean isFragmentUpstreamAvailable =
classLoader.isClassAvailable(FRAGMENT_CLASS_NAME, options);
final boolean isFragmentAvailable =
classLoader.isClassAvailable(SENTRY_FRAGMENT_INTEGRATION_CLASS_NAME, options);
(isFragmentUpstreamAvailable
philipphofmann marked this conversation as resolved.
Show resolved Hide resolved
&& classLoader.isClassAvailable(
SENTRY_FRAGMENT_INTEGRATION_CLASS_NAME, options));
final boolean isTimberAvailable =
classLoader.isClassAvailable(SENTRY_TIMBER_INTEGRATION_CLASS_NAME, options);
(isTimberUpstreamAvailable
&& classLoader.isClassAvailable(SENTRY_TIMBER_INTEGRATION_CLASS_NAME, options));

AndroidOptionsInitializer.init(
options, context, logger, isFragmentAvailable, isTimberAvailable);
Expand Down
3 changes: 2 additions & 1 deletion sentry-android-fragment/build.gradle.kts
Expand Up @@ -66,9 +66,10 @@ kotlin {
dependencies {
api(projects.sentry)

implementation(Config.Libs.fragment)
compileOnly(Config.Libs.fragment)

// tests
testImplementation(Config.Libs.fragment)
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
testImplementation(Config.TestLibs.mockitoInline)
Expand Down
6 changes: 4 additions & 2 deletions sentry-android-okhttp/build.gradle.kts
Expand Up @@ -68,12 +68,14 @@ kotlin {
dependencies {
api(projects.sentry)

implementation(Config.Libs.okhttpBom)
implementation(Config.Libs.okhttp)
compileOnly(Config.Libs.okhttpBom)
compileOnly(Config.Libs.okhttp)

implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))

// tests
testImplementation(Config.Libs.okhttpBom)
testImplementation(Config.Libs.okhttp)
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.androidxJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
Expand Down
3 changes: 2 additions & 1 deletion sentry-android-timber/build.gradle.kts
Expand Up @@ -71,11 +71,12 @@ kotlin {
dependencies {
api(projects.sentry)

api(Config.Libs.timber)
compileOnly(Config.Libs.timber)

implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))

// tests
testImplementation(Config.Libs.timber)
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.androidxJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-android/build.gradle.kts
Expand Up @@ -111,6 +111,7 @@ dependencies {
implementation(projects.sentryAndroidTimber)
implementation(projects.sentryCompose)
implementation(Config.Libs.fragment)
implementation(Config.Libs.timber)

// how to exclude androidx if release health feature is disabled
// implementation(projects.sentryAndroid) {
Expand Down