Fix writing soong.variables .
ConfiguredJarList had a marshaler but no unmarshaler.
Bug: 182965747
Test: Presubmits.
Change-Id: Id03669f4a0a3d389063a4e4b11af6d6be63dbba3
diff --git a/android/config.go b/android/config.go
index f4685a1..2f8cb57 100644
--- a/android/config.go
+++ b/android/config.go
@@ -19,6 +19,7 @@
import (
"encoding/json"
+ "errors"
"fmt"
"io/ioutil"
"os"
@@ -1635,6 +1636,20 @@
return nil
}
+func (l *ConfiguredJarList) MarshalJSON() ([]byte, error) {
+ if len(l.apexes) != len(l.jars) {
+ return nil, errors.New(fmt.Sprintf("Inconsistent ConfiguredJarList: apexes: %q, jars: %q", l.apexes, l.jars))
+ }
+
+ list := make([]string, 0, len(l.apexes))
+
+ for i := 0; i < len(l.apexes); i++ {
+ list = append(list, l.apexes[i]+":"+l.jars[i])
+ }
+
+ return json.Marshal(list)
+}
+
// ModuleStem hardcodes the stem of framework-minus-apex to return "framework".
//
// TODO(b/139391334): hard coded until we find a good way to query the stem of a