Skip to content

Commit 52898e0

Browse files
authored
Prevent task registration collisions by checking for existing tasks before registering (#5)
* Add "No-Op" modules for Session Replay, Logs, and Profiling features to provide empty implementations with minimal footprint. * refactor: optimize dependency isolation and compatibility - Downgrade androidx.core to 1.12.0 and move key dependencies (Gson, OkHttp, WorkManager) to compileOnly scope to reduce SDK footprint and avoid version conflicts. - Implement WorkManagerUtils with reflection-based safe initialization check to handle optional WorkManager dependency. - Update API surface and transitive dependency lists across multiple modules. - Fix Detekt configuration to handle missing classpath files gracefully. - Bump SDK version to 0.3.1-SNAPSHOT. * Enable Logging, Session Replay, and Feature Flags in sample applications - Add `setApplicationLaunchSampleRate` and `useCustomEndpoint` to `ProfilingConfiguration.Builder` in the no-op profiling module. - Uncomment and enable Log, Session Replay, Feature Flag, and Timber integration dependencies across multiple sample modules (automotive, benchmark, kotlin, tv, vendor-lib, wear). - Restore initialization code for Logs, Session Replay, and Timber in sample application classes. - Downgrade several transitive dependencies (e.g., Gson, OkHttp, Okio, and various AndroidX libraries) to older versions across multiple modules. - Include `:features:dd-sdk-android-flags` and related modules in the global settings. - Implement a dependency substitution rule in the Kotlin sample to use no-op logs when appropriate. * Add no-op implementations for Feature Flags and OpenFeature modules * feat: add `dd-sdk-android-flags-noop` module - Provides a no-op implementation of the Flags SDK to allow safe compilation without the full feature. - Includes core interfaces: `FlagsClient`, `FlagsConfiguration`, `EvaluationContext`, and `ResolutionDetails`. - Defines `NoOpFlagsClient` which returns default values for all flag evaluations. * feat: add `dd-sdk-android-flags-openfeature-noop` module - Provides a no-op implementation of the OpenFeature provider. - Includes `DatadogFlagsProvider` which implements `FeatureProvider` by returning default values. - Adds `asOpenFeatureProvider()` extension on `FlagsClient`. * chore: update sample application - Configure Kotlin sample to use `noop` variants for the `noop` build flavor. - Uncomment and initialize Feature Flags in `SampleApplication.kt` using the new APIs. * build: include new modules in project settings and build configurations. * Update build configuration and test dependencies across SDK modules - Add missing test dependencies (`gson`, `okHttp`, `fresco`, `robolectric`) to multiple feature modules - Update `dd-sdk-android-profiling` to use version catalog for AndroidX Core dependencies - Add several unit test exclusions in `dd-sdk-android-flags` and `dd-sdk-android-internal` - Register no-op and alias tasks in `dd-sdk-android-dependencies` to support Android aggregation tasks (assemble, lint, test, etc.) - Define new AndroidX core versions and modules in `libs.versions.toml` - Temporarily comment out `WorkerParametersForgeryFactory` in core tests * Update shadowJar configuration and dependencies * chore: update shadowJar and jar tasks - Change shadowJar archive classifier to "all" - Configure jar task to depend on and include contents of shadowJar (excluding manifest) * chore: update transitive dependencies - Add okhttp, okio, and collection to dd-sdk-android-flags-noop - Add coroutines and kotlin-stdlib-jdk variants to dd-sdk-android-flags-openfeature-noop * Remove shadowJar artifacts from API and runtime elements - Remove `shadowJar` task artifacts from `apiElements` and `runtimeElements` configurations in `dd-sdk-android-dependencies/build.gradle.kts`. * Prevent task registration collisions by checking for existing tasks before registering shadow and aggregation tasks in `dd-sdk-android-dependencies/build.gradle.kts`. * Update task registration for `assembleDebug`, `assembleRelease`, `testDebugUnitTest`, and `testReleaseUnitTest` to use conditional checks. * Apply the same conditional logic to no-op tasks including `lintRelease`, `checkDependencyLicenses`, `checkApiSurfaceChanges`, `checkCompilerMetadataChanges`, `checkTransitiveDependenciesList`, `koverXmlReportRelease`, and `printDetektClasspath`.
1 parent 6a57afc commit 52898e0

1 file changed

Lines changed: 44 additions & 67 deletions

File tree

dd-sdk-android-dependencies/build.gradle.kts

Lines changed: 44 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -29,92 +29,69 @@ tasks.named<Jar>("jar") {
2929
}
3030
}
3131

32-
tasks.register("assembleDebug") {
33-
dependsOn("assemble")
34-
}
35-
36-
tasks.register("assembleRelease") {
37-
dependsOn("assemble")
38-
}
39-
40-
// Shadow tasks to satisfy Android aggregation tasks
41-
tasks.register("testDebugUnitTest") {
42-
dependsOn("test")
43-
}
44-
45-
tasks.register("testReleaseUnitTest") {
46-
dependsOn("test")
47-
}
48-
49-
tasks.register("lintRelease") {
50-
// No-op for this Java library
51-
}
52-
53-
tasks.register("checkDependencyLicenses") {
54-
// No-op for this Java library
55-
}
56-
57-
tasks.register("checkApiSurfaceChanges") {
58-
// No-op for this Java library
59-
}
60-
61-
tasks.register("checkCompilerMetadataChanges") {
62-
// No-op for this Java library
63-
}
64-
65-
tasks.register("checkTransitiveDependenciesList") {
66-
// No-op for this Java library
67-
}
68-
69-
tasks.register("koverXmlReportRelease") {
70-
// No-op or depends on koverXmlReport if applied
71-
}
72-
73-
tasks.register("printDetektClasspath") {
74-
// No-op
75-
}
76-
77-
tasks.register("assembleDebug") {
78-
dependsOn("assemble")
32+
if (tasks.findByName("assembleDebug") == null) {
33+
tasks.register("assembleDebug") {
34+
dependsOn("assemble")
35+
}
7936
}
8037

81-
tasks.register("assembleRelease") {
82-
dependsOn("assemble")
38+
if (tasks.findByName("assembleRelease") == null) {
39+
tasks.register("assembleRelease") {
40+
dependsOn("assemble")
41+
}
8342
}
8443

8544
// Shadow tasks to satisfy Android aggregation tasks
86-
tasks.register("testDebugUnitTest") {
87-
dependsOn("test")
45+
if (tasks.findByName("testDebugUnitTest") == null) {
46+
tasks.register("testDebugUnitTest") {
47+
dependsOn("test")
48+
}
8849
}
8950

90-
tasks.register("testReleaseUnitTest") {
91-
dependsOn("test")
51+
if (tasks.findByName("testReleaseUnitTest") == null) {
52+
tasks.register("testReleaseUnitTest") {
53+
dependsOn("test")
54+
}
9255
}
9356

94-
tasks.register("lintRelease") {
95-
// No-op for this Java library
57+
if (tasks.findByName("lintRelease") == null) {
58+
tasks.register("lintRelease") {
59+
// No-op for this Java library
60+
}
9661
}
9762

98-
tasks.register("checkDependencyLicenses") {
99-
// No-op for this Java library
63+
if (tasks.findByName("checkDependencyLicenses") == null) {
64+
tasks.register("checkDependencyLicenses") {
65+
// No-op for this Java library
66+
}
10067
}
10168

102-
tasks.register("checkApiSurfaceChanges") {
103-
// No-op for this Java library
69+
if (tasks.findByName("checkApiSurfaceChanges") == null) {
70+
tasks.register("checkApiSurfaceChanges") {
71+
// No-op for this Java library
72+
}
10473
}
10574

106-
tasks.register("checkCompilerMetadataChanges") {
107-
// No-op for this Java library
75+
if (tasks.findByName("checkCompilerMetadataChanges") == null) {
76+
tasks.register("checkCompilerMetadataChanges") {
77+
// No-op for this Java library
78+
}
10879
}
10980

110-
tasks.register("checkTransitiveDependenciesList") {
111-
// No-op for this Java library
81+
if (tasks.findByName("checkTransitiveDependenciesList") == null) {
82+
tasks.register("checkTransitiveDependenciesList") {
83+
// No-op for this Java library
84+
}
11285
}
11386

114-
tasks.register("koverXmlReportRelease") {
115-
// No-op or depends on koverXmlReport if applied
87+
if (tasks.findByName("koverXmlReportRelease") == null) {
88+
tasks.register("koverXmlReportRelease") {
89+
// No-op or depends on koverXmlReport if applied
90+
}
11691
}
11792

118-
tasks.register("printDetektClasspath") {
119-
// No-op
93+
if (tasks.findByName("printDetektClasspath") == null) {
94+
tasks.register("printDetektClasspath") {
95+
// No-op
96+
}
12097
}

0 commit comments

Comments
 (0)