diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2fc68590..ad936e54 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/Gemfile.lock b/Gemfile.lock
index 1ad9b0e3..dc21ae7d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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)
@@ -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)
@@ -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
diff --git a/detekt-baseline.xml b/detekt-baseline.xml
index 6b6325ec..e7698be7 100644
--- a/detekt-baseline.xml
+++ b/detekt-baseline.xml
@@ -9,13 +9,12 @@
MagicNumber:BugsnagPluginExtension.kt$BugsnagPluginExtension$60000
MagicNumber:BugsnagReleasesTask.kt$BugsnagReleasesTask$200
MagicNumber:MappingFileProvider.kt$9
- 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 */
+ MaxLineLength:BugsnagPlugin.kt$BugsnagPlugin$val mappingFilesProvider = createMappingFileProvider(project, variant, output, bugsnag.dexguardMajorVersion.orNull)
ReturnCount:BugsnagGenerateUnitySoMappingTask.kt$BugsnagGenerateUnitySoMappingTask.Companion$ @Suppress("SENSELESS_COMPARISON") internal fun isUnityLibraryUploadEnabled( bugsnag: BugsnagPluginExtension, android: BaseExtension ): Boolean
ReturnCount:BugsnagPlugin.kt$BugsnagPlugin$ private fun registerUploadSourceMapTask( project: Project, variant: BaseVariant, output: BaseVariantOutput, bugsnag: BugsnagPluginExtension, manifestInfoProvider: Provider<RegularFile> ): TaskProvider<out BugsnagUploadJsSourceMapTask>?
ReturnCount:ManifestUuidTaskV2Compat.kt$internal fun createManifestUpdateTask( bugsnag: BugsnagPluginExtension, project: Project, variantName: String, variantOutput: VariantOutput ): TaskProvider<BugsnagManifestUuidTask>?
SpreadOperator:DexguardCompat.kt$(buildDir, *path, variant.dirName, outputDir, "mapping.txt")
SwallowedException:NdkToolchain.kt$NdkToolchain.Companion$catch (e: Exception) { null }
- SwallowedException:NdkToolchain.kt$NdkToolchain.Companion$catch (e: Exception) { return@provider extensions.getByType(BaseExtension::class.java).ndkDirectory.absoluteFile }
TooGenericExceptionCaught:AbstractSoMappingTask.kt$AbstractSoMappingTask$e: Exception
TooGenericExceptionCaught:BugsnagHttpClientHelper.kt$exc: Throwable
TooGenericExceptionCaught:BugsnagMultiPartUploadRequest.kt$BugsnagMultiPartUploadRequest$exc: Throwable
diff --git a/gradle.properties b/gradle.properties
index 4f4816ca..395ad9ee 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -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/
diff --git a/src/main/groovy/com/bugsnag/android/gradle/GroovyCompat.groovy b/src/main/groovy/com/bugsnag/android/gradle/GroovyCompat.groovy
index c4e36610..02998e30 100644
--- a/src/main/groovy/com/bugsnag/android/gradle/GroovyCompat.groovy
+++ b/src/main/groovy/com/bugsnag/android/gradle/GroovyCompat.groovy
@@ -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
diff --git a/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPlugin.kt b/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPlugin.kt
index 7c4e48cb..c5d18d16 100644
--- a/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPlugin.kt
+++ b/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPlugin.kt
@@ -207,7 +207,7 @@ class BugsnagPlugin : Plugin {
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
diff --git a/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPluginExtension.kt b/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPluginExtension.kt
index 3f3c1a3a..09895b90 100644
--- a/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPluginExtension.kt
+++ b/src/main/kotlin/com/bugsnag/android/gradle/BugsnagPluginExtension.kt
@@ -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"
@@ -65,6 +66,9 @@ open class BugsnagPluginExtension @Inject constructor(objects: ObjectFactory) {
val sharedObjectPaths: ListProperty = objects.listProperty()
.convention(emptyList())
+ val dexguardMajorVersion: Property = objects.property()
+ .convention(NULL_INT)
+
val nodeModulesDir: Property = objects.property()
.convention(NULL_FILE)
diff --git a/src/main/kotlin/com/bugsnag/android/gradle/MappingFileProvider.kt b/src/main/kotlin/com/bugsnag/android/gradle/MappingFileProvider.kt
index e6ac3a16..47ed4c0a 100644
--- a/src/main/kotlin/com/bugsnag/android/gradle/MappingFileProvider.kt
+++ b/src/main/kotlin/com/bugsnag/android/gradle/MappingFileProvider.kt
@@ -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 {
- 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 {
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)
diff --git a/src/main/kotlin/com/bugsnag/android/gradle/internal/DexguardCompat.kt b/src/main/kotlin/com/bugsnag/android/gradle/internal/DexguardCompat.kt
index d70a43f1..0bc833d3 100644
--- a/src/main/kotlin/com/bugsnag/android/gradle/internal/DexguardCompat.kt
+++ b/src/main/kotlin/com/bugsnag/android/gradle/internal/DexguardCompat.kt
@@ -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
}
diff --git a/src/test/kotlin/com/bugsnag/android/gradle/internal/DexguardCompatKtTest.kt b/src/test/kotlin/com/bugsnag/android/gradle/internal/DexguardCompatKtTest.kt
index d5e2f334..b1370556 100644
--- a/src/test/kotlin/com/bugsnag/android/gradle/internal/DexguardCompatKtTest.kt
+++ b/src/test/kotlin/com/bugsnag/android/gradle/internal/DexguardCompatKtTest.kt
@@ -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