aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2016-01-17 17:19:14 -0800
committerJakob Odersky <jodersky@gmail.com>2016-01-17 17:19:14 -0800
commit9194209277f5a58bc74f49157bdaacba473951c4 (patch)
tree9376079f2612db6c001c48e8749acac4aad26e1d
parent2b343f73fc5b7605b22af41c675c2afc86d2a447 (diff)
downloadsbt-jni-9194209277f5a58bc74f49157bdaacba473951c4.tar.gz
sbt-jni-9194209277f5a58bc74f49157bdaacba473951c4.tar.bz2
sbt-jni-9194209277f5a58bc74f49157bdaacba473951c4.zip
Remove old plugins
-rw-r--r--jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniNative.scala.old123
-rw-r--r--jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniPackage.scala.old183
2 files changed, 0 insertions, 306 deletions
diff --git a/jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniNative.scala.old b/jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniNative.scala.old
deleted file mode 100644
index 9cfa2af..0000000
--- a/jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniNative.scala.old
+++ /dev/null
@@ -1,123 +0,0 @@
-package ch.jodersky.sbt.jni
-
-import build._
-import ch.jodersky.jni.{NativeLoader, Platform}
-import sbt._
-import sbt.Keys._
-
-object JniNative extends AutoPlugin {
-
- override def requires = plugins.JvmPlugin
-
- object autoImport {
-
- val jni = taskKey[File]("Builds a native library (by calling the native build tool).")
-
- val jniPlatform = settingKey[Platform]("Platform of the system this build is running on.")
- val jniBuildTool = taskKey[BuildTool]("The build tool to be used when building a native library.")
-
- val jniLibraryPath = settingKey[String]("String that is prepended to the path of a native library when packaged.")
-
- }
- import autoImport._
-
- lazy val mainSettings: Seq[Setting[_]] = Seq(
-
- sourceDirectory in jni := baseDirectory.value / "src",
-
- target in jni := target.value / "native" / (jniPlatform in jni).value.id,
-
- jniPlatform in jni := Platform.current.getOrElse {
- sLog.value.warn("Warning: cannot determine platform! It will be set to 'unknown'.")
- Platform.Unknown
- },
-
- jniBuildTool in jni := {
- val tools = Seq(CMake, Autotools)
-
- val base = (sourceDirectory in jni).value
-
- val tool = if (base.exists && base.isDirectory) {
- tools.find(t => t detect base)
- } else {
- None
- }
- tool.getOrElse(
- sys.error("No supported native build tool detected. " +
- s"Check that the setting 'sourceDirectory in jni' (currently $base) " +
- "points to a valid directory. Supported build tools are: " +
- tools.map(_.name).mkString(","))
- )
- },
-
- clean in jni := {
- val log = streams.value.log
- val tool = try {
- Some((jniBuildTool in jni).value)
- } catch {
- case _: Exception => None
- }
- tool foreach { t =>
- log.debug("Cleaning native build")
- t.api.clean(
- (sourceDirectory in jni).value,
- log
- )
- }
- },
-
- jni := {
- val tool = (jniBuildTool in jni).value
- val dir = (sourceDirectory in jni).value
- val buildDir = (target in jni).value / "build"
- val targetDir = (target in jni).value / "lib"
- val log = streams.value.log
-
- IO.createDirectory(buildDir)
- IO.createDirectory(targetDir)
-
- tool.api.library(dir, buildDir, targetDir, log)
- },
-
- clean := {
- (clean in jni).value
- clean.value
- },
-
- jniLibraryPath in jni := {
- "/" + organization.value.replaceAll("\\.", "/") + "/" + name.value
- }
-
- )
-
- lazy val resourceSettings: Seq[Setting[_]] = Seq(
-
- unmanagedResourceDirectories in Compile += baseDirectory.value / "lib_native",
-
- resourceGenerators in Compile += Def.task {
- //build native library
- val library = jni.value
-
- //native library as a managed resource file
- val libraryResource = (resourceManaged in Compile).value /
- NativeLoader.fullLibraryPath(
- (jniLibraryPath in jni).value,
- (jniPlatform in jni).value
- )
-
- //copy native library to a managed resource (so it can also be loaded when not packaged as a jar)
- IO.copyFile(library, libraryResource)
-
- Seq(libraryResource)
- }.taskValue
-
- )
-
-
-
- override lazy val projectSettings = mainSettings ++ resourceSettings ++ Seq(
- //don't add scala version to native jars
- crossPaths := false
- )
-
-}
diff --git a/jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniPackage.scala.old b/jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniPackage.scala.old
deleted file mode 100644
index 60980f5..0000000
--- a/jni-plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/JniPackage.scala.old
+++ /dev/null
@@ -1,183 +0,0 @@
-package ch.jodersky.sbt.jni
-
-import build._
-import ch.jodersky.jni.{NativeLoader, Platform}
-import sbt._
-import sbt.Keys._
-
-object JniPackager extends AutoPlugin {
-
- override def requires = Jni
- override def trigger = allRequirements
-
- object autoImport {
-
- //Main task, inspect this first
- //val packageNative = taskKey[File]("Packages native libraries in a jar.")
-
- //val packageNativeMappings = taskKey[Seq[(File, String)]]("")
-
- val nativeLibraryPath = settingKey[String](
- "String that is prepended to the path of a native library when packaged.")
-
- val enableNativeCompilation = settingKey[Boolean](
- "Determines if native compilation is enabled in a scoped key (typically for packaging).")
-
- val unmanagedNativeDirectories = settingKey[Seq[File]](
- """|Unmanaged directories containing native libraries. The libraries must be regular files
- |contained in a subdirectory corresponding to a platform.""".stripMargin)
-
- val unmanagedNativeLibraries = taskKey[Map[Platform, File]]("")
-
- val managedNativeLibraries = taskKey[Map[Platform, File]]("")
-
- }
- import autoImport._
- import Jni.autoImport._
-
- lazy val settings: Seq[Setting[_]] = Seq(
-
- nativeLibraryPath := {
- val orgPath = organization.value.replaceAll("\\.", "/")
- s"/${orgPath}/${name.value}/native"
- },
-
- //Make NativeLoader available to project
- libraryDependencies += "ch.jodersky" %% "jni-library" % Version.PluginVersion,
-
- name in packageNative := {
- name.value + "-native-" + version.value + ".jar"
- },
-
- enableNativeCompilation := true,
-
- unmanagedNativeDirectories := Seq(baseDirectory.value / "lib_native"),
-
- unmanagedNativeLibraries := {
- val dirs: Seq[File] = unmanagedNativeDirectories.value
- val seq: Seq[(Platform, File)] = for (
- dir <- dirs;
- platformDir <- dir.listFiles();
- if platformDir.isDirectory;
- platform = Platform.fromId(platformDir.name);
- library <- platformDir.listFiles();
- if library.isFile
- ) yield {
- platform -> library.getCanonicalFile()
- }
-
- seq.toMap
- },
-
- managedNativeLibraries := Def.taskDyn[Map[Platform, File]]{
- val enableManaged = (enableNativeCompilation).value
- if (enableManaged) Def.task {
- val library: File = (nativeCompile in Compile).value
- val platform = (nativePlatform in Compile).value
- Map(platform -> library)
- } else Def.task{
- Map()
- }
- }.value,
-
- resourceGenerators in Compile += Def.task {
-
- val libraries: Seq[(Patform, File)] = (managedNativeLibraries.value ++ unmanagedNativeLibraries.value).toSeq
-
- val resources: Seq[File] = for ((plat, file) <- libraries) yield {
-
- //native library as a managed resource file
- val resource = (resourceManaged in Compile).value /
- NativeLoader.fullLibraryPath(
- (nativeLibraryPath).value,
- plat)
-
- //copy native library to a managed resource (so it can also be loaded when not packaged as a jar)
- IO.copyFile(file, resource)
- resource
- }
- resources
- }.taskValue,
-
- //don't add scala version to native jars
- crossPaths := false
-
- )
-
- override lazy val projectSettings = settings
- /*
- name in packageNative := name,
-
-
- //this is file name of the artifact
- artifactName in packageNative := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
- artifact.name + "-native." + module.revision + "." + artifact.extension
- }
-
- packageNative := {
- val log = streams.value.log
-
- val mappings: Seq[(File, String)] = {
- val libs = unmanagedNativeLibraries.value.toSeq ++ managedNativeLibraries.value.toSeq
- libs.map{ case (platform, file) =>
- file -> NativeLoader.fullLibraryPath(
- (nativeLibraryPath in Compile).value,
- platform)
- }
- }
-
- val manifest = new java.util.jar.Manifest
- val namer = (artifactName in packageNative).value
- val jar: File = (target in nativeCompile).value / namer(
- scalaVersion,
-
- (artifactName in packageNative).value
- )
-
- Package.makeJar(mappings, jar, manifest, log)
- jar
- },
- */
-
- //Add native jar to runtime classpath. Note that it is not added as a resource (this would cause
- //the native library to included in the main jar).
- //unmanagedClasspath in Runtime += Attributed.blank(packageNative.value),
-
- //Fork new JVM when running locally, since native libraries can only be loaded once
- //fork in run := true
-
- /*
- override lazy val projectSettings =
- Defaults.packageTaskSettings(packageNative, packageNativeMappings) ++
- addArtifact(artifact in packageNative, packageNative) ++
- inConfig(Compile)(settings) ++ Seq(
-
- packageNativeMappings := {
- val libs = (unmanagedNativeLibraries in Compile).value.toSeq ++
- (managedNativeLibraries in Compile).value.toSeq
- libs.map{ case (platform, file) =>
- file -> NativeLoader.fullLibraryPath(
- (nativeLibraryPath in Compile).value,
- platform)
- }
- },
-
- artifactClassifier in packageNative := Some("native"),
-
- //this is file name of the artifact
- artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
- artifact.name + "-foso" + module.revision + "." + artifact.extension
- },
-
- artifact in packageNative := {
- Artifact("foo", "jar", "jar", Some("native"), Nil, None, Map("platform" -> "all"))
- },
-
- crossVersion in packageNative := CrossVersion.Disabled
-// projectID in packageNative := { projectID.value.copy(crossVersion = CrossVersion.Disabled) }
-
-
- )
- */
-
-}