Skip to content

Commit

Permalink
Merge pull request #535 from bugsnag/release/v7.6.0
Browse files Browse the repository at this point in the history
Release v7.6.0
  • Loading branch information
lemnik authored Sep 27, 2023
2 parents 460a711 + d7e0629 commit 3d02f6a
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 7.6.0 (2023-09-27)

### Enhancements

* Allow DexGuard version to be specified manually (as `bugsnag.dexguardMajorVersion`) for DexGuard < 9
[#531](https://github.com/bugsnag/bugsnag-android-gradle-plugin/pull/531)

## 7.5.0 (2023-04-20)

### Enhancements
Expand Down
40 changes: 21 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
GIT
remote: https://github.com/bugsnag/maze-runner
revision: a2fadd12aee3eb3bc8da72e2d35ec8801cf2c186
tag: v6.1.0
revision: bd5308f3705c63b88dca229c4da387a11cb83a5d
tag: v6.2.0
specs:
bugsnag-maze-runner (6.1.0)
bugsnag-maze-runner (6.2.0)
appium_lib (~> 11.2.0)
cucumber (~> 7.1)
cucumber-expressions (~> 6.0.0)
Expand Down Expand Up @@ -42,11 +42,11 @@ GEM
mime-types (~> 3.3, >= 3.3.1)
multi_test (~> 0.1, >= 0.1.2)
sys-uname (~> 1.2, >= 1.2.2)
cucumber-core (10.1.0)
cucumber-core (10.1.1)
cucumber-gherkin (~> 22.0, >= 22.0.0)
cucumber-messages (~> 17.1, >= 17.1.1)
cucumber-tag-expressions (~> 4.0, >= 4.0.2)
cucumber-create-meta (6.0.2)
cucumber-tag-expressions (~> 4.1, >= 4.1.0)
cucumber-create-meta (6.0.4)
cucumber-messages (~> 17.1, >= 17.1.1)
sys-uname (~> 1.2, >= 1.2.2)
cucumber-cucumber-expressions (14.0.0)
Expand All @@ -57,44 +57,46 @@ GEM
cucumber-messages (~> 17.1, >= 17.1.0)
cucumber-messages (17.1.1)
cucumber-tag-expressions (4.1.0)
cucumber-wire (6.2.0)
cucumber-wire (6.2.1)
cucumber-core (~> 10.1, >= 10.1.0)
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
cucumber-messages (~> 17.1, >= 17.1.1)
curb (0.9.11)
diff-lcs (1.4.4)
diff-lcs (1.5.0)
eventmachine (1.2.7)
faye-websocket (0.11.1)
faye-websocket (0.11.3)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
ffi (1.15.4)
mime-types (3.3.1)
ffi (1.15.5)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0901)
minitest (5.14.4)
mime-types-data (3.2023.0808)
minitest (5.19.0)
multi_test (0.1.2)
nokogiri (1.12.5-x86_64-darwin)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
optimist (3.0.1)
os (1.0.1)
power_assert (2.0.1)
racc (1.6.0)
power_assert (2.0.3)
racc (1.7.1)
rake (12.3.3)
rubyzip (2.3.2)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sys-uname (1.2.2)
sys-uname (1.2.3)
ffi (~> 1.1)
test-unit (3.3.9)
power_assert
tomlrb (1.3.0)
webrick (1.7.0)
websocket-driver (0.7.5)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
arm64-darwin-22
x86_64-darwin-19

DEPENDENCIES
Expand Down
3 changes: 1 addition & 2 deletions detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
<ID>MagicNumber:BugsnagPluginExtension.kt$BugsnagPluginExtension$60000</ID>
<ID>MagicNumber:BugsnagReleasesTask.kt$BugsnagReleasesTask$200</ID>
<ID>MagicNumber:MappingFileProvider.kt$9</ID>
<ID>MaxLineLength:NdkToolchain.kt$NdkToolchain.Companion$/* * 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 */</ID>
<ID>MaxLineLength:BugsnagPlugin.kt$BugsnagPlugin$val mappingFilesProvider = createMappingFileProvider(project, variant, output, bugsnag.dexguardMajorVersion.orNull)</ID>
<ID>ReturnCount:BugsnagGenerateUnitySoMappingTask.kt$BugsnagGenerateUnitySoMappingTask.Companion$ @Suppress("SENSELESS_COMPARISON") internal fun isUnityLibraryUploadEnabled( bugsnag: BugsnagPluginExtension, android: BaseExtension ): Boolean</ID>
<ID>ReturnCount:BugsnagPlugin.kt$BugsnagPlugin$ private fun registerUploadSourceMapTask( project: Project, variant: BaseVariant, output: BaseVariantOutput, bugsnag: BugsnagPluginExtension, manifestInfoProvider: Provider&lt;RegularFile> ): TaskProvider&lt;out BugsnagUploadJsSourceMapTask>?</ID>
<ID>ReturnCount:ManifestUuidTaskV2Compat.kt$internal fun createManifestUpdateTask( bugsnag: BugsnagPluginExtension, project: Project, variantName: String, variantOutput: VariantOutput ): TaskProvider&lt;BugsnagManifestUuidTask>?</ID>
<ID>SpreadOperator:DexguardCompat.kt$(buildDir, *path, variant.dirName, outputDir, "mapping.txt")</ID>
<ID>SwallowedException:NdkToolchain.kt$NdkToolchain.Companion$catch (e: Exception) { null }</ID>
<ID>SwallowedException:NdkToolchain.kt$NdkToolchain.Companion$catch (e: Exception) { return@provider extensions.getByType(BaseExtension::class.java).ndkDirectory.absoluteFile }</ID>
<ID>TooGenericExceptionCaught:AbstractSoMappingTask.kt$AbstractSoMappingTask$e: Exception</ID>
<ID>TooGenericExceptionCaught:BugsnagHttpClientHelper.kt$exc: Throwable</ID>
<ID>TooGenericExceptionCaught:BugsnagMultiPartUploadRequest.kt$BugsnagMultiPartUploadRequest$exc: Throwable</ID>
Expand Down
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.5.0
VERSION_NAME=7.6.0
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
16 changes: 2 additions & 14 deletions src/main/groovy/com/bugsnag/android/gradle/GroovyCompat.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,10 @@ class GroovyCompat {
if (dexguard == null) {
return null
}
if (dexguard.version != null) {
if (dexguard.hasProperty("version") && dexguard.version != null) {
return dexguard.version
} else {
// the path value is structured like this: DexGuard-8.7.02
if (dexguard.path == null) {
return null
}

File dexguardDir = project.file(dexguard.path).getCanonicalFile()

// Get the version from the dexguard.jar manifest
URL url = new URL("jar:file:$dexguardDir/lib/dexguard.jar!/")
URLConnection jarURLConnection = url.openConnection() as JarURLConnection
Manifest manifest = jarURLConnection.manifest
Attributes attrs = manifest.mainAttributes
return attrs.getValue("Implementation-Version")
return "9.0.0"
}
} catch (MissingPropertyException ignored) {
// running earlier version of DexGuard, ignore missing property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class BugsnagPlugin : Plugin<Project> {
val reactNativeEnabled = isReactNativeUploadEnabled(bugsnag)

// register bugsnag tasks
val mappingFilesProvider = createMappingFileProvider(project, variant, output)
val mappingFilesProvider = createMappingFileProvider(project, variant, output, bugsnag.dexguardMajorVersion.orNull)
val manifestTaskProvider = registerManifestUuidTask(project, output)

val manifestInfoProvider = manifestTaskProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import javax.inject.Inject
private val NULL_STRING: String? = null
private val NULL_BOOLEAN: Boolean? = null
private val NULL_FILE: File? = null
private val NULL_INT: Int? = null

internal const val UPLOAD_ENDPOINT_DEFAULT: String = "https://upload.bugsnag.com"

Expand Down Expand Up @@ -65,6 +66,9 @@ open class BugsnagPluginExtension @Inject constructor(objects: ObjectFactory) {
val sharedObjectPaths: ListProperty<File> = objects.listProperty<File>()
.convention(emptyList())

val dexguardMajorVersion: Property<Int> = objects.property<Int>()
.convention(NULL_INT)

val nodeModulesDir: Property<File> = objects.property<File>()
.convention(NULL_FILE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ import org.gradle.api.provider.Provider
internal fun createMappingFileProvider(
project: Project,
variant: BaseVariant,
variantOutput: BaseVariantOutput
variantOutput: BaseVariantOutput,
dexguardMajorVersion: Int? = null
): Provider<FileCollection> {
return findMappingFiles(project, variant, variantOutput)
return findMappingFiles(project, variant, variantOutput, dexguardMajorVersion)
.map { files -> files.filter { it.exists() } }
}

private fun findMappingFiles(
project: Project,
variant: BaseVariant,
variantOutput: BaseVariantOutput
variantOutput: BaseVariantOutput,
dexguardMajorVersion: Int? = null
): Provider<FileCollection> {
return when {
project.hasDexguardPlugin() -> {
if (getDexguardMajorVersionInt(project) >= 9) {
val dexguardVersion = dexguardMajorVersion ?: getDexguardMajorVersionInt(project)
if (dexguardVersion >= 9) {
project.provider {
val files = findMappingFileDexguard9(project, variant, variantOutput)
project.layout.files(files)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal fun Project.isDexguardEnabledForVariant(variant: BaseVariant): Boolean
* Retrieves the major version of DexGuard in use in the project
*/
internal fun getDexguardMajorVersionInt(project: Project): Int {
val version = GroovyCompat.getDexguardVersionString(project) ?: ""
val version = GroovyCompat.getDexguardVersionString(project) ?: "9.0.0"
val versionNumber = VersionNumber.parse(version)
return versionNumber.major
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ class DexguardCompatKtTest {
fun dexguardGetFromVersion() {
// dexguard.version set
`when`(extensions.findByName("dexguard")).thenReturn(mapOf(Pair("version", "8.7.02")))
assertEquals("8.7.02", GroovyCompat.getDexguardVersionString(proj))
assertEquals("9.0.0", GroovyCompat.getDexguardVersionString(proj))
}

@Test
fun dexguardMajorVersionNull() {
// handles when dexguard is not applied
`when`(extensions.findByName("dexguard")).thenReturn(null)
assertEquals(0, getDexguardMajorVersionInt(proj))
assertEquals(9, getDexguardMajorVersionInt(proj))
}

@Test
fun dexguardMajorFromVersion() {
// dexguard.version set
`when`(extensions.findByName("dexguard")).thenReturn(mapOf(Pair("version", "8.7.02")))
assertEquals(8, getDexguardMajorVersionInt(proj))
assertEquals(9, getDexguardMajorVersionInt(proj))
}

@Test
Expand Down

0 comments on commit 3d02f6a

Please sign in to comment.