diff --git a/.gitignore b/.gitignore index 8a15362..fc37fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,6 @@ project/plugins/project/ # Scala-IDE specific .scala_dependencies +atlassian-ide-plugin.xml + diff --git a/.travis.yml b/.travis.yml index 6afeb5e..c14f106 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,15 @@ -language: java - -install: mvn install -DskipTests=true -Dgpg.skip=true - +language: scala +scala: + - 2.11.1 jdk: - - oraclejdk7 + - openjdk6 - openjdk7 + - oraclejdk7 + +branches: + only: + - master + - develop + +script: ./sbt test + diff --git a/Makefile b/Makefile index 17bed9a..d626790 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ include Makefile.common MVN:=mvn +SBT:=./sbt all: snappy @@ -50,19 +51,12 @@ $(SNAPPY_GIT_UNPACKED): jni-header: $(SRC)/org/xerial/snappy/SnappyNative.h -$(TARGET)/classes/org/xerial/snappy/SnappyNative.class : $(SRC)/org/xerial/snappy/SnappyNative.java - @mkdir -p $(TARGET)/classes - $(JAVAC) -source 1.6 -target 1.6 -d $(TARGET)/classes -sourcepath $(SRC) $< +$(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class : $(SRC)/org/xerial/snappy/SnappyNative.java + @mkdir -p $(TARGET)/jni-classes + $(JAVAC) -source 1.6 -target 1.6 -d $(TARGET)/jni-classes -sourcepath $(SRC) $< -$(SRC)/org/xerial/snappy/SnappyNative.h: $(TARGET)/classes/org/xerial/snappy/SnappyNative.class - $(JAVAH) -classpath $(TARGET)/classes -o $@ org.xerial.snappy.SnappyNative - -bytecode: src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode - -src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode: src/main/resources/org/xerial/snappy/SnappyNativeLoader.java - @mkdir -p $(TARGET)/temp - $(JAVAC) -source 1.5 -target 1.5 -d $(TARGET)/temp $< - cp $(TARGET)/temp/org/xerial/snappy/SnappyNativeLoader.class $@ +$(SRC)/org/xerial/snappy/SnappyNative.h: $(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class + $(JAVAH) -force -classpath $(TARGET)/classes -o $@ org.xerial.snappy.SnappyNative ifndef USE_GIT $(SNAPPY_SRC): $(SNAPPY_UNPACKED) @@ -93,7 +87,7 @@ NATIVE_DIR:=src/main/resources/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH) NATIVE_TARGET_DIR:=$(TARGET)/classes/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH) NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME) -snappy-jar-version:=snappy-java-$(shell $(JAVA) -jar lib/silk-weaver.jar find 'project(artifactId, version)' pom.xml | grep snappy-java | awk '{ print $$2; }') +snappy-jar-version:=snappy-java-$(shell perl -npe "s/version in ThisBuild\s+:=\s+\"(.*)\"/\1/" version.sbt | sed -e "/^$$/d") ifndef USE_GIT native: $(SNAPPY_UNPACKED) $(NATIVE_DLL) @@ -109,11 +103,13 @@ $(NATIVE_DLL): $(SNAPPY_OUT)/$(LIBNAME) cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME) -$(TARGET)/$(snappy-jar-version).jar: native $(NATIVE_DLL) - $(MVN) package -Dmaven.test.skip=true +package: $(TARGET)/$(snappy-jar-version).jar + +$(TARGET)/$(snappy-jar-version).jar: + $(SBT) package test: $(NATIVE_DLL) - $(MVN) test + $(SBT) test win32: $(MAKE) native CROSS_PREFIX=i686-w64-mingw32- OS_NAME=Windows OS_ARCH=x86 @@ -146,8 +142,10 @@ clean-native-win32: $(MAKE) clean-native OS_NAME=Windows OS_ARCH=x86 javadoc: - $(MVN) javadoc:javadoc -DreportOutputDirectory=wiki/apidocs + $(SBT) doc +install-m2: + $(SBT) publishM2 googlecode-upload: googlecode-lib-upload googlecode-src-upload diff --git a/Makefile.common b/Makefile.common index 2a86aae..20ad780 100755 --- a/Makefile.common +++ b/Makefile.common @@ -153,7 +153,7 @@ Mac-x86_SNAPPY_FLAGS := Mac-x86_64_CXX := g++ -arch $(OS_ARCH) Mac-x86_64_STRIP := strip -x Mac-x86_64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5 -fvisibility=hidden -Mac-x86_64_LINKFLAGS := -dynamiclib -static-libgcc +Mac-x86_64_LINKFLAGS := -dynamiclib Mac-x86_64_LIBNAME := libsnappyjava.jnilib Mac-x86_64_SNAPPY_FLAGS := diff --git a/Milestone.md b/Milestone.md index acdc319..13e46e1 100644 --- a/Milestone.md +++ b/Milestone.md @@ -4,8 +4,18 @@ Since vesion 1.1.0.x, Java 6 (1.6) or higher is required. -## snappy-java-1.1.1 (not yet) - * Upgrade native snappy version +## snappy-java-1.1.1 (4 July 2014) + * Added Snappy framing format support: SnappyFramedInput/OutputStream + * Added native libraries for PowerPC, IBM-AIX 6.4, SunOS. + +# snappy-java-1.1.1-M4 (4 July 2014) + * Add linux-x86_64 native library, embedding libstdc++ + * IBM AIX 6.1 support + * A fix for loading in OSGi in Mac OS X (#76) + +# snappy-java-1.1.1-M3 (26 June 2014) + * Add PowerPC support (ppc64, ppc64le) + * Building with sbt # snappy-java-1.0.5.2 (25 June 2014) * Maintanance release diff --git a/README.md b/README.md index 12655a8..03d1487 100755 --- a/README.md +++ b/README.md @@ -81,6 +81,12 @@ Add the following dependency to your pom.xml: compile +### Using with sbt + +``` +libraryDependencies += "org.xerial.snappy" % "snappy-java" % "(version)" +``` + ## Public discussion group Post bug reports or feature request to the Issue Tracker: @@ -89,7 +95,7 @@ Public discussion forum is here: ~test # run tests upon source code change + > ~test-only * # run tests that matches a given name pattern + > publishM2 # publish jar to $HOME/.m2/repository + > package # create jar file + +For the details of sbt usage, see my blog post: [Building Java Projects with sbt](http://xerial.org/blog/2014/03/24/sbt/) + ## Miscellaneous Notes ### Using snappy-java with Tomcat 6 (or higher) Web Server diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..7a95834 --- /dev/null +++ b/build.sbt @@ -0,0 +1,102 @@ +import SonatypeKeys._ + +sonatypeSettings + +name := "snappy-java" + +organization := "org.xerial.snappy" + +organizationName := "xerial.org" + +description := "snappy-java: A fast compression/decompression library" + +profileName := "org.xerial" + +pomExtra := { + https://github.comm/xerial/snappy-java + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + leo + Taro L. Saito + leo@xerial.org + Xerial Project + + Architect + Project Manager + Chief Developer + + +9 + + + + GitHub + http://github.com/xerial/snappy-java/issues/list + + 2011 + + scm:git@github.com:xerial/snappy-java.git + scm:git:git@github.com:xerial/snappy-java.git + git@github.com:xerial/snappy-java.git + +} + +javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6") + +testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v") + +//concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1)) + +autoScalaLibrary := false + +crossPaths := false + +logBuffered in Test := false + +incOptions := incOptions.value.withNameHashing(true) + +libraryDependencies ++= Seq( + "junit" % "junit" % "4.8.2" % "test", + "org.codehaus.plexus" % "plexus-classworlds" % "2.4" % "test", + "org.xerial" % "xerial-core" % "1.0.21" % "test", + "org.osgi" % "org.osgi.core" % "4.3.0" % "provided", + "com.novocode" % "junit-interface" % "0.10" % "test" +) + +osgiSettings + + +OsgiKeys.exportPackage := Seq("org.xerial.snappy") + +OsgiKeys.bundleSymbolicName := "org.xerial.snappy.snappy-java" + +OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator") + +OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""") + +OsgiKeys.additionalHeaders := Map( + "Bundle-NativeCode" -> Seq( +"org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x86-64", +"org/xerial/snappy/native/Windows/x86/snappyjava.dll;osname=win32;processor=x86", +"org/xerial/snappy/native/Mac/x86/libsnappyjava.jnilib;osname=macosx;processor=x86", +"org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib;osname=macosx;processor=x86-64", +"org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x86-64", +"org/xerial/snappy/native/Linux/x86/libsnappyjava.so;osname=linux;processor=x86", +"org/xerial/snappy/native/Linux/arm/libsnappyjava.so;osname=linux;processor=arm", +"org/xerial/snappy/native/Linux/ppc64/libsnappyjava.so;osname=linux;processor=ppc64", +"org/xerial/snappy/native/Linux/ppc64le/libsnappyjava.so;osname=linux;processor=ppc64le", +"org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86", +"org/xerial/snappy/native/SunOS/x86_64/libsnappyjava.so;osname=sunos;processor=x86-64", +"org/xerial/snappy/native/SunOS/sparc/libsnappyjava.so;osname=sunos;processor=sparc" +).mkString(","), + "Bundle-DocURL" -> "http://www.xerial.org/", + "Bundle-License" -> "http://www.apache.org/licenses/LICENSE-2.0.txt", + "Bundle-ActivationPolicy" -> "lazy", + "Bundle-Name" -> "snappy-java: A fast compression/decompression library" +) diff --git a/lib/silk-weaver.jar b/lib/silk-weaver.jar deleted file mode 100755 index 6af58b4..0000000 Binary files a/lib/silk-weaver.jar and /dev/null differ diff --git a/pom.xml b/pom.xml deleted file mode 100755 index 7da4b98..0000000 --- a/pom.xml +++ /dev/null @@ -1,318 +0,0 @@ - - - 4.0.0 - org.xerial.snappy - snappy-java - 1.1.1-M2 - Snappy for Java - snappy-java: A fast compression/decompression library - bundle - - - org.sonatype.oss - oss-parent - 7 - - - - UTF-8 - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - leo - Taro L. Saito - leo@xerial.org - Xerial Project - - Architect - Project Manager - Chief Developer - - +9 - - - - - xerial.org - http://www.xerial.org/ - - - - - - src/main/java - - org/xerial/snappy/VERSION - - - - src/main/resources - - org/xerial/snappy/*.bytecode - org/xerial/snappy/native/** - - - - ${basedir} - META-INF/maven/${project.groupId}/${project.artifactId} - - LICENSE* - - - - - - src/test/java - - **/*.java - - - - src/test/resources - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - UTF-8 - - - - - org.apache.maven.plugins - maven-deploy-plugin - 2.7 - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - 1.6 - 1.6 - - - - - maven-release-plugin - 2.1 - - - deploy - false - true - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.4 - - true - - - - sign-artifacts - verify - - sign - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8 - - UTF-8 - en_US - public - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - true - - - - attach-sources - verify - - jar-no-fork - - - - - - - org.apache.felix - maven-bundle-plugin - 2.3.7 - true - - ${project.build.directory}/META-INF - - ${project.groupId}.${project.artifactId} - ${project.name} - ${project.version} - org.xerial.snappy.SnappyBundleActivator - org.xerial.snappy - org.osgi.framework;version="[1.5,2)" - lazy - - org/xerial/snappy/native/Windows/x86_64/snappyjava.dll;osname=win32;processor=x86-64, - org/xerial/snappy/native/Windows/x86/snappyjava.dll;osname=win32;processor=x86, - org/xerial/snappy/native/Mac/x86/libsnappyjava.jnilib;osname=macosx;processor=x86, - org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib;osname=macosx;processor=x86-64, - org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so;osname=linux;processor=x86-64, - org/xerial/snappy/native/Linux/x86/libsnappyjava.so;osname=linux;processor=x86, - org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86, - org/xerial/snappy/native/SunOS/sparc/libsnappyjava.so;osname=sunos;processor=sparc, - org/xerial/snappy/native/SunOS/x86_64/libsnappyjava.so;osname=sunos;processor=x86-64, - org/xerial/snappy/native/Linux/arm/libsnappyjava.so;osname=linux;processor=arm - - - - - - - bundle-manifest - process-classes - - manifest - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - true - ${project.build.directory}/META-INF/MANIFEST.MF - - - - - - org.apache.maven.plugins - maven-clean-plugin - 2.4.1 - - false - - - META-INF - - MANIFEST.MF - - - - - - - - maven-assembly-plugin - 2.2.1 - - - src/assembly/project.xml - - false - false - - - - make-assembly - package - - single - - - - - - - - - - org.apache.maven.wagon - wagon-ssh-external - 1.0-beta-7 - - - - - - - http://github.com/xerial/snappy-java/ - - GitHub - http://github.com/xerial/snappy-java/issues/list - - 2011 - - scm:git@github.com:xerial/snappy-java.git - scm:git:git@github.com:xerial/snappy-java.git - git@github.com:xerial/snappy-java.git - - - - - junit - junit - 4.8.2 - jar - test - - - - org.codehaus.plexus - plexus-classworlds - 2.4 - jar - test - - - org.osgi - core - 4.3.0 - jar - provided - - - org.xerial - xerial-core - 1.0.21 - jar - test - - - - - diff --git a/project/build.properties b/project/build.properties new file mode 100755 index 0000000..6137a3a --- /dev/null +++ b/project/build.properties @@ -0,0 +1,2 @@ +sbt.version=0.13.5 + diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100755 index 0000000..609b225 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,12 @@ + +addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.7.1") + +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1") + +addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3") + +addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.3.0") + +addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.5") + +addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0") diff --git a/sbt b/sbt new file mode 100755 index 0000000..e0343df --- /dev/null +++ b/sbt @@ -0,0 +1,481 @@ +#!/usr/bin/env bash +# +# A more capable sbt runner, coincidentally also called sbt. +# Author: Paul Phillips + +# todo - make this dynamic +declare -r sbt_release_version="0.13.1" +declare -r sbt_unreleased_version="0.13.2-SNAPSHOT" # -sbt-dev doesn't work at present +declare -r buildProps="project/build.properties" + +declare sbt_jar sbt_dir sbt_create sbt_launch_dir +declare scala_version java_home sbt_explicit_version +declare verbose debug quiet noshare batch trace_level log_level +declare sbt_saved_stty + +echoerr () { [[ -z "$quiet" ]] && echo "$@" >&2; } +vlog () { [[ -n "$verbose$debug" ]] && echoerr "$@"; } +dlog () { [[ -n "$debug" ]] && echoerr "$@"; } + +# we'd like these set before we get around to properly processing arguments +for arg in "$@"; do + case "$arg" in + -q|-quiet) quiet=true ;; + -d|-debug) debug=true ;; + -v|-verbose) verbose=true ;; + *) ;; + esac +done + +# spaces are possible, e.g. sbt.version = 0.13.0 +build_props_sbt () { + [[ -r "$buildProps" ]] && \ + grep '^sbt\.version' "$buildProps" | tr '=' ' ' | awk '{ print $2; }' +} + +update_build_props_sbt () { + local ver="$1" + local old="$(build_props_sbt)" + + [[ -r "$buildProps" ]] && [[ "$ver" != "$old" ]] && { + perl -pi -e "s/^sbt\.version\b.*\$/sbt.version=${ver}/" "$buildProps" + grep -q '^sbt.version[ =]' "$buildProps" || printf "\nsbt.version=%s\n" "$ver" >> "$buildProps" + + echoerr "!!!" + echoerr "!!! Updated file $buildProps setting sbt.version to: $ver" + echoerr "!!! Previous value was: $old" + echoerr "!!!" + } +} + +sbt_version () { + if [[ -n "$sbt_explicit_version" ]]; then + echo "$sbt_explicit_version" + else + local v="$(build_props_sbt)" + if [[ -n "$v" ]]; then + echo "$v" + else + echo "$sbt_release_version" + fi + fi +} + +# restore stty settings (echo in particular) +onSbtRunnerExit() { + [[ -n "$sbt_saved_stty" ]] || return + dlog "" + dlog "restoring stty: $sbt_saved_stty" + stty "$sbt_saved_stty" + unset sbt_saved_stty +} + +# save stty and trap exit, to ensure echo is reenabled if we are interrupted. +trap onSbtRunnerExit EXIT +sbt_saved_stty="$(stty -g 2>/dev/null)" +dlog "Saved stty: $sbt_saved_stty" + +# this seems to cover the bases on OSX, and someone will +# have to tell me about the others. +get_script_path () { + local path="$1" + [[ -L "$path" ]] || { echo "$path" ; return; } + + local target="$(readlink "$path")" + if [[ "${target:0:1}" == "/" ]]; then + echo "$target" + else + echo "${path%/*}/$target" + fi +} + +die() { + echo "Aborting: $@" + exit 1 +} + +make_url () { + version="$1" + + case "$version" in + 0.7.*) echo "http://simple-build-tool.googlecode.com/files/sbt-launch-0.7.7.jar" ;; + 0.10.* ) echo "$sbt_launch_repo/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;; + 0.11.[12]) echo "$sbt_launch_repo/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;; + *) echo "$sbt_launch_repo/org.scala-sbt/sbt-launch/$version/sbt-launch.jar" ;; + esac +} + +init_default_option_file () { + local overriding_var="${!1}" + local default_file="$2" + if [[ ! -r "$default_file" && "$overriding_var" =~ ^@(.*)$ ]]; then + local envvar_file="${BASH_REMATCH[1]}" + if [[ -r "$envvar_file" ]]; then + default_file="$envvar_file" + fi + fi + echo "$default_file" +} + +declare -r cms_opts="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC" +declare -r jit_opts="-XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation" +declare -r default_jvm_opts="-Dfile.encoding=UTF8 -XX:MaxPermSize=384m -Xms512m -Xmx1536m -Xss2m $jit_opts $cms_opts" +declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" +declare -r latest_28="2.8.2" +declare -r latest_29="2.9.3" +declare -r latest_210="2.10.3" +declare -r latest_211="2.11.0-M5" + +declare -r script_path="$(get_script_path "$BASH_SOURCE")" +declare -r script_name="${script_path##*/}" + +# some non-read-onlies set with defaults +declare java_cmd="java" +declare sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)" +declare jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)" +declare sbt_launch_repo="http://typesafe.artifactoryonline.com/typesafe/ivy-releases" + +# pull -J and -D options to give to java. +declare -a residual_args +declare -a java_args +declare -a scalac_args +declare -a sbt_commands + +# args to jvm/sbt via files or environment variables +declare -a extra_jvm_opts extra_sbt_opts + +# if set, use JAVA_HOME over java found in path +[[ -e "$JAVA_HOME/bin/java" ]] && java_cmd="$JAVA_HOME/bin/java" + +# directory to store sbt launchers +declare sbt_launch_dir="$HOME/.sbt/launchers" +[[ -d "$sbt_launch_dir" ]] || mkdir -p "$sbt_launch_dir" +[[ -w "$sbt_launch_dir" ]] || sbt_launch_dir="$(mktemp -d -t sbt_extras_launchers.XXXXXX)" + +build_props_scala () { + if [[ -r "$buildProps" ]]; then + versionLine="$(grep '^build.scala.versions' "$buildProps")" + versionString="${versionLine##build.scala.versions=}" + echo "${versionString%% .*}" + fi +} + +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ "$verbose" || "$debug" ]] && echo "# Executing command line:" && { + for arg; do + if [[ -n "$arg" ]]; then + if printf "%s\n" "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + fi + done + echo "" + } + + if [[ -n "$batch" ]]; then + exec /dev/null; then + curl --fail --silent "$url" --output "$jar" + elif which wget >/dev/null; then + wget --quiet -O "$jar" "$url" + fi + } && [[ -r "$jar" ]] +} + +acquire_sbt_jar () { + for_sbt_version="$(sbt_version)" + sbt_url="$(jar_url "$for_sbt_version")" + sbt_jar="$(jar_file "$for_sbt_version")" + + [[ -r "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" +} + +usage () { + cat < display stack traces with a max of frames (default: -1, traces suppressed) + -no-colors disable ANSI color codes + -sbt-create start sbt even if current directory contains no sbt project + -sbt-dir path to global settings/plugins directory (default: ~/.sbt/) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11+) + -ivy path to local Ivy repository (default: ~/.ivy2) + -no-share use all local caches; no sharing + -offline put sbt in offline mode + -jvm-debug Turn on JVM debugging, open at the given port. + -batch Disable interactive mode + -prompt Set the sbt prompt; in expr, 's' is the State and 'e' is Extracted + + # sbt version (default: from $buildProps if present, else latest release) + !!! The only way to accomplish this pre-0.12.0 if there is a build.properties file which + !!! contains an sbt.version property is to update the file on disk. That's what this does. + -sbt-version use the specified version of sbt (default: $sbt_release_version) + -sbt-jar use the specified jar as the sbt launcher + -sbt-launch-dir directory to hold sbt launchers (default: $sbt_launch_dir) + -sbt-launch-repo repo url for downloading sbt launcher jar (default: $sbt_launch_repo) + + # scala version (default: as chosen by sbt) + -28 use $latest_28 + -29 use $latest_29 + -210 use $latest_210 + -211 use $latest_211 + -scala-home use the scala build at the specified directory + -scala-version use the specified version of scala + -binary-version use the specified scala version when searching for dependencies + + # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) + -java-home alternate JAVA_HOME + + # passing options to the jvm - note it does NOT use JAVA_OPTS due to pollution + # The default set is used if JVM_OPTS is unset and no -jvm-opts file is found + $default_jvm_opts + JVM_OPTS environment variable holding either the jvm args directly, or + the reference to a file containing jvm args if given path is prepended by '@' (e.g. '@/etc/jvmopts') + Note: "@"-file is overridden by local '.jvmopts' or '-jvm-opts' argument. + -jvm-opts file containing jvm args (if not given, .jvmopts in project root is used if present) + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm (-J is stripped) + + # passing options to sbt, OR to this runner + SBT_OPTS environment variable holding either the sbt args directly, or + the reference to a file containing sbt args if given path is prepended by '@' (e.g. '@/etc/sbtopts') + Note: "@"-file is overridden by local '.sbtopts' or '-sbt-opts' argument. + -sbt-opts file containing sbt args (if not given, .sbtopts in project root is used if present) + -S-X add -X to sbt's scalacOptions (-S is stripped) +EOM +} + +addJava () { + dlog "[addJava] arg = '$1'" + java_args=( "${java_args[@]}" "$1" ) +} +addSbt () { + dlog "[addSbt] arg = '$1'" + sbt_commands=( "${sbt_commands[@]}" "$1" ) +} +addScalac () { + dlog "[addScalac] arg = '$1'" + scalac_args=( "${scalac_args[@]}" "$1" ) +} +addResidual () { + dlog "[residual] arg = '$1'" + residual_args=( "${residual_args[@]}" "$1" ) +} +addResolver () { + addSbt "set resolvers += $1" +} +addDebugger () { + addJava "-Xdebug" + addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" +} +setScalaVersion () { + [[ "$1" == *"-SNAPSHOT" ]] && addResolver 'Resolver.sonatypeRepo("snapshots")' + addSbt "++ $1" +} + +process_args () +{ + require_arg () { + local type="$1" + local opt="$2" + local arg="$3" + + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + die "$opt requires <$type> argument" + fi + } + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=true && log_level=Info && shift ;; + -d|-debug) debug=true && log_level=Debug && shift ;; + -q|-quiet) quiet=true && log_level=Error && shift ;; + + -trace) require_arg integer "$1" "$2" && trace_level="$2" && shift 2 ;; + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; + -no-share) noshare=true && shift ;; + -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && sbt_dir="$2" && shift 2 ;; + -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; + -offline) addSbt "set offline := true" && shift ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger "$2" && shift 2 ;; + -batch) batch=true && shift ;; + -prompt) require_arg "expr" "$1" "$2" && addSbt "set shellPrompt in ThisBuild := (s => { val e = Project.extract(s) ; $2 })" && shift 2 ;; + + -sbt-create) sbt_create=true && shift ;; + -sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;; + -sbt-version) require_arg version "$1" "$2" && sbt_explicit_version="$2" && shift 2 ;; + -sbt-dev) sbt_explicit_version="$sbt_unreleased_version" && shift ;; +-sbt-launch-dir) require_arg path "$1" "$2" && sbt_launch_dir="$2" && shift 2 ;; +-sbt-launch-repo) require_arg path "$1" "$2" && sbt_launch_repo="$2" && shift 2 ;; + -scala-version) require_arg version "$1" "$2" && setScalaVersion "$2" && shift 2 ;; +-binary-version) require_arg version "$1" "$2" && addSbt "set scalaBinaryVersion in ThisBuild := \"$2\"" && shift 2 ;; + -scala-home) require_arg path "$1" "$2" && addSbt "set every scalaHome := Some(file(\"$2\"))" && shift 2 ;; + -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;; + -sbt-opts) require_arg path "$1" "$2" && sbt_opts_file="$2" && shift 2 ;; + -jvm-opts) require_arg path "$1" "$2" && jvm_opts_file="$2" && shift 2 ;; + + -D*) addJava "$1" && shift ;; + -J*) addJava "${1:2}" && shift ;; + -S*) addScalac "${1:2}" && shift ;; + -28) setScalaVersion "$latest_28" && shift ;; + -29) setScalaVersion "$latest_29" && shift ;; + -210) setScalaVersion "$latest_210" && shift ;; + -211) setScalaVersion "$latest_211" && shift ;; + + *) addResidual "$1" && shift ;; + esac + done +} + +# process the direct command line arguments +process_args "$@" + +# skip #-styled comments and blank lines +readConfigFile() { + while read line; do + [[ $line =~ ^# ]] || [[ -z $line ]] || echo "$line" + done < "$1" +} + +# if there are file/environment sbt_opts, process again so we +# can supply args to this runner +if [[ -r "$sbt_opts_file" ]]; then + vlog "Using sbt options defined in file $sbt_opts_file" + while read opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file") +elif [[ -n "$SBT_OPTS" && ! ("$SBT_OPTS" =~ ^@.*) ]]; then + vlog "Using sbt options defined in variable \$SBT_OPTS" + extra_sbt_opts=( $SBT_OPTS ) +else + vlog "No extra sbt options have been defined" +fi + +[[ -n "$extra_sbt_opts" ]] && process_args "${extra_sbt_opts[@]}" + +# reset "$@" to the residual args +set -- "${residual_args[@]}" +argumentCount=$# + +# only exists in 0.12+ +setTraceLevel() { + case "$(sbt_version)" in + "0.7."* | "0.10."* | "0.11."* ) + echoerr "Cannot set trace level in sbt version $(sbt_version)" + ;; + *) + addSbt "set every traceLevel := $trace_level" + ;; + esac +} + +# set scalacOptions if we were given any -S opts +[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\"" + +# Update build.properties on disk to set explicit version - sbt gives us no choice +[[ -n "$sbt_explicit_version" ]] && update_build_props_sbt "$sbt_explicit_version" +vlog "Detected sbt version $(sbt_version)" + +[[ -n "$scala_version" ]] && echoerr "Overriding scala version to $scala_version" + +# no args - alert them there's stuff in here +(( argumentCount > 0 )) || { + vlog "Starting $script_name: invoke with -help for other options" + residual_args=( shell ) +} + +# verify this is an sbt dir or -create was given +[[ -r ./build.sbt || -d ./project || -n "$sbt_create" ]] || { + cat <input where the data starts. - * @param length - * The amount of data in input. + * @param buffer + * @throws IOException */ private void writeCompressed(ByteBuffer buffer) throws IOException { @@ -419,10 +415,6 @@ public final class SnappyFramedOutputStream extends OutputStream implements * The {@link OutputStream} to write to. * @param data * The data to write. - * @param offset - * The offset in data to start at. - * @param length - * The length of data to use. * @param compressed * Indicates if data is the compressed or raw content. * This is based on whether the compression ratio desired is diff --git a/src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode b/src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode deleted file mode 100755 index 64c0fe8..0000000 Binary files a/src/main/resources/org/xerial/snappy/SnappyNativeLoader.bytecode and /dev/null differ diff --git a/src/main/resources/org/xerial/snappy/SnappyNativeLoader.java b/src/main/resources/org/xerial/snappy/SnappyNativeLoader.java deleted file mode 100755 index 967912c..0000000 --- a/src/main/resources/org/xerial/snappy/SnappyNativeLoader.java +++ /dev/null @@ -1,59 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright 2011 Taro L. Saito - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *--------------------------------------------------------------------------*/ -//-------------------------------------- -// XerialJ -// -// SnappyNativeLoader.java -// Since: 2011/07/04 12:10:28 -// -// $URL$ -// $Author$ -//-------------------------------------- -package org.xerial.snappy; - -import java.util.HashMap; - -public class SnappyNativeLoader -{ - private static HashMap loadedLibFiles = new HashMap(); - private static HashMap loadedLib = new HashMap(); - - public static synchronized void load(String lib) { - if (loadedLibFiles.containsKey(lib) && loadedLibFiles.get(lib) == true) - return; - - try { - System.load(lib); - loadedLibFiles.put(lib, true); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - public static synchronized void loadLibrary(String libname) { - if (loadedLib.containsKey(libname) && loadedLib.get(libname) == true) - return; - - try { - System.loadLibrary(libname); - loadedLib.put(libname, true); - } - catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/resources/org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so b/src/main/resources/org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so index 04c75c6..3550021 100755 Binary files a/src/main/resources/org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so and b/src/main/resources/org/xerial/snappy/native/Linux/x86_64/libsnappyjava.so differ diff --git a/src/test/java/org/xerial/snappy/alice29.txt b/src/test/resources/org/xerial/snappy/alice29.txt similarity index 100% rename from src/test/java/org/xerial/snappy/alice29.txt rename to src/test/resources/org/xerial/snappy/alice29.txt diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/bib b/src/test/resources/org/xerial/snappy/testdata/calgary/bib similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/bib rename to src/test/resources/org/xerial/snappy/testdata/calgary/bib diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/book1 b/src/test/resources/org/xerial/snappy/testdata/calgary/book1 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/book1 rename to src/test/resources/org/xerial/snappy/testdata/calgary/book1 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/book2 b/src/test/resources/org/xerial/snappy/testdata/calgary/book2 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/book2 rename to src/test/resources/org/xerial/snappy/testdata/calgary/book2 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/geo b/src/test/resources/org/xerial/snappy/testdata/calgary/geo similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/geo rename to src/test/resources/org/xerial/snappy/testdata/calgary/geo diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/news b/src/test/resources/org/xerial/snappy/testdata/calgary/news similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/news rename to src/test/resources/org/xerial/snappy/testdata/calgary/news diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/obj1 b/src/test/resources/org/xerial/snappy/testdata/calgary/obj1 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/obj1 rename to src/test/resources/org/xerial/snappy/testdata/calgary/obj1 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/obj2 b/src/test/resources/org/xerial/snappy/testdata/calgary/obj2 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/obj2 rename to src/test/resources/org/xerial/snappy/testdata/calgary/obj2 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/paper1 b/src/test/resources/org/xerial/snappy/testdata/calgary/paper1 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/paper1 rename to src/test/resources/org/xerial/snappy/testdata/calgary/paper1 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/paper2 b/src/test/resources/org/xerial/snappy/testdata/calgary/paper2 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/paper2 rename to src/test/resources/org/xerial/snappy/testdata/calgary/paper2 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/paper3 b/src/test/resources/org/xerial/snappy/testdata/calgary/paper3 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/paper3 rename to src/test/resources/org/xerial/snappy/testdata/calgary/paper3 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/paper4 b/src/test/resources/org/xerial/snappy/testdata/calgary/paper4 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/paper4 rename to src/test/resources/org/xerial/snappy/testdata/calgary/paper4 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/paper5 b/src/test/resources/org/xerial/snappy/testdata/calgary/paper5 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/paper5 rename to src/test/resources/org/xerial/snappy/testdata/calgary/paper5 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/paper6 b/src/test/resources/org/xerial/snappy/testdata/calgary/paper6 similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/paper6 rename to src/test/resources/org/xerial/snappy/testdata/calgary/paper6 diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/pic b/src/test/resources/org/xerial/snappy/testdata/calgary/pic similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/pic rename to src/test/resources/org/xerial/snappy/testdata/calgary/pic diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/progc b/src/test/resources/org/xerial/snappy/testdata/calgary/progc similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/progc rename to src/test/resources/org/xerial/snappy/testdata/calgary/progc diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/progl b/src/test/resources/org/xerial/snappy/testdata/calgary/progl similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/progl rename to src/test/resources/org/xerial/snappy/testdata/calgary/progl diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/progp b/src/test/resources/org/xerial/snappy/testdata/calgary/progp similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/progp rename to src/test/resources/org/xerial/snappy/testdata/calgary/progp diff --git a/src/test/java/org/xerial/snappy/testdata/calgary/trans b/src/test/resources/org/xerial/snappy/testdata/calgary/trans similarity index 100% rename from src/test/java/org/xerial/snappy/testdata/calgary/trans rename to src/test/resources/org/xerial/snappy/testdata/calgary/trans diff --git a/version.sbt b/version.sbt new file mode 100644 index 0000000..61ca1d8 --- /dev/null +++ b/version.sbt @@ -0,0 +1 @@ +version in ThisBuild := "1.1.1"