diff options
author | 2020-01-10 17:35:22 +0000 | |
---|---|---|
committer | 2020-01-10 17:35:22 +0000 | |
commit | e35e961aa925e6ab75daf455d36875b3d6511081 (patch) | |
tree | 27e9a02f9e216e9b25d7cafa03114b0cb02d2820 /java/jdeps.go | |
parent | 2827ccc126a37c0cff4336b2ea7155fa816b378c (diff) | |
parent | 05c25ccb4adb5329add700b533416c226cdbfa96 (diff) |
Merge "Sandbox soong_build by changing to root directory"
Diffstat (limited to 'java/jdeps.go')
-rw-r--r-- | java/jdeps.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/java/jdeps.go b/java/jdeps.go index fccc40fa8..49e3de3cc 100644 --- a/java/jdeps.go +++ b/java/jdeps.go @@ -17,7 +17,6 @@ package java import ( "encoding/json" "fmt" - "os" "android/soong/android" ) @@ -92,23 +91,21 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont moduleInfos[name] = dpInfo }) - jfpath := android.PathForOutput(ctx, jdepsJsonFileName).String() + jfpath := android.PathForOutput(ctx, jdepsJsonFileName) err := createJsonFile(moduleInfos, jfpath) if err != nil { ctx.Errorf(err.Error()) } } -func createJsonFile(moduleInfos map[string]android.IdeInfo, jfpath string) error { - file, err := os.Create(jfpath) +func createJsonFile(moduleInfos map[string]android.IdeInfo, jfpath android.WritablePath) error { + buf, err := json.MarshalIndent(moduleInfos, "", "\t") if err != nil { - return fmt.Errorf("Failed to create file: %s, relative: %v", jdepsJsonFileName, err) + return fmt.Errorf("JSON marshal of java deps failed: %s", err) } - defer file.Close() - buf, err := json.MarshalIndent(moduleInfos, "", "\t") + err = android.WriteFileToOutputDir(jfpath, buf, 0666) if err != nil { - return fmt.Errorf("Write file failed: %s, relative: %v", jdepsJsonFileName, err) + return fmt.Errorf("Writing java deps to %s failed: %s", jfpath.String(), err) } - fmt.Fprintf(file, string(buf)) return nil } |