aboutsummaryrefslogtreecommitdiff
path: root/project/jni.scala
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2013-07-12 10:09:44 +0200
committerJakob Odersky <jodersky@gmail.com>2013-07-12 10:09:44 +0200
commit4b0cca3622e0c4272e14e5019f986c40cbbc4bf7 (patch)
tree8775b1880cfb96569db5c6e8c03533ad61b90abe /project/jni.scala
parentc9c4864d3b63459ea8d989d13d9e83a058e3145e (diff)
downloadakka-serial-4b0cca3622e0c4272e14e5019f986c40cbbc4bf7.tar.gz
akka-serial-4b0cca3622e0c4272e14e5019f986c40cbbc4bf7.tar.bz2
akka-serial-4b0cca3622e0c4272e14e5019f986c40cbbc4bf7.zip
add warining in case no JDK is found
Diffstat (limited to 'project/jni.scala')
-rw-r--r--project/jni.scala20
1 files changed, 16 insertions, 4 deletions
diff --git a/project/jni.scala b/project/jni.scala
index 7cde93b..5e248f2 100644
--- a/project/jni.scala
+++ b/project/jni.scala
@@ -1,9 +1,11 @@
import sbt._
import Keys._
import NativeKeys._
+import scala.util.Try
object JniKeys {
- val jdkHome = settingKey[File]("Home of JDK.")
+ val jdkHome = settingKey[Option[File]]("Home of JDK.")
+ val jdkHomeNotFound = taskKey[Unit]("Utility task that informs user that no JDK was found.")
val javahHeaderDirectory = settingKey[File]("Directory where generated javah header files are placed.")
val javahClasses = settingKey[Seq[String]]("Fully qualified names of classes containing native declarations.")
val javahClasspath = taskKey[Seq[File]]("Classpath to use in javah.")
@@ -14,12 +16,22 @@ object JniDefaults {
import JniKeys._
val defaultSettings: Seq[Setting[_]] = Seq(
- jdkHome := file(sys.env("JAVA_HOME")),
+ jdkHome := Try(file(sys.env("JAVA_HOME"))).toOption,
+ jdkHomeNotFound := jdkHomeNotFoundImpl.value,
+ nativeCompile in Native := ((nativeCompile in Native) dependsOn jdkHomeNotFound).value,
javahHeaderDirectory := (sourceManaged in Native).value / "javah",
- javah := javahImpl.value,
+ javah := javahImpl.value,
sourceGenerators in Native <+= javah map { headers => headers},
includeDirectories in Native += javahHeaderDirectory.value,
- includeDirectories in Native += jdkHome.value / "include")
+ includeDirectories in Native ++= jdkHome.value.map( jdk => jdk / "include").toSeq)
+
+ def jdkHomeNotFoundImpl = Def.task {
+ if (jdkHome.value == None) {
+ streams.value.log.warn(
+ "No JDK home directory found, any native code using JNI may not compile. Please set JAVA_HOME environment variable.")
+ }
+ ()
+ }
def javahImpl = Def.task {
val cps = javahClasspath.value