1
1
package scala .cli .commands
2
2
3
3
import caseapp ._
4
- import com .google .gson .Gson
5
4
import upickle .default .{ReadWriter , macroRW }
6
5
7
- import java .io .{BufferedReader , File , FileReader }
6
+ import java .io .File
7
+ import java .nio .charset .Charset
8
8
import java .nio .file .{AtomicMoveNotSupportedException , FileAlreadyExistsException , Files }
9
9
import java .util .{Locale , Random }
10
10
@@ -13,6 +13,7 @@ import scala.build.blooprifle.{BloopRifleConfig, BloopVersion, BspConnectionAddr
13
13
import scala .build .{Bloop , Logger , Os }
14
14
import scala .cli .internal .Pid
15
15
import scala .concurrent .duration .{Duration , FiniteDuration }
16
+ import scala .io .Codec
16
17
import scala .util .Properties
17
18
18
19
// format: off
@@ -190,21 +191,23 @@ final case class SharedCompilationServerOptions(
190
191
))(v => BloopRifleConfig .Strict (BloopVersion (v)))
191
192
192
193
def bloopDefaultJvmOptions (logger : Logger ): List [String ] = {
193
- val file = new File (bloopGlobalOptionsFile)
194
- if (file .exists() && file .isFile())
194
+ val filePath = os. Path (bloopGlobalOptionsFile, Os .pwd )
195
+ if (os .exists(filePath ) && os .isFile(filePath ))
195
196
try {
196
- val reader = new BufferedReader (new FileReader (file))
197
- val gson = new Gson ()
198
- val json = gson.fromJson(reader, classOf [BloopJson ])
199
- json.javaOptions.toList
197
+ val json = ujson.read(
198
+ os.read(filePath : os.ReadablePath , charSet = Codec (Charset .defaultCharset()))
199
+ )
200
+ val bloopJson = upickle.default.read(json)(BloopJson .jsonCodec)
201
+ bloopJson.javaOptions
200
202
}
201
203
catch {
202
204
case e : Throwable =>
205
+ System .err.println(s " Error parsing global bloop config in ' $filePath': " )
203
206
e.printStackTrace()
204
207
List .empty
205
208
}
206
209
else {
207
- logger.debug(s " Bloop global options file ' ${file.toPath().toAbsolutePath()} ' not found. " )
210
+ logger.debug(s " Bloop global options file ' $filePath ' not found. " )
208
211
List .empty
209
212
}
210
213
}
0 commit comments