Skip to content

Commit

Permalink
Fix warning (not only) in users' code (#59)
Browse files Browse the repository at this point in the history
* Fix warning (not only) in users' code
  • Loading branch information
sideeffffect authored Jul 28, 2021
1 parent 2a71d1d commit b78a634
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ val macrosParadiseVersion = "2.1.1"

ThisBuild / versionScheme := Some("semver-spec")
ThisBuild / organization := "com.github.sbt"
ThisBuild / scalacOptions ++= Seq("-deprecation", "-feature")
ThisBuild / scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
ThisBuild / licenses := Seq(("BSD New", url("http://opensource.org/licenses/BSD-3-Clause")))
ThisBuild / homepage := Some(url("https://github.com/jodersky/sbt-jni"))
ThisBuild / developers := List(
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/scala-2/com/github/sbt/jni/Process.scala

This file was deleted.

6 changes: 3 additions & 3 deletions core/src/main/scala-2/com/github/sbt/jni/annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class nativeLoaderAnnotationMacro(val c: Context) {
val tmp: Path = Files.createTempDirectory("jni-")
val plat: String = {
val line = try {
scala.sys.process.Process("uname -sm").lineStream.head
scala.sys.process.Process("uname -sm").!!.linesIterator.next()
} catch {
case ex: Exception => sys.error("Error running `uname` command")
case _: Exception => sys.error("Error running `uname` command")
}
val parts = line.split(" ")
if (parts.length != 2) {
Expand Down Expand Up @@ -80,7 +80,7 @@ class nativeLoaderAnnotationMacro(val c: Context) {
def load(): Unit = try {
System.loadLibrary($nativeLibrary)
} catch {
case ex: UnsatisfiedLinkError => loadPackaged()
case _: UnsatisfiedLinkError => loadPackaged()
}

load()
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/scala-3/com/github/sbt/jni/Process.scala

This file was deleted.

11 changes: 7 additions & 4 deletions core/src/main/scala/com/github/sbt/jni/syntax/NativeLoader.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.sbt.jni.syntax

import com.github.sbt.jni.Process

import java.nio.file.{Files, Path}

class NativeLoader(nativeLibrary: String) {
Expand All @@ -16,7 +14,12 @@ object NativeLoader {

val tmp: Path = Files.createTempDirectory("jni-")
val plat: String = {
val line = Process.out("uname -sm")
val line =
try {
scala.sys.process.Process("uname -sm").!!.linesIterator.next()
} catch {
case _: Exception => sys.error("Error running `uname` command")
}
val parts = line.split(" ")
if (parts.length != 2) {
sys.error("Could not determine platform: 'uname -sm' returned unexpected string: " + line)
Expand Down Expand Up @@ -50,7 +53,7 @@ object NativeLoader {
def load(): Unit = try {
System.loadLibrary(nativeLibrary)
} catch {
case ex: UnsatisfiedLinkError => loadPackaged()
case _: UnsatisfiedLinkError => loadPackaged()
}

load()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object JniNative extends AutoPlugin {
arch + "-" + kernel
}
} catch {
case ex: Exception =>
case _: Exception =>
sLog.value.error("Error trying to determine platform.")
sLog.value.warn("Cannot determine platform! It will be set to 'unknown'.")
"unknown-unknown"
Expand Down

0 comments on commit b78a634

Please sign in to comment.