Revert "Sandbox soong_build by changing to root directory"
This reverts commit 05c25ccb4adb5329add700b533416c226cdbfa96.
Reason for revert: broke absolute OUT_DIR
Bug: 146437378
Change-Id: I523ed79d40e1c1ef040212ba794a7a084abea75d
diff --git a/java/jdeps.go b/java/jdeps.go
index 49e3de3..fccc40f 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -17,6 +17,7 @@
import (
"encoding/json"
"fmt"
+ "os"
"android/soong/android"
)
@@ -91,21 +92,23 @@
moduleInfos[name] = dpInfo
})
- jfpath := android.PathForOutput(ctx, jdepsJsonFileName)
+ jfpath := android.PathForOutput(ctx, jdepsJsonFileName).String()
err := createJsonFile(moduleInfos, jfpath)
if err != nil {
ctx.Errorf(err.Error())
}
}
-func createJsonFile(moduleInfos map[string]android.IdeInfo, jfpath android.WritablePath) error {
+func createJsonFile(moduleInfos map[string]android.IdeInfo, jfpath string) error {
+ file, err := os.Create(jfpath)
+ if err != nil {
+ return fmt.Errorf("Failed to create file: %s, relative: %v", jdepsJsonFileName, err)
+ }
+ defer file.Close()
buf, err := json.MarshalIndent(moduleInfos, "", "\t")
if err != nil {
- return fmt.Errorf("JSON marshal of java deps failed: %s", err)
+ return fmt.Errorf("Write file failed: %s, relative: %v", jdepsJsonFileName, err)
}
- err = android.WriteFileToOutputDir(jfpath, buf, 0666)
- if err != nil {
- return fmt.Errorf("Writing java deps to %s failed: %s", jfpath.String(), err)
- }
+ fmt.Fprintf(file, string(buf))
return nil
}