Skip to content

Commit

Permalink
Merge pull request #501 from bugsnag/release/v7.4.1
Browse files Browse the repository at this point in the history
Release v7.4.1
  • Loading branch information
lemnik authored Feb 22, 2023
2 parents 2184f1c + 6403e9b commit 2a65394
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 48 deletions.
12 changes: 12 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ steps:
- RN_FIXTURE_DIR=features/fixtures/rn065/android
command: ['bundle', 'exec', 'maze-runner', '-c', '--verbose', '--fail-fast']

- label: ':android: AGP 7.4.1 E2E tests'
depends_on: 'agp-ci'
timeout_in_minutes: 60
plugins:
- docker-compose#v3.7.0:
run: android-gradle-plugin-ci
env:
- AGP_VERSION=7.4.1
- GRADLE_WRAPPER_VERSION=7.5.1
- RN_FIXTURE_DIR=features/fixtures/rn70/android
command: ['bundle', 'exec', 'maze-runner', '-c', '--verbose', '--fail-fast']

- label: ':android: AGP 7.2.1 R/N 0.70 E2E tests'
depends_on: 'agp-ci'
timeout_in_minutes: 60
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 7.4.1 (2023-02-22)

### Bug Fixes

* Fix task ordering when using DexGuard and a `bundle***` task
[#496](https://github.com/bugsnag/bugsnag-android-gradle-plugin/pull/496)
* Improve support for Gradle Configuration Caching
[#491](https://github.com/bugsnag/bugsnag-android-gradle-plugin/pull/491)
[#499](https://github.com/bugsnag/bugsnag-android-gradle-plugin/pull/499)

## 7.4.0 (2022-11-10)

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion features/fixtures/config/ndk/objcopy.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ dependencies {
implementation 'com.bugsnag:bugsnag-android:5.26.0'
}

android.ndkVersion = "23.0.7599858"
android.ndkVersion = "24.0.8215888"
bugsnag.useLegacyNdkSymbolUpload = false
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POM_NAME=Bugsnag Android Gradle Plugin
POM_ARTIFACT_ID=bugsnag-android-gradle-plugin
POM_PACKAGING=jar
GROUP=com.bugsnag
VERSION_NAME=7.4.0
VERSION_NAME=7.4.1
POM_DESCRIPTION=Gradle plugin to automatically upload ProGuard mapping files to Bugsnag.
POM_URL=https://github.com/bugsnag/bugsnag-android-gradle-plugin/
POM_SCM_URL=https://github.com/bugsnag/bugsnag-android-gradle-plugin/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.bugsnag.android.gradle

import com.bugsnag.android.gradle.internal.BugsnagHttpClientHelper
import org.gradle.api.Task
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal

interface BugsnagFileUploadTask {
interface BugsnagFileUploadTask : Task {
@get:Input
val failOnUploadError: Property<Boolean>

Expand All @@ -24,11 +26,16 @@ interface BugsnagFileUploadTask {
@get:Internal
val httpClientHelper: Property<BugsnagHttpClientHelper>

fun configureWith(bugsnag: BugsnagPluginExtension) {
fun configureWith(
bugsnag: BugsnagPluginExtension,
httpClientHelperProvider: Provider<out BugsnagHttpClientHelper>
) {
failOnUploadError.set(bugsnag.failOnUploadError)
overwrite.set(bugsnag.overwrite)
endpoint.set(bugsnag.endpoint)
retryCount.set(bugsnag.retryCount)
timeoutMillis.set(bugsnag.requestTimeoutMs)
httpClientHelper.set(httpClientHelperProvider)
usesService(httpClientHelperProvider)
}
}
8 changes: 5 additions & 3 deletions src/main/kotlin/com/bugsnag/android/gradle/BugsnagPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,13 @@ class BugsnagPlugin : Plugin<Project> {

return BugsnagUploadProguardTask.register(project, taskName) {
requestOutputFile.set(requestOutputFileProvider)
httpClientHelper.set(httpClientHelperProvider)
manifestInfo.set(manifestInfoProvider)
uploadRequestClient.set(proguardUploadClientProvider)
mappingFileProperty.set(gzipOutputProvider)
configureWith(bugsnag)

uploadRequestClient.set(proguardUploadClientProvider)
usesService(proguardUploadClientProvider)

configureWith(bugsnag, httpClientHelperProvider)

val task = generateProguardTaskProvider?.get()
mustRunAfter(task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ internal abstract class BugsnagUploadSoSymTask : DefaultTask(), AndroidManifestI
BugsnagUploadSoSymTask::class.java
) { task ->
task.dependsOn(generateTaskProvider)
task.usesService(httpClientHelperProvider)
task.usesService(ndkUploadClientProvider)

task.endpoint.set(bugsnag.endpoint)
Expand All @@ -191,10 +190,9 @@ internal abstract class BugsnagUploadSoSymTask : DefaultTask(), AndroidManifestI
task.requestOutputFile.set(requestOutputFileFor(project, variant))
task.projectRoot.set(bugsnag.projectRoot.getOrElse(project.projectDir.toString()))

task.httpClientHelper.set(httpClientHelperProvider)
task.uploadRequestClient.set(ndkUploadClientProvider)

task.configureWith(bugsnag)
task.configureWith(bugsnag, httpClientHelperProvider)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal fun Project.hasDexguardPlugin(): Boolean {
*/
internal fun Project.isDexguardEnabledForVariant(variant: BaseVariant): Boolean {
val flavor = variant.flavorName
val buildType = variant.buildType.name.capitalize()
val buildType = if (flavor.isEmpty()) variant.buildType.name else variant.buildType.name.capitalize()
return GroovyCompat.isDexguardEnabledForVariant(project, "$flavor$buildType")
}

Expand Down
48 changes: 15 additions & 33 deletions src/main/kotlin/com/bugsnag/android/gradle/internal/NdkToolchain.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
package com.bugsnag.android.gradle.internal

import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.api.ApkVariant
import com.bugsnag.android.gradle.Abi
import com.bugsnag.android.gradle.BugsnagGenerateUnitySoMappingTask
import com.bugsnag.android.gradle.BugsnagPluginExtension
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.StopExecutionException
import org.gradle.util.VersionNumber
import java.io.File

abstract class NdkToolchain {
@get:Input
abstract val baseDir: Property<File>
// Internal rather than InputDirectory because this is an
// absolute path otherwise and would break build caching.
@get:Internal
abstract val baseDir: DirectoryProperty

@get:Input
abstract val useLegacyNdkSymbolUpload: Property<Boolean>
Expand All @@ -44,10 +46,11 @@ abstract class NdkToolchain {
?.let { it < MIN_BUGSNAG_ANDROID_VERSION }
if (legacyUploadRequired == null) {
logger.warn(
"Cannot detect Bugsnag SDK version for variant ${variantName.get()}, assuming a modern version is " +
"being used. This can cause problems with NDK symbols if older versions are being used. " +
"Please either specify the Bugsnag SDK version for ${variantName.get()} directly." +
"See https://docs.bugsnag.com/api/ndk-symbol-mapping-upload/ for details."
"Cannot detect Bugsnag SDK version for variant ${variantName.get()}. To use the new upload " +
"functionality, version 5.26.0 of bugsnag-android is required. If this is not the case, " +
"please either upgrade the dependency or set bugsnag.useLegacyNdkSymbolUpload to use the legacy " +
"upload mechanism. See https://docs.bugsnag.com/build-integrations/gradle/#ndk-symbol-files " +
"for details."
)

legacyUploadRequired = false
Expand Down Expand Up @@ -92,7 +95,7 @@ abstract class NdkToolchain {
val objdumpOverrides = overrides.get()

return objdumpOverrides[abi]?.let { File(it) } ?: File(
baseDir.get(),
baseDir.asFile.get(),
"toolchains/${abi.toolchainPrefix}-4.9/prebuilt/" +
"$osName/bin/${abi.objdumpPrefix}-${executableName("objdump")}"
)
Expand All @@ -113,7 +116,7 @@ abstract class NdkToolchain {
"$osName/bin/${abi.objdumpPrefix}-${executableName("objcopy")}"
}

return File(baseDir.get(), relativeExecutablePath)
return File(baseDir.asFile.get(), relativeExecutablePath)
}

enum class MappingTool {
Expand Down Expand Up @@ -151,27 +154,6 @@ abstract class NdkToolchain {
else -> null
}

/*
* SdkComponents.ndkDirectory
* https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/SdkComponents#ndkDirectory()
* sometimes fails to resolve when ndkPath is not defined (Cannot query the value of this property because it has
* no value available.). This means that even `map` and `isPresent` will break.
*
* So we also fall back use the old BaseExtension if it appears broken
*/
private fun ndkToolchainDirectoryFor(project: Project): Provider<File> {
val extensions = project.extensions
val sdkComponents = extensions.getByType(AndroidComponentsExtension::class.java)?.sdkComponents

return project.provider {
try {
return@provider sdkComponents!!.ndkDirectory.get().asFile
} catch (e: Exception) {
return@provider extensions.getByType(BaseExtension::class.java).ndkDirectory.absoluteFile
}
}
}

private fun getBugsnagAndroidNDKVersion(variant: ApkVariant): String? {
return try {
val bugsnagAndroidCoreVersion = variant.compileConfiguration.resolvedConfiguration.resolvedArtifacts
Expand All @@ -196,7 +178,7 @@ abstract class NdkToolchain {
val overrides = bugsnag.objdumpPaths.map { it.mapKeys { (abi, _) -> Abi.findByName(abi)!! } }

val ndkToolchain = project.objects.newInstance<NdkToolchain>()
ndkToolchain.baseDir.set(ndkToolchainDirectoryFor(project))
ndkToolchain.baseDir.set(project.extensions.getByType(BaseExtension::class.java).ndkDirectory)
ndkToolchain.useLegacyNdkSymbolUpload.set(useLegacyNdkSymbolUpload)
ndkToolchain.overrides.set(overrides)

Expand All @@ -213,5 +195,5 @@ abstract class NdkToolchain {
}
}

private val NdkToolchain.version get() = baseDir.map { VersionNumber.parse(it.name) }
private val NdkToolchain.version get() = baseDir.map { VersionNumber.parse(it.asFile.name) }
private val NdkToolchain.isLLVMPreferred get() = version.map { it >= NdkToolchain.MIN_NDK_LLVM_VERSION }
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.bugsnag.android.gradle.internal

import com.bugsnag.android.gradle.Abi
import org.gradle.api.Transformer
import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.internal.provider.DefaultProvider
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
Expand Down Expand Up @@ -85,18 +87,21 @@ private class TestNdkToolchainImpl(
useLegacyNdkSymbolUpload: Boolean,
overrides: Map<Abi, String> = emptyMap()
) : NdkToolchain() {
override val baseDir: Property<File> = Mockito.mock(Property::class.java) as Property<File>
override val baseDir: DirectoryProperty = Mockito.mock(DirectoryProperty::class.java)
override val useLegacyNdkSymbolUpload: Property<Boolean> = Mockito.mock(Property::class.java) as Property<Boolean>
override val overrides: MapProperty<Abi, String> = Mockito.mock(MapProperty::class.java) as MapProperty<Abi, String>
override val bugsnagNdkVersion: Property<String> = Mockito.mock(Property::class.java) as Property<String>
override val variantName: Property<String> = Mockito.mock(Property::class.java) as Property<String>

init {
whenMock(this.baseDir.get()).thenReturn(baseDir)
whenMock(this.baseDir.map(any<Transformer<out Any, in File>>()))
val baseDirectory: Directory = Mockito.mock(Directory::class.java)
whenMock(baseDirectory.asFile).thenReturn(baseDir)

whenMock(this.baseDir.asFile).thenReturn(DefaultProvider { baseDir })
whenMock(this.baseDir.map(any<Transformer<out Any, in Directory>>()))
.thenAnswer {
DefaultProvider {
(it.arguments.first() as Transformer<out Any, in File>).transform(baseDir)
(it.arguments.first() as Transformer<out Any, in Directory>).transform(baseDirectory)
}
}
whenMock(this.useLegacyNdkSymbolUpload.get()).thenReturn(useLegacyNdkSymbolUpload)
Expand Down

0 comments on commit 2a65394

Please sign in to comment.