First pass at adding Gradle as build tool

This commit is contained in:
J. Brisbin
2011-02-04 12:42:30 -06:00
parent d2d59a17e5
commit da11fd7c5d
17 changed files with 573 additions and 164 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
target
build
.springBeans
.ant-targets-build.xml
src/ant/.ant-targets-upload-dist.xml

62
build.gradle Normal file
View File

@@ -0,0 +1,62 @@
apply plugin: "eclipse"
apply plugin: "idea"
subprojects {
apply plugin: "java"
apply plugin: "maven"
releaseType = "M2"
version = "1.0.0.$releaseType"
compileJava.options.compilerArgs = ["-Xlint:unchecked"]
repositories {
// Read user's local Maven repo first
mavenRepo name: "mavenLocal", urls: new File(System.getProperty("user.home" ), ".m2/repository").toURL().toString()
// Public Spring artefacts
mavenRepo name: "spring-release", urls: "http://maven.springframework.org/release"
mavenRepo name: "spring-milestone", urls: "http://maven.springframework.org/milestone"
mavenRepo name: "spring-snapshot", urls: "http://maven.springframework.org/snapshot"
// Additional community artefacts
mavenCentral()
mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots"
mavenRepo name: "jboss", urls: "http://repository.jboss.org/maven2/"
mavenRepo name: "java.net", urls: "http://download.java.net/maven/2/"
}
// Common dependencies
dependencies {
// Logging
compile "org.slf4j:slf4j-api:$slf4jVersion"
compile "org.slf4j:jcl-over-slf4j:$slf4jVersion"
runtime "log4j:log4j:$log4jVersion"
runtime "org.slf4j:slf4j-log4j12:$slf4jVersion"
// Spring Framework
compile("org.springframework:spring-core:$springVersion") {
exclude module: "commons-logging"
}
compile "org.springframework:spring-beans:$springVersion"
compile "org.springframework:spring-context:$springVersion"
compile "org.springframework:spring-context-support:$springVersion"
compile "org.springframework:spring-tx:$springVersion"
// Jackson JSON Mapper
compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
// Testing
testCompile "junit:junit:$junitVersion"
testCompile "org.springframework:spring-test:$springVersion"
testCompile "org.mockito:mockito-all:$mockitoVersion"
}
}
configurations {
build
}
repositories {
mavenCentral()
}
dependencies {
}

15
gradle.properties Normal file
View File

@@ -0,0 +1,15 @@
# Logging
log4jVersion = 1.2.16
slf4jVersion = 1.6.1
# Common libraries
springVersion = 3.0.5.RELEASE
jacksonVersion = 1.6.4
# Redis support
jedisVersion = 1.5.2-SNAPSHOT
jredisVersion = 03122010
# Testing
junitVersion = 4.8.1
mockitoVersion = 1.8.5

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,6 @@
#Fri Feb 04 09:28:52 CST 2011
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://gradle.artifactoryonline.com/gradle/distributions/gradle-0.9.2-bin.zip

168
gradlew vendored Executable file
View File

@@ -0,0 +1,168 @@
#!/bin/bash
##############################################################################
## ##
## Gradle wrapper script for UN*X ##
## ##
##############################################################################
# Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
# GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"
# JAVA_OPTS="$JAVA_OPTS -Xmx512m"
GRADLE_APP_NAME=Gradle
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set JAVA_HOME if it's not already set.
if [ -z "$JAVA_HOME" ] ; then
if $darwin ; then
[ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
[ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
else
javaExecutable="`which javac`"
[ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
[ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
javaExecutable="`readlink -f \"$javaExecutable\"`"
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
export JAVA_HOME="$javaHome"
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar
WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties
# Determine the Java command to use to start the JVM.
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="java"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
if [ -z "$JAVA_HOME" ] ; then
warn "JAVA_HOME environment variable is not set"
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
if $darwin; then
JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
# we may also want to set -Xdock:image
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
GRADLE_APP_BASE_NAME=`basename "$0"`
exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
-classpath "$CLASSPATH" \
-Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \
-Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
$STARTER_MAIN_CLASS \
"$@"

82
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,82 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem ##
@rem Gradle startup script for Windows ##
@rem ##
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m
@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.\
@rem Find java.exe
set JAVA_EXE=java.exe
if not defined JAVA_HOME goto init
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo.
goto end
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
set CLASSPATH=%DIRNAME%\gradle\wrapper\gradle-wrapper.jar
set WRAPPER_PROPERTIES=%DIRNAME%\gradle\wrapper\gradle-wrapper.properties
set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%"
@rem Execute Gradle
"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%"
exit /b "%ERRORLEVEL%"
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -52,9 +52,9 @@
<developer>
<id>jbrisbin</id>
<name>Jon Brisbin</name>
<email>jon at jbrisbin.com</email>
<organization>NPC International</organization>
<organizationUrl>http://www.npcinternational.com</organizationUrl>
<email>jbrisbin at vmware.com</email>
<organization>SpringSource</organization>
<organizationUrl>http://www.SpringSource.com</organizationUrl>
<roles>
<role>Developer</role>
</roles>

3
settings.gradle Normal file
View File

@@ -0,0 +1,3 @@
include "spring-data-keyvalue-core",
"spring-data-redis",
"spring-data-riak"

View File

View File

@@ -0,0 +1,12 @@
repositories {
mavenRepo name: "ext-snapshots", urls: "http://springframework.svn.sourceforge.net/svnroot/springframework/repos/repo-ext/"
}
dependencies {
compile project(":spring-data-keyvalue-core")
compile "javax.annotation:jsr250-api:1.0"
compile "com.thoughtworks.xstream:xstream:1.3"
compile "redis.clients:jedis:$jedisVersion"
compile "org.jredis:jredis-anthonylauzon:$jredisVersion"
compile "org.springframework:spring-oxm:$springVersion"
}

View File

@@ -0,0 +1,9 @@
dependencies {
compile project(":spring-data-keyvalue-core")
compile "org.codehaus.groovy:groovy-all:1.7.6"
compile "javax.mail:mail:1.4.1"
compile "javax.activation:activation:1.1.1"
compile "commons-cli:commons-cli:1.2"
compile "org.springframework:spring-web:$springVersion"
}

View File

@@ -40,103 +40,105 @@ import java.util.Map;
@SuppressWarnings({"unchecked"})
public abstract class AbstractRiakMapReduceJob implements MapReduceJob {
protected final Log log = LogFactory.getLog(getClass());
protected List<Object> inputs = new LinkedList<Object>();
protected List<MapReducePhase> phases = new ArrayList<MapReducePhase>();
protected final Log log = LogFactory.getLog(getClass());
protected List<Object> inputs = new LinkedList<Object>();
protected List<MapReducePhase> phases = new ArrayList<MapReducePhase>();
public List getInputs() {
return this.inputs;
}
public List getInputs() {
return this.inputs;
}
public MapReduceJob addInputs(List keys) {
inputs.addAll(keys);
return this;
}
public MapReduceJob addInputs(List keys) {
inputs.addAll(keys);
return this;
}
public MapReduceJob addPhase(MapReducePhase phase) {
phases.add(phase);
return this;
}
public MapReduceJob addPhase(MapReducePhase phase) {
phases.add(phase);
return this;
}
public List<MapReducePhase> getPhases() {
return this.phases;
}
public List<MapReducePhase> getPhases() {
return this.phases;
}
public String toJson() {
StringWriter out = new StringWriter();
try {
JsonGenerator json = new JsonFactory().createJsonGenerator(out);
json.setCodec(new ObjectMapper());
json.writeStartObject();
public String toJson() {
StringWriter out = new StringWriter();
try {
JsonGenerator json = new JsonFactory().createJsonGenerator(out);
json.setCodec(new ObjectMapper());
json.writeStartObject();
// Inputs
json.writeFieldName("inputs");
if (1 == inputs.size() && !(inputs.get(0) instanceof List)) {
json.writeString(inputs.get(0).toString());
} else if (inputs.size() > 0) {
json.writeStartArray();
for (Object obj : inputs) {
List pair = (List) obj;
json.writeStartArray();
json.writeString(pair.get(0).toString());
json.writeString(pair.get(1).toString());
json.writeEndArray();
}
json.writeEndArray();
}
// Inputs
json.writeFieldName("inputs");
if (1 == inputs.size() && !(inputs.get(0) instanceof List)) {
json.writeString(inputs.get(0).toString());
} else if (inputs.size() > 0) {
json.writeStartArray();
for (Object obj : inputs) {
List pair = (List) obj;
json.writeStartArray();
json.writeString(pair.get(0).toString());
json.writeString(pair.get(1).toString());
json.writeEndArray();
}
json.writeEndArray();
}
// Query
json.writeFieldName("query");
json.writeStartArray();
for (MapReducePhase phase : phases) {
json.writeStartObject();
switch (phase.getPhase()) {
case MAP:
json.writeFieldName("map");
break;
case REDUCE:
json.writeFieldName("reduce");
break;
}
// Query
json.writeFieldName("query");
json.writeStartArray();
for (MapReducePhase phase : phases) {
json.writeStartObject();
switch (phase.getPhase()) {
case MAP:
json.writeFieldName("map");
break;
case REDUCE:
json.writeFieldName("reduce");
break;
case LINK:
json.writeFieldName("link");
}
json.writeStartObject();
json.writeStringField("language", phase.getLanguage());
Object repr = phase.getOperation().getRepresentation();
if (repr instanceof String) {
// Using source
json.writeStringField("source",
String.format("%s", phase.getOperation().getRepresentation()));
} else if (repr instanceof BucketKeyPair) {
BucketKeyPair pair = (BucketKeyPair) repr;
json.writeStringField("bucket",
String.format("%s", pair.getBucket()));
json.writeStringField("key", String.format("%s", pair.getKey()));
} else if (repr instanceof Map) {
for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) repr).entrySet()) {
json.writeStringField(entry.getKey().toString(),
entry.getValue().toString());
}
}
if (phase.getKeepResults()) {
json.writeBooleanField("keep", true);
}
// Arg
if (null != phase.getArg()) {
json.writeObjectField("arg", phase.getArg());
}
json.writeStartObject();
json.writeStringField("language", phase.getLanguage());
Object repr = phase.getOperation().getRepresentation();
if (repr instanceof String) {
// Using source
json.writeStringField("source",
String.format("%s", phase.getOperation().getRepresentation()));
} else if (repr instanceof BucketKeyPair) {
BucketKeyPair pair = (BucketKeyPair) repr;
json.writeStringField("bucket",
String.format("%s", pair.getBucket()));
json.writeStringField("key", String.format("%s", pair.getKey()));
} else if (repr instanceof Map) {
for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) repr).entrySet()) {
json.writeStringField(entry.getKey().toString(),
entry.getValue().toString());
}
}
if (phase.getKeepResults()) {
json.writeBooleanField("keep", true);
}
// Arg
if (null != phase.getArg()) {
json.writeObjectField("arg", phase.getArg());
}
json.writeEndObject();
json.writeEndObject();
}
json.writeEndArray();
json.writeEndObject();
json.writeEndObject();
}
json.writeEndArray();
json.writeEndObject();
json.flush();
json.writeEndObject();
json.flush();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
return out.toString();
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
return out.toString();
}
}

View File

@@ -0,0 +1,26 @@
package org.springframework.data.keyvalue.riak.mapreduce;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author J. Brisbin <jbrisbin@vmware.com>
*/
public class MapReduceLinkOperation implements MapReduceOperation {
protected String bucket = null;
protected String key;
public MapReduceLinkOperation(String bucket, String key) {
this.bucket = bucket;
this.key = key;
}
public Object getRepresentation() {
Map<String, Object> repr = new LinkedHashMap<String, Object>();
repr.put("bucket", (null != bucket ? bucket : "_"));
repr.put("key", (null != key ? key : "_"));
return repr;
}
}

View File

@@ -25,44 +25,58 @@ package org.springframework.data.keyvalue.riak.mapreduce;
*/
public interface MapReducePhase {
public static enum Phase {
MAP, REDUCE
}
public static enum Phase {
MAP, REDUCE, LINK
}
Phase getPhase();
/**
* The bucket pattern to match on link phases.
*
* @return
*/
String getBucket();
/**
* The language this phase is described in.
*
* @return
*/
String getLanguage();
/**
* Set the bucket pattern to match on link phases.
*
* @param bucket
*/
void setBucket(String bucket);
/**
* Whether or not to keep the result of this phase.
*
* @return
*/
boolean getKeepResults();
Phase getPhase();
/**
* Get the operation this phase will execute.
*
* @return
*/
MapReduceOperation getOperation();
/**
* The language this phase is described in.
*
* @return
*/
String getLanguage();
/**
* Set the static argument for this job.
*
* @param arg
*/
void setArg(Object arg);
/**
* Whether or not to keep the result of this phase.
*
* @return
*/
boolean getKeepResults();
/**
* Get the static argument for this phase.
*
* @return
*/
Object getArg();
/**
* Get the operation this phase will execute.
*
* @return
*/
MapReduceOperation getOperation();
/**
* Set the static argument for this job.
*
* @param arg
*/
void setArg(Object arg);
/**
* Get the static argument for this phase.
*
* @return
*/
Object getArg();
}

View File

@@ -26,54 +26,63 @@ package org.springframework.data.keyvalue.riak.mapreduce;
*/
public class RiakMapReducePhase implements MapReducePhase {
protected Phase phase;
protected String language;
protected MapReduceOperation operation;
protected boolean keepResults = false;
protected Object arg;
protected Phase phase;
protected String bucket;
protected String language;
protected MapReduceOperation operation;
protected boolean keepResults = false;
protected Object arg;
public RiakMapReducePhase(String phase, String language, MapReduceOperation oper) {
this.phase = Phase.valueOf(phase.toUpperCase());
this.language = language;
this.operation = oper;
}
public RiakMapReducePhase(String phase, String language, MapReduceOperation oper) {
this.phase = Phase.valueOf(phase.toUpperCase());
this.language = language;
this.operation = oper;
}
public RiakMapReducePhase(Phase phase, String language, MapReduceOperation oper) {
this.phase = phase;
this.language = language;
this.operation = oper;
}
public RiakMapReducePhase(Phase phase, String language, MapReduceOperation oper) {
this.phase = phase;
this.language = language;
this.operation = oper;
}
public Phase getPhase() {
return phase;
}
public String getBucket() {
return this.bucket;
}
public String getLanguage() {
return language;
}
public void setBucket(String bucket) {
this.bucket = bucket;
}
public MapReduceOperation getOperation() {
return this.operation;
}
public Phase getPhase() {
return phase;
}
public boolean getKeepResults() {
return this.keepResults;
}
public String getLanguage() {
return language;
}
public void setKeepResults(boolean keepResults) {
this.keepResults = keepResults;
}
public MapReduceOperation getOperation() {
return this.operation;
}
public void setOperation(MapReduceOperation oper) {
public boolean getKeepResults() {
return this.keepResults;
}
this.operation = oper;
}
public void setKeepResults(boolean keepResults) {
this.keepResults = keepResults;
}
public Object getArg() {
return arg;
}
public void setOperation(MapReduceOperation oper) {
public void setArg(Object arg) {
this.arg = arg;
}
this.operation = oper;
}
public Object getArg() {
return arg;
}
public void setArg(Object arg) {
this.arg = arg;
}
}

View File

@@ -15,7 +15,7 @@
<author>
<firstname>Jon</firstname>
<surname>Brisbin</surname>
<affiliation>NPC International, Inc.</affiliation>
<affiliation>SpringSource</affiliation>
</author>
</authorgroup>