Skip to content

Commit

Permalink
fix: workaround for AGP 3.5.0 tasks running before package
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Aug 14, 2020
1 parent cba71b7 commit 5056291
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions features/abi_apk_splits.feature
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Scenario: ABI Splits automatic upload disabled
Then I should receive no requests

@skip_agp4_1_or_higher
@skip_agp3_5
Scenario: ABI Splits manual upload of build API
When I build the "Armeabi-release" variantOutput for "abi_splits" using the "all_disabled" bugsnag config
Then I should receive 1 request
Expand Down
2 changes: 2 additions & 0 deletions features/app_bundle.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Feature: Generating Android app bundles

@skip_agp3_5
Scenario: Single-module default app bundles successfully
When I bundle "default_app" using the "standard" bugsnag config
Then I should receive 2 requests
Expand Down Expand Up @@ -28,6 +29,7 @@ Scenario: Single-module default app bundles successfully
And the field "appId" for multipart request 1 equals "com.bugsnag.android.example"
And the field "overwrite" for multipart request 1 is null

@skip_agp3_5
Scenario: Bundling multiple flavors automatically
When I bundle "flavors" using the "standard" bugsnag config
Then I should receive 4 requests
Expand Down
1 change: 1 addition & 0 deletions features/density_abi_splits.feature
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Scenario: Density ABI Splits automatic upload disabled
Then I should receive no requests

@skip_agp4_1_or_higher
@skip_agp3_5
Scenario: Density ABI Splits manual upload of build API
When I build the "XxxhdpiArmeabi-release" variantOutput for "density_abi_splits" using the "all_disabled" bugsnag config
Then I should receive 1 request
Expand Down
1 change: 1 addition & 0 deletions features/density_splits.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Scenario: Density Splits automatic upload disabled
Then I should receive no requests

@skip_agp4_1_or_higher
@skip_agp3_5
Scenario: Density Splits manual upload of build API
When I build the "Hdpi-release" variantOutput for "density_splits" using the "all_disabled" bugsnag config
Then I should receive 1 request
Expand Down
1 change: 1 addition & 0 deletions features/flavor_apk_splits.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Scenario: Flavor Density Split automatic upload disabled
Then I should receive no requests

@skip_agp4_1_or_higher
@skip_agp3_5
Scenario: Flavor Density Split manual upload of build API
When I build the "Bar-xxhdpi-release" variantOutput for "flavor_apk_splits" using the "all_disabled" bugsnag config
Then I should receive 1 request
Expand Down
1 change: 1 addition & 0 deletions features/flavors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Scenario: Flavors automatic upload disabled
When I build "flavors" using the "all_disabled" bugsnag config
Then I should receive no requests

@skip_agp3_5
Scenario: Flavors manual upload of build API
When I build the "Foo-release" variantOutput for "flavors" using the "all_disabled" bugsnag config
Then I should receive 1 request
Expand Down
10 changes: 10 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
skip_this_scenario() if is_above_or_equal_to_target(410)
end

Before('@skip_agp3_5') do |scenario|
skip_this_scenario() if equals_target(350)
end

def equals_target(target)
version = ENV["AGP_VERSION"].slice(0, 5)
version = version.gsub(".", "")
return version.to_i >= target
end

def is_above_or_equal_to_target(target)
version = ENV["AGP_VERSION"].slice(0, 5)
version = version.gsub(".", "")
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/com/bugsnag/android/gradle/internal/GradleUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal object AgpVersions {
// Use baseVersion to avoid any qualifiers like `-alpha06`
val CURRENT: VersionNumber = VersionNumber.parse(ANDROID_GRADLE_PLUGIN_VERSION).baseVersion
val VERSION_3_4: VersionNumber = VersionNumber.parse("3.4.0")
val VERSION_3_5: VersionNumber = VersionNumber.parse("3.5.0")
val VERSION_4_0: VersionNumber = VersionNumber.parse("4.0.0")
}

Expand Down Expand Up @@ -123,6 +124,17 @@ private fun BaseVariant.registerManual(project: Project, provider: TaskProvider<
.configureEach {
it.dependsOn(provider)
}

if (AgpVersions.CURRENT.major == AgpVersions.VERSION_3_5.major
&& AgpVersions.CURRENT.minor == AgpVersions.VERSION_3_5.minor) {
// workaround - AGP 3.5.0 executes upload tasks before the package tasks
// so we need to manually specify that it must run after the package task
// this stops config avoidance for AGP 3.5.0 only
project.tasks.matching { it.name.contains("package") }
.configureEach { packageTask ->
provider.get().mustRunAfter(packageTask)
}
}
}

/**
Expand Down

0 comments on commit 5056291

Please sign in to comment.