diff --git a/README.md b/README.md index 9979cdca..62683274 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ libraryDependencies ++= Seq( ``` Latest `version`: [![Maven][mavenImg]][mavenLink] -Although this library is currently only actively developed for Scala 2.11 and 2.12, -you can find reasonably recent versions of this library for Scala 2.10 [here](https://oss.sonatype.org/#nexus-search;quick~better-files) +Although this library is currently only actively developed for Scala 2.12, +you can find reasonably recent versions of this library for Scala 2.10 and 2.11 [here](https://oss.sonatype.org/#nexus-search;quick~better-files) ## Tests [![codecov][codecovImg]][codecovLink] * [FileSpec](core/src/test/scala/better/files/FileSpec.scala) @@ -71,8 +71,8 @@ you can find reasonably recent versions of this library for Scala 2.10 [here](ht [codacyImg2]: https://api.codacy.com/project/badge/grade/0e2aeb7949bc49e6802afcc43a7a1aa1 [codacyLink]: https://www.codacy.com/app/pathikrit/better-files/dashboard -[mavenImg]: https://img.shields.io/maven-central/v/com.github.pathikrit/better-files_2.11.svg -[mavenImg2]: https://maven-badges.herokuapp.com/maven-central/com.github.pathikrit/better-files_2.11/badge.svg +[mavenImg]: https://img.shields.io/maven-central/v/com.github.pathikrit/better-files_2.12.svg +[mavenImg2]: https://maven-badges.herokuapp.com/maven-central/com.github.pathikrit/better-files_2.12/badge.svg [mavenLink]: http://search.maven.org/#search%7Cga%7C1%7Cbetter-files [gitterImg]: https://img.shields.io/gitter/room/pathikrit/better-files.svg diff --git a/build.sbt b/build.sbt index d5924f7a..96d54232 100644 --- a/build.sbt +++ b/build.sbt @@ -3,8 +3,8 @@ val repo = "better-files" lazy val commonSettings = Seq( organization := s"com.github.$username", - scalaVersion := "2.11.8", - crossScalaVersions := Seq("2.11.8"), + scalaVersion := "2.12.1", + crossScalaVersions := Seq("2.12.1"), crossVersion := CrossVersion.binary, javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint"), scalacOptions ++= Seq( @@ -16,7 +16,7 @@ lazy val commonSettings = Seq( "-unchecked", "-Xfatal-warnings", "-Xlint", - "-Yinline-warnings", + //"-Yinline-warnings", //Removed in 2.12? "-Yno-adapted-args", "-Ywarn-dead-code", "-Ywarn-numeric-widen", diff --git a/circle.yml b/circle.yml index 7f62dcb7..d21ba559 100644 --- a/circle.yml +++ b/circle.yml @@ -8,7 +8,7 @@ test: override: - sbt +clean +coverage +test # post: -# - cp -r target/scala-2.11/ $CIRCLE_ARTIFACTS +# - cp -r target/scala-2.12/ $CIRCLE_ARTIFACTS deployment: master: diff --git a/core/src/main/scala/better/files/Cmds.scala b/core/src/main/scala/better/files/Cmds.scala index 9c2b5641..43f33756 100644 --- a/core/src/main/scala/better/files/Cmds.scala +++ b/core/src/main/scala/better/files/Cmds.scala @@ -3,7 +3,7 @@ package better.files import java.nio.file.attribute.{PosixFileAttributes, PosixFilePermission, PosixFilePermissions} import java.util.zip.{Deflater, ZipOutputStream} -import scala.collection.JavaConversions._ +import scala.collection.JavaConverters._ import scala.io.Codec /** @@ -101,7 +101,7 @@ object Cmds { * @return file */ def chmod(permissions: String, file: File): File = - file.setPermissions(PosixFilePermissions.fromString(permissions).toSet) + file.setPermissions(PosixFilePermissions.fromString(permissions).asScala.toSet) def chmod_+(permission: PosixFilePermission, file: File): File = file.addPermission(permission) diff --git a/core/src/main/scala/better/files/File.scala b/core/src/main/scala/better/files/File.scala index cfee15d9..0e21e5d2 100644 --- a/core/src/main/scala/better/files/File.scala +++ b/core/src/main/scala/better/files/File.scala @@ -9,7 +9,7 @@ import java.time.Instant import java.util.zip.{Deflater, ZipFile} import javax.xml.bind.DatatypeConverter -import scala.collection.JavaConversions._ +import scala.collection.JavaConverters._ import scala.io.{BufferedSource, Codec, Source} import scala.util.Properties @@ -194,7 +194,7 @@ class File private(val path: Path) { * @return all lines in this file */ def lines(implicit codec: Codec): Traversable[String] = - Files.readAllLines(path, codec) + Files.readAllLines(path, codec).asScala /** * Iterate over lines in a file (auto-close stream on complete) @@ -233,7 +233,7 @@ class File private(val path: Path) { * @return */ def appendLines(lines: String*)(implicit openOptions: File.OpenOptions = File.OpenOptions.append, codec: Codec): this.type = { - Files.write(path, lines, codec, openOptions: _*) + Files.write(path, lines.asJava, codec, openOptions: _*) this } @@ -352,7 +352,7 @@ class File private(val path: Path) { newOutputStream(openOptions).autoClosed def newFileChannel(implicit openOptions: File.OpenOptions = File.OpenOptions.default, attributes: File.Attributes = File.Attributes.default): FileChannel = - FileChannel.open(path, openOptions.toSet, attributes: _*) + FileChannel.open(path, openOptions.toSet.asJava, attributes: _*) def fileChannel(implicit openOptions: File.OpenOptions = File.OpenOptions.default, attributes: File.Attributes = File.Attributes.default): ManagedResource[FileChannel] = newFileChannel(openOptions, attributes).autoClosed @@ -502,13 +502,13 @@ class File private(val path: Path) { walk()(visitOptions).map(f => Files.size(f.path)).sum def permissions(implicit linkOptions: File.LinkOptions = File.LinkOptions.default): Set[PosixFilePermission] = - Files.getPosixFilePermissions(path, linkOptions: _*).toSet + Files.getPosixFilePermissions(path, linkOptions: _*).asScala.toSet def permissionsAsString(implicit linkOptions: File.LinkOptions = File.LinkOptions.default): String = - PosixFilePermissions.toString(permissions(linkOptions)) + PosixFilePermissions.toString(permissions(linkOptions).asJava) def setPermissions(permissions: Set[PosixFilePermission]): this.type = { - Files.setPosixFilePermissions(path, permissions) + Files.setPosixFilePermissions(path, permissions.asJava) this } @@ -681,7 +681,7 @@ class File private(val path: Path) { walk()(visitOptions).map(relativize) def relativize(destination: File): Path = - path relativize destination.path + path.relativize(destination.path) def isSamePathAs(that: File): Boolean = this.path == that.path @@ -779,7 +779,7 @@ class File private(val path: Path) { def unzipTo(destination: File)(implicit codec: Codec): destination.type = { for { zipFile <- new ZipFile(toJava, codec).autoClosed - entry <- zipFile.entries() + entry <- zipFile.entries().asScala file = destination.createChild(entry.getName, entry.isDirectory) if !entry.isDirectory } zipFile.getInputStream(entry) > file.newOutputStream @@ -821,7 +821,7 @@ object File { Paths.get(uri) def roots: Iterable[File] = - FileSystems.getDefault.getRootDirectories.map(File.apply) + FileSystems.getDefault.getRootDirectories.asScala.map(File.apply) def root: File = roots.head diff --git a/core/src/main/scala/better/files/Implicits.scala b/core/src/main/scala/better/files/Implicits.scala index 9797dc6e..ed4a1004 100644 --- a/core/src/main/scala/better/files/Implicits.scala +++ b/core/src/main/scala/better/files/Implicits.scala @@ -123,11 +123,6 @@ trait Implicits { new BufferedWriter(writer) } - implicit class BufferedIteratorOps[A](it: BufferedIterator[A]) { - def headOption: Option[A] = - when(it.hasNext)(it.head) // TODO: https://issues.scala-lang.org/browse/SI-9691 - } - implicit class FileChannelOps(fc: FileChannel) { def toMappedByteBuffer: MappedByteBuffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()) diff --git a/core/src/main/scala/better/files/ThreadBackedFileMonitor.scala b/core/src/main/scala/better/files/ThreadBackedFileMonitor.scala index b7530677..82d2f853 100644 --- a/core/src/main/scala/better/files/ThreadBackedFileMonitor.scala +++ b/core/src/main/scala/better/files/ThreadBackedFileMonitor.scala @@ -15,9 +15,7 @@ abstract class ThreadBackedFileMonitor(val root: File, maxDepth: Int) extends Fi override def run() = Iterator.continually(service.take()) foreach process } thread.setDaemon(true) - thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler { - override def uncaughtException(thread: Thread, exception: Throwable) = onException(exception) - }) + thread.setUncaughtExceptionHandler((thread, exception) => onException(exception)) def this(root: File, recursive: Boolean = true) = this(root, if (recursive) Int.MaxValue else 0) @@ -26,8 +24,8 @@ abstract class ThreadBackedFileMonitor(val root: File, maxDepth: Int) extends Fi val path = key.watchable().asInstanceOf[Path] - import scala.collection.JavaConversions._ - key.pollEvents() foreach { + import scala.collection.JavaConverters._ + key.pollEvents().asScala foreach { case event: WatchEvent[Path] @unchecked => val target: File = path resolve event.context() if (reactTo(target)) {