Skip to content

Commit

Permalink
See #17 (#18)
Browse files Browse the repository at this point in the history
* Update sbt and scala
* Added more strict version check
  • Loading branch information
vimalaguti authored and lloydmeta committed Dec 22, 2018
1 parent 31661b1 commit b8f1eb7
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 24 deletions.
6 changes: 6 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ you can change the target platform for your build straight from your command lin
```scala
sbt compile -Dsbt.javacpp.platform="android-arm android-x86"
```

In case you want to select a different javacpp version:

```scala
javaCppVersion := "1.4.3"
```
13 changes: 6 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name := """sbt-javacpp"""
name := "sbt-javacpp"

version := "1.14-SNAPSHOT"

Expand All @@ -8,11 +8,11 @@ sbtPlugin := true

publishMavenStyle := true

scalaVersion := "2.12.4"
scalaVersion in Global := "2.12.8"

sbtVersion in Global := "1.0.4"
sbtVersion in Global := "1.2.7"

crossSbtVersions := Vector("0.13.17", "1.0.4")
crossSbtVersions := Vector("0.13.17", "1.2.7")

scalaCompilerBridgeSource := {
val sv = appConfiguration.value.provider.id.version
Expand All @@ -23,7 +23,7 @@ publishArtifact in Test := false

pomIncludeRepository := { _ => false }

libraryDependencies += "org.bytedeco" % "javacpp" % "1.4"
libraryDependencies += "org.bytedeco" % "javacpp" % "1.4.3"

scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-Xlint", "-Xlog-free-terms")

Expand All @@ -35,7 +35,7 @@ publishTo := {
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

pomExtra := (
pomExtra :=
<url>https://github.com/bytedeco/sbt-javacpp</url>
<licenses>
<license>
Expand All @@ -55,4 +55,3 @@ pomExtra := (
<url>https://beachape.com</url>
</developer>
</developers>
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Activator-generated Properties
#Mon Feb 22 20:41:33 JST 2016
template.uuid=e17acfbb-1ff5-41f5-b8cf-2c40be6a8340
sbt.version=0.13.17
sbt.version=0.13.17
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
classpathTypes += "maven-plugin"

addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
5 changes: 1 addition & 4 deletions project/scripted.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
libraryDependencies += {
"org.scala-sbt" % "scripted-plugin" % sbtVersion.value
}

libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
2 changes: 1 addition & 1 deletion scripted.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ scriptedLaunchOpts := { scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
}

scriptedBufferLog := false
scriptedBufferLog := false
32 changes: 23 additions & 9 deletions src/main/scala/org/bytedeco/sbt/javacpp/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import scala.language.postfixOps
import sbt._
import sbt.Keys._

import scala.util.Try

object Plugin extends AutoPlugin {

override def projectSettings: Seq[Setting[_]] = {
Expand All @@ -21,7 +23,7 @@ object Plugin extends AutoPlugin {
}

object Versions {
val javaCppVersion = "1.4"
val javaCppVersion = "1.4.3"
}

object autoImport {
Expand All @@ -37,25 +39,37 @@ object Plugin extends AutoPlugin {
private def javaCppPresetDependencies: Def.Setting[Seq[ModuleID]] = {
import autoImport._
libraryDependencies ++= {
val majorMinorJavaCppVersion = majorMinorOnly(javaCppVersion.value)
val cppPresetVersion = majorMinorOnly(javaCppVersion.value)
javaCppPresetLibs.value.flatMap {
case (libName, libVersion) => {
val generic = "org.bytedeco.javacpp-presets" % libName % s"$libVersion-$majorMinorJavaCppVersion" classifier ""
case (libName, libVersion) =>
val generic = "org.bytedeco.javacpp-presets" % libName % s"$libVersion-$cppPresetVersion" classifier ""
val platformSpecific = javaCppPlatform.value.map { platform =>
"org.bytedeco.javacpp-presets" % libName % s"$libVersion-$majorMinorJavaCppVersion" classifier platform
"org.bytedeco.javacpp-presets" % libName % s"$libVersion-$cppPresetVersion" classifier platform
}
generic +: platformSpecific
}
}
}
}

/**
* Before javacpp 1.4
* Given a version string, simply drops the patch level and returns the major-minor version only
* @param version
*
* Starting from javacpp 1.4
* The version number of the presets are equal to the javacpp version.
*
* @param version eg. "1.4.2"
*/
private def majorMinorOnly(version: String): String = {
version.split('.').take(2).mkString(".")
private def majorMinorOnly(version: String): String =
version match {
case VersionSplit(a :: b :: _) if a < 2 & b < 4 => s"$a.$b"
case VersionSplit(_) => version
case _ => throw new IllegalArgumentException("Version format not recognized")
}

private object VersionSplit {
def unapply(arg: String): Option[List[Int]] =
Try(arg.split('.').map(_.toInt).toList).toOption
}

}
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-javacpp/simple/build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version := "0.1"

scalaVersion := "2.11.8"
scalaVersion := "2.11.12"

libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"

0 comments on commit b8f1eb7

Please sign in to comment.