core/src/commonMain/kotlin/gms/OssLicenseParser.kt
changeset 30 763a6573b900
parent 24 f07de07b90c4
child 34 ce299aacc068
--- a/core/src/commonMain/kotlin/gms/OssLicenseParser.kt	Thu Apr 03 16:11:04 2025 -0400
+++ b/core/src/commonMain/kotlin/gms/OssLicenseParser.kt	Thu Apr 03 17:24:24 2025 -0400
@@ -29,16 +29,20 @@
 /**
  * Parse licences data generated by the "com.google.android.gms.oss-licenses-plugin" gradle plugin.
  */
-class OssLicenseParser {
+class OssLicenseParser(
+    thirdPartyLicensesSource: Source,
+    thirdPartyLicensesMetadataSource: Source
+): AutoCloseable {
+
+    private val thirdPartyLicensesInput = thirdPartyLicensesSource.buffer()
+    private val thirdPartyLicensesMetadataInput = thirdPartyLicensesMetadataSource.buffer()
 
     /**
      * Parse licenses
      * @param [thirdPartyLicensesInput] is usually res/raw/third_party_licenses file
      * @param [thirdPartyLicensesMetadataInput] is usually res/raw/third_party_license_metadata file
      */
-    fun parseLicenses(
-        thirdPartyLicensesInput: Source, thirdPartyLicensesMetadataInput: Source
-    ): Map<String, String> {
+    fun parseLicenses(): Map<String, String> {
         val licenses = readLicensesFile(thirdPartyLicensesInput)
         return buildLicenseInfo(licenses, thirdPartyLicensesMetadataInput)
     }
@@ -71,6 +75,11 @@
         }
     }
 
+    override fun close() {
+        thirdPartyLicensesInput.close()
+        thirdPartyLicensesMetadataInput.close()
+    }
+
     companion object
 }