Merge branch 'release/1.0.5-M3'

This commit is contained in:
Taro L. Saito 2012-09-28 12:05:01 +09:00
commit 1cc4d0a0c6
9 changed files with 520 additions and 506 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
# IntelliJ
.idea
.idea_modules
*.iml
# sbt specific
bin/.lib

View File

@ -77,13 +77,6 @@ test:
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
release:
mvn release:prepare
mvn release:perform
release-xerial:
mvn release:perform -Dtag=snappy-java-$(VERSION)
release-sourceforge:
mvn release:perform -Darguments="-P sourceforge" -Dtag=snappy-java-$(VERSION)
mvn deploy -DperformRelease=true

View File

@ -2,6 +2,9 @@
* `SnappyIndexer` for parallel compression/decompression
* CUI commands (snap/unsnap)
## snappy-java-1.0.5-M2 (27 September 2012)
* Upgrade release for snappy-1.0.5
## snappy-java-1.0.4.1 (5 September 2011)
* Fixes issue 33: Fixes a problem when reading incomplete input stream

View File

@ -23,10 +23,10 @@ The snappy-java is a Java port of the snappy
## Download
The current stable version is available from here:
* Release version: http://maven.xerial.org/repository/artifact/org/xerial/snappy/snappy-java
* [release plans](./snappy-java/Milestone.md)
* Release version: http://code.google.com/p/snappy-java/downloads/list
* [Release plans](https://github.com/xerial/snappy-java/blob/develop/Milestone.md)
* Snapshot version (the latest beta version): https://oss.sonatype.org/content/repositories/snapshots/org/xerial/snappy/snappy-java/
If you are a Maven user, see [#Using_with_Maven]
If you are a Maven user, see [pom.xml example](#using-with-maven).
## Usage
First, import `org.xerial.snapy.Snappy` in your Java code:

522
pom.xml
View File

@ -1,283 +1,289 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.0.5-M2</version>
<name>Snappy for Java</name>
<description>snappy-java: A fast compression/decompression library</description>
<packaging>bundle</packaging>
<modelVersion>4.0.0</modelVersion>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.0.5-M3</version>
<name>Snappy for Java</name>
<description>snappy-java: A fast compression/decompression library</description>
<packaging>bundle</packaging>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>leo</id>
<name>Taro L. Saito</name>
<email>leo@xerial.org</email>
<organization>Xerial Project</organization>
<roles>
<role>Architect</role>
<role>Project Manager</role>
<role>Chief Developer</role>
</roles>
<timezone>+9</timezone>
</developer>
</developers>
<developers>
<developer>
<id>leo</id>
<name>Taro L. Saito</name>
<email>leo@xerial.org</email>
<organization>Xerial Project</organization>
<roles>
<role>Architect</role>
<role>Project Manager</role>
<role>Chief Developer</role>
</roles>
<timezone>+9</timezone>
</developer>
</developers>
<organization>
<name>xerial.org</name>
<url>http://www.xerial.org/</url>
</organization>
<organization>
<name>xerial.org</name>
<url>http://www.xerial.org/</url>
</organization>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>org/xerial/snappy/VERSION</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>org/xerial/snappy/*.bytecode</include>
<include>org/xerial/snappy/native/**</include>
</includes>
</resource>
<resource>
<directory>${basedir}</directory>
<targetPath>META-INF/maven/${project.groupId}/${project.artifactId}</targetPath>
<includes>
<include>LICENSE*</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>org/xerial/snappy/VERSION</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>org/xerial/snappy/*.bytecode</include>
<include>org/xerial/snappy/native/**</include>
</includes>
</resource>
<resource>
<directory>${basedir}</directory>
<targetPath>META-INF/maven/${project.groupId}/${project.artifactId}</targetPath>
<includes>
<include>LICENSE*</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- do not run site-deploy goal, included in the default settings -->
<goals>deploy</goals>
<pushChanges>false</pushChanges>
<localCheckout>true</localCheckout>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<configuration>
<useAgent>true</useAgent>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- do not run site-deploy goal, included in the default settings -->
<goals>deploy</goals>
<pushChanges>false</pushChanges>
<localCheckout>true</localCheckout>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<charset>UTF-8</charset>
<locale>en_US</locale>
<show>public</show>
<stylesheetfile>stylesheet.css</stylesheetfile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<configuration>
<useAgent>true</useAgent>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<charset>UTF-8</charset>
<locale>en_US</locale>
<show>public</show>
<stylesheetfile>stylesheet.css</stylesheetfile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${pproject.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>org.xerial.snappy.SnappyBundleActivator</Bundle-Activator>
<Export-Package>org.xerial.snappy</Export-Package>
<Import-Package>org.osgi.framework;version="[1.5,2)"</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptors>
<descriptor>src/assembly/project.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${pproject.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>org.xerial.snappy.SnappyBundleActivator</Bundle-Activator>
<Export-Package>org.xerial.snappy</Export-Package>
<Import-Package>org.osgi.framework;version="[1.5,2)"</Import-Package>
</instructions>
</configuration>
</plugin>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptors>
<descriptor>src/assembly/project.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
</build>
<url>http://github.com/xerial/snappy-java/</url>
<issueManagement>
<system>GitHub</system>
<url>http://github.com/xerial/snappy-java/issues/list</url>
</issueManagement>
<inceptionYear>2011</inceptionYear>
<scm>
<connection>scm:git@github.com:xerial/snappy-java.git</connection>
<developerConnection>scm:git:git@github.com:xerial/snappy-java.git</developerConnection>
<url>git@github.com:xerial/snappy-java.git</url>
</scm>
<url>http://github.com/xerial/snappy-java/</url>
<issueManagement>
<system>GitHub</system>
<url>http://github.com/xerial/snappy-java/issues/list</url>
</issueManagement>
<inceptionYear>2011</inceptionYear>
<scm>
<connection>scm:git@github.com:xerial/snappy-java.git</connection>
<developerConnection>scm:git:git@github.com:xerial/snappy-java.git</developerConnection>
<url>git@github.com:xerial/snappy-java.git</url>
</scm>
<profiles>
<!-- for local updates -->
<profile>
<id>xerial.local</id>
<distributionManagement>
<repository>
<id>xerial.local</id>
<name>Xerial Maven Repository</name>
<url>file:///home/web/maven.xerial.org/repository/artifact</url>
</repository>
<snapshotRepository>
<id>xerial.local</id>
<name>Xerial Maven Snapshot Repository</name>
<url>file:///home/web/maven.xerial.org/repository/snapshot</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
<site>
<id>xerial.local</id>
<url>file:///home/web/maven.xerial.org/repository/site</url>
</site>
</distributionManagement>
</profile>
</profiles>
<profiles>
<!-- for local updates -->
<profile>
<id>xerial.local</id>
<distributionManagement>
<repository>
<id>xerial.local</id>
<name>Xerial Maven Repository</name>
<url>file:///home/web/maven.xerial.org/repository/artifact</url>
</repository>
<snapshotRepository>
<id>xerial.local</id>
<name>Xerial Maven Snapshot Repository</name>
<url>file:///home/web/maven.xerial.org/repository/snapshot</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
<site>
<id>xerial.local</id>
<url>file:///home/web/maven.xerial.org/repository/site</url>
</site>
</distributionManagement>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId>
<version>2.4</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>core</artifactId>
<version>4.3.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>xerial-core</artifactId>
<version>1.0.21</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId>
<version>2.4</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>core</artifactId>
<version>4.3.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>xerial-core</artifactId>
<version>1.0.21</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -78,9 +78,9 @@ public class OSInfo
// ignored: fall back to "arm" arch (soft-float ABI)
}
}
else if(getOSName().equals("Mac") && osArch.equals("universal")) {
return "x86_64"; // Fix for openjdk7
}
else if(getOSName().equals("Mac") && (osArch.equals("universal") || osArch.equals("amd64"))) {
return "x86_64"; // Fix for openjdk7
}
return translateArchNameToFolderName(osArch);
}

View File

@ -24,13 +24,7 @@
//--------------------------------------
package org.xerial.snappy;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
@ -411,13 +405,10 @@ public class SnappyLoader
static File findNativeLibrary() {
boolean useSystemLib = Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_USE_SYSTEMLIB, "false"));
if (useSystemLib)
return null;
boolean disabledBundledLibs = Boolean
.parseBoolean(System.getProperty(KEY_SNAPPY_DISABLE_BUNDLED_LIBS, "false"));
if (disabledBundledLibs)
return null;
if (useSystemLib || disabledBundledLibs)
return null; // Use a pre-installed libsnappyjava
// Try to load the library in org.xerial.snappy.lib.path */
String snappyNativeLibraryPath = System.getProperty(KEY_SNAPPY_LIB_PATH);
@ -433,23 +424,43 @@ public class SnappyLoader
return nativeLib;
}
{
// Load an OS-dependent native library inside a jar file
snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
if (SnappyLoader.class.getResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName) != null) {
// Temporary library folder. Use the value of org.xerial.snappy.tempdir or java.io.tmpdir
String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR,
System.getProperty("java.io.tmpdir"))).getAbsolutePath();
// Extract and load a native library inside the jar file
return extractLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder);
// Load an OS-dependent native library inside a jar file
snappyNativeLibraryPath = "/org/xerial/snappy/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
boolean hasNativeLib = hasResource(snappyNativeLibraryPath + "/" + snappyNativeLibraryName);
if(!hasNativeLib) {
if(OSInfo.getOSName().equals("Mac")) {
// Fix for openjdk7 for Mac
String altName = "libsnappyjava.jnilib";
if(hasResource(snappyNativeLibraryPath + "/" + altName)) {
snappyNativeLibraryName = altName;
hasNativeLib = true;
}
}
}
return null; // Use a pre-installed libsnappyjava
if(!hasNativeLib) {
String errorMessage = String.format("no native library is found for os.name=%s and os.arch=%s", OSInfo.getOSName(), OSInfo.getArchName());
throw new SnappyError(SnappyErrorCode.FAILED_TO_LOAD_NATIVE_LIBRARY, errorMessage);
}
// Temporary library folder. Use the value of org.xerial.snappy.tempdir or java.io.tmpdir
String tempFolder = new File(System.getProperty(KEY_SNAPPY_TEMPDIR,
System.getProperty("java.io.tmpdir"))).getAbsolutePath();
// Extract and load a native library inside the jar file
return extractLibraryFile(snappyNativeLibraryPath, snappyNativeLibraryName, tempFolder);
}
private static boolean hasResource(String path) {
return SnappyLoader.class.getResource(path) != null;
}
/**
* Get the snappy-java version by reading pom.properties embedded in jar.
* This version data is used as a suffix of a dll file extracted from the