mirror of https://github.com/sbt/sbt.git
[2.x] refactor: Use Files.writeString instead of Files.write (#9093)
This commit is contained in:
parent
60cbde453f
commit
9d620f3b1f
|
|
@ -31,7 +31,7 @@ object LockFile {
|
|||
val json = Converter.toJson(data).get
|
||||
val content = PrettyPrinter(json)
|
||||
lockFile.getParentFile.mkdirs()
|
||||
Files.write(lockFile.toPath, content.getBytes(StandardCharsets.UTF_8))
|
||||
Files.writeString(lockFile.toPath, content)
|
||||
} match {
|
||||
case Success(_) => Right(())
|
||||
case Failure(ex) => Left(s"Failed to write lock file: ${ex.getMessage}")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ import java.nio.file.Files
|
|||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,6 @@ object Main {
|
|||
"Expected not to find classes from argonaut"
|
||||
)
|
||||
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ object Main {
|
|||
"Expected not to find class from cats-mtl"
|
||||
)
|
||||
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ import org.apache.zookeeper.ZooKeeper
|
|||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, classOf[ZooKeeper].getSimpleName.getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, classOf[ZooKeeper].getSimpleName)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ import java.nio.file.Paths
|
|||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
val msg = Bar.value
|
||||
Files.write(Paths.get("baz/output"), msg.getBytes("UTF-8"))
|
||||
Files.writeString(Paths.get("baz/output"), msg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ object Main {
|
|||
def main(args: Array[String]): Unit = {
|
||||
val msg = CC(2, A.msg).asJson.spaces2
|
||||
|
||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, msg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ object Main {
|
|||
|
||||
assert(hadoopVersion == "2.6.0")
|
||||
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ object Main {
|
|||
// assert(Thread.currentThread.getContextClassLoader.getResource("org/nlogo/nvm/Task.class") != null)
|
||||
// Thread.currentThread.getContextClassLoader.getResource("org/nlogo/nvm/Task.class")
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ csrExtraCredentials += {
|
|||
|foo.https-only=false
|
||||
""".stripMargin
|
||||
val dest = (ThisBuild / baseDirectory).value / "project" / "target" / "cred"
|
||||
Files.write(dest.toPath, content.getBytes("UTF-8"))
|
||||
Files.writeString(dest.toPath, content)
|
||||
lmcoursier.credentials.FileCredentials(dest.toString)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ object Main {
|
|||
// assert(Thread.currentThread.getContextClassLoader.getResource("org/nlogo/nvm/Task.class") != null)
|
||||
// Thread.currentThread.getContextClassLoader.getResource("org/nlogo/nvm/Task.class")
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ object Main {
|
|||
val l = Generic[CC].to(cc)
|
||||
val msg = l.head
|
||||
|
||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, msg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ object Main {
|
|||
val l = Generic[CC].to(cc)
|
||||
val msg = l.head
|
||||
|
||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, msg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ object Main {
|
|||
// TODO Use some jvm-repr stuff as a test
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, A.default.msg.getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, A.default.msg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ import java.nio.file.Files
|
|||
*/
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ object Main {
|
|||
// TODO Use some jvm-repr stuff
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ import java.nio.file.Files
|
|||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,6 @@ object Main {
|
|||
notFromCoursierCache("scala-library")
|
||||
assert(props.lengthCompare(1) == 0, s"Found several library.properties files in classpath: $props")
|
||||
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ import java.nio.file.Files
|
|||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ import java.nio.file.Files
|
|||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ import org.apache.zookeeper.ZooKeeper
|
|||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
Files.write(new File("output").toPath, classOf[ZooKeeper].getSimpleName.getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, classOf[ZooKeeper].getSimpleName)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ import java.io.File
|
|||
import java.nio.file.Files
|
||||
|
||||
@main def hello() =
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
Files.writeString(new File("output").toPath, "OK")
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ package sbt
|
|||
package internal
|
||||
package librarymanagement
|
||||
|
||||
import java.nio.charset.StandardCharsets.UTF_8
|
||||
import java.nio.file.Files
|
||||
|
||||
import lmcoursier.definitions.{ Configuration, Project }
|
||||
|
|
@ -66,7 +65,7 @@ object IvyXml {
|
|||
val content0 = rawContent(currentProject, shadedConfigOpt, bomForcedDeps)
|
||||
cacheIvyFile.getParentFile.mkdirs()
|
||||
log.debug(s"writing Ivy file $cacheIvyFile")
|
||||
Files.write(cacheIvyFile.toPath, content0.getBytes(UTF_8))
|
||||
Files.writeString(cacheIvyFile.toPath, content0)
|
||||
|
||||
// Just writing an empty file here... Are these only used?
|
||||
cacheIvyPropertiesFile.getParentFile.mkdirs()
|
||||
|
|
|
|||
Loading…
Reference in New Issue