1name := "snappy-java"
2organization := "org.xerial.snappy"
3organizationName := "xerial.org"
4description := "snappy-java: A fast compression/decompression library"
5sonatypeProfileName := "org.xerial"
6
7credentials ++= {
8  if (sys.env.contains("SONATYPE_USERNAME") && sys.env.contains("SONATYPE_PASSWORD")) {
9    Seq(Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", sys.env("SONATYPE_USERNAME"), sys.env("SONATYPE_PASSWORD")))
10  } else {
11    Seq.empty
12  }
13}
14
15publishTo := Some(
16  if (isSnapshot.value) {
17    Opts.resolver.sonatypeSnapshots
18  } else {
19    Opts.resolver.sonatypeStaging
20  }
21)
22
23pomExtra := {
24  <url>https://github.com/xerial/snappy-java</url>
25   <licenses>
26       <license>
27           <name>The Apache Software License, Version 2.0</name>
28            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
29            <distribution>repo</distribution>
30        </license>
31    </licenses>
32    <developers>
33        <developer>
34            <id>leo</id>
35            <name>Taro L. Saito</name>
36            <email>leo@xerial.org</email>
37            <organization>Xerial Project</organization>
38            <roles>
39                <role>Architect</role>
40                <role>Project Manager</role>
41                <role>Chief Developer</role>
42            </roles>
43            <timezone>+9</timezone>
44        </developer>
45    </developers>
46    <issueManagement>
47        <system>GitHub</system>
48        <url>http://github.com/xerial/snappy-java/issues/list</url>
49    </issueManagement>
50    <inceptionYear>2011</inceptionYear>
51    <scm>
52        <connection>scm:git@github.com:xerial/snappy-java.git</connection>
53        <developerConnection>scm:git:git@github.com:xerial/snappy-java.git</developerConnection>
54        <url>git@github.com:xerial/snappy-java.git</url>
55    </scm>
56}
57
58scalaVersion in ThisBuild := "2.12.8"
59
60javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.7", "-target", "1.7")
61
62javacOptions in doc := {
63  val opts = Seq("-source", "1.6")
64  if (scala.util.Properties.isJavaAtLeast("1.8"))
65    opts ++ Seq("-Xdoclint:none")
66  else
67    opts
68}
69
70// Configuration for SnappyHadoopCompatibleOutputStream testing
71fork in Test := true
72import java.io.File
73val libTemp = {
74  val path = s"${System.getProperty("java.io.tmpdir")}/snappy_test_${System.currentTimeMillis()}"
75  // certain older Linux systems (debian/trusty in Travis CI) requires the libsnappy.so, loaded by
76  // libhadoop.so, be copied to the temp path before the child JVM is forked.
77  // because of that, cannot define as an additional task in Test scope
78  IO.copyFile(file("src/test/resources/lib/Linux/libsnappy.so"), file(s"$path/libsnappy.so"))
79  IO.copyFile(file("src/test/resources/lib/Linux/libsnappy.so"), file(s"$path/libsnappy.so.1"))
80  path
81}
82
83val macOSXLibPath = s"$libTemp:${System.getenv("DYLD_LIBRARY_PATH")}"
84val linuxLibPath  = s"$libTemp:${System.getenv("LD_LIBRARY_PATH")}"
85
86// have to add to system dynamic library path since hadoop native library indirectly load libsnappy.1
87// can't use javaOptions in Test because it causes the expression to eval twice yielding different temp path values
88envVars in Test := Map("XERIAL_SNAPPY_LIB" -> libTemp, "DYLD_LIBRARY_PATH" -> macOSXLibPath, "LD_LIBRARY_PATH" -> linuxLibPath)
89
90testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")
91concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
92autoScalaLibrary := false
93crossPaths := false
94logBuffered in Test := false
95
96findbugsReportType := Some(FindbugsReport.FancyHtml)
97findbugsReportPath := Some(crossTarget.value / "findbugs" / "report.html")
98
99libraryDependencies ++= Seq(
100  "junit"               % "junit"              % "4.8.2" % "test",
101  "org.codehaus.plexus" % "plexus-classworlds" % "2.4"   % "test",
102  "org.xerial.java"     % "xerial-core"        % "2.1"   % "test",
103  "org.wvlet.airframe"  %% "airframe-log"      % "0.25"  % "test",
104  "org.scalatest"       %% "scalatest"         % "3.0.4" % "test",
105  "org.osgi"            % "org.osgi.core"      % "4.3.0" % "provided",
106  "com.novocode"        % "junit-interface"    % "0.11"  % "test",
107  "org.apache.hadoop"   % "hadoop-common"      % "2.7.3" % "test" exclude ("org.xerial.snappy", "snappy-java")
108)
109
110enablePlugins(SbtOsgi)
111
112osgiSettings
113
114OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer", "org.xerial.snappy.pool")
115OsgiKeys.bundleSymbolicName := "org.xerial.snappy.snappy-java"
116OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
117OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
118OsgiKeys.requireCapability := """osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))""""
119
120OsgiKeys.additionalHeaders := Map(
121  "Bundle-NativeCode" -> Seq(
122    "org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x86-64",
123    "org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x64",
124    "org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=amd64",
125    "org/xerial/snappy/native/Windows/x86/snappyjava.dll;osname=win32;processor=x86",
126    "org/xerial/snappy/native/Mac/x86/libsnappyjava.jnilib;osname=macosx;processor=x86",
127    "org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib;osname=macosx;processor=x86-64",
128    "org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x86-64",
129    "org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x64",
130    "org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=amd64",
131    "org/xerial/snappy/native/Linux/x86/libsnappyjava.so;osname=linux;processor=x86",
132    "org/xerial/snappy/native/Linux/aarch64/libsnappyjava.so;osname=linux;processor=aarch64",
133    "org/xerial/snappy/native/Linux/arm/libsnappyjava.so;osname=linux;processor=arm",
134    "org/xerial/snappy/native/Linux/armv7/libsnappyjava.so;osname=linux;processor=arm_le",
135    "org/xerial/snappy/native/Linux/ppc64/libsnappyjava.so;osname=linux;processor=ppc64le",
136    "org/xerial/snappy/native/Linux/s390x/libsnappyjava.so;osname=linux;processor=s390x",
137    "org/xerial/snappy/native/AIX/ppc/libsnappyjava.a;osname=aix;processor=ppc",
138    "org/xerial/snappy/native/AIX/ppc64/libsnappyjava.a;osname=aix;processor=ppc64",
139    "org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86",
140    "org/xerial/snappy/native/SunOS/x86_64/libsnappyjava.so;osname=sunos;processor=x86-64",
141    "org/xerial/snappy/native/SunOS/sparc/libsnappyjava.so;osname=sunos;processor=sparc"
142  ).mkString(","),
143  "Bundle-DocURL"           -> "http://www.xerial.org/",
144  "Bundle-License"          -> "http://www.apache.org/licenses/LICENSE-2.0.txt",
145  "Bundle-ActivationPolicy" -> "lazy",
146  "Bundle-Name"             -> "snappy-java: A fast compression/decompression library"
147)
148
149import ReleaseTransformations._
150import sbtrelease._
151
152releaseTagName := { (version in ThisBuild).value }
153releasePublishArtifactsAction := PgpKeys.publishSigned.value
154
155releaseProcess := Seq[ReleaseStep](
156  checkSnapshotDependencies,
157  inquireVersions,
158  runClean,
159  runTest,
160  setReleaseVersion,
161  commitReleaseVersion,
162  tagRelease,
163  publishArtifacts,
164  setNextVersion,
165  commitNextVersion,
166  releaseStepCommand("sonatypeReleaseAll"),
167  pushChanges
168)
169