├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── java │ └── com │ │ └── glonk │ │ └── benchmark │ │ ├── Benchmark.java │ │ ├── BenchmarkSet.java │ │ ├── jackson │ │ ├── model │ │ │ ├── Type.java │ │ │ └── Obj.java │ │ └── JacksonBenchmarks.java │ │ ├── protobuf │ │ └── ProtobufBenchmarks.java │ │ └── BenchmarkApp.java │ └── proto │ └── dummy.proto ├── README.md └── gradlew /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .gradle 3 | .project 4 | .settings 5 | 6 | bin/ 7 | build/ 8 | gradlew.bat 9 | 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phensley/protobuf-vs-jackson/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/java/com/glonk/benchmark/Benchmark.java: -------------------------------------------------------------------------------- 1 | package com.glonk.benchmark; 2 | 3 | public interface Benchmark { 4 | 5 | String name(); 6 | 7 | void run() throws Exception; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jun 25 15:17:21 EDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip 7 | -------------------------------------------------------------------------------- /src/main/java/com/glonk/benchmark/BenchmarkSet.java: -------------------------------------------------------------------------------- 1 | package com.glonk.benchmark; 2 | 3 | public interface BenchmarkSet { 4 | 5 | String name(); 6 | 7 | Benchmark serialization() throws Exception; 8 | 9 | Benchmark deserialization() throws Exception; 10 | 11 | int encodedSize() throws Exception; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/glonk/benchmark/jackson/model/Type.java: -------------------------------------------------------------------------------- 1 | package com.glonk.benchmark.jackson.model; 2 | 3 | public enum Type { 4 | 5 | UNKNOWN(0), 6 | FOO(1), 7 | BAR(2) 8 | ; 9 | 10 | private final int value; 11 | 12 | private Type(int value) { 13 | this.value = value; 14 | } 15 | 16 | public int getValue() { 17 | return value; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/proto/dummy.proto: -------------------------------------------------------------------------------- 1 | 2 | syntax = 'proto3'; 3 | 4 | package benchmark; 5 | 6 | option java_package = "com.glonk.benchmark.protobuf.model"; 7 | option java_multiple_files = true; 8 | 9 | enum Type { 10 | UNKNOWN = 0; 11 | FOO = 1; 12 | BAR = 2; 13 | } 14 | 15 | message Obj { 16 | Type type = 1; 17 | bool flag = 2; 18 | int32 num32 = 3; 19 | int64 num64 = 4; 20 | string str = 5; 21 | repeated Obj children = 10; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/java/com/glonk/benchmark/protobuf/ProtobufBenchmarks.java: -------------------------------------------------------------------------------- 1 | package com.glonk.benchmark.protobuf; 2 | 3 | import com.glonk.benchmark.Benchmark; 4 | import com.glonk.benchmark.BenchmarkSet; 5 | import com.glonk.benchmark.protobuf.model.Obj; 6 | import com.glonk.benchmark.protobuf.model.Type; 7 | 8 | 9 | public class ProtobufBenchmarks implements BenchmarkSet { 10 | 11 | private static final String name = "protobuf"; 12 | 13 | private final int numChildren; 14 | 15 | public ProtobufBenchmarks(int numChildren) { 16 | this.numChildren = numChildren; 17 | } 18 | 19 | @Override 20 | public String name() { 21 | return name; 22 | } 23 | 24 | @Override 25 | public Benchmark serialization() { 26 | final Obj obj = buildObject("parent"); 27 | return new Benchmark() { 28 | @Override 29 | public String name() { 30 | return name + " serialization"; 31 | } 32 | @Override 33 | public void run() throws Exception { 34 | obj.toByteArray(); 35 | } 36 | }; 37 | } 38 | 39 | @Override 40 | public Benchmark deserialization() { 41 | Obj obj = buildObject("parent"); 42 | final byte[] bytes = obj.toByteArray(); 43 | return new Benchmark() { 44 | @Override 45 | public String name() { 46 | return name + " deserialization"; 47 | } 48 | @Override 49 | public void run() throws Exception { 50 | Obj.parseFrom(bytes); 51 | } 52 | }; 53 | } 54 | 55 | @Override 56 | public int encodedSize() { 57 | Obj obj = buildObject("parent"); 58 | byte[] bytes = obj.toByteArray(); 59 | return bytes.length; 60 | } 61 | 62 | private Obj buildObject(String name) { 63 | return buildObject(name, true); 64 | } 65 | 66 | private Obj buildObject(String name, boolean children) { 67 | Obj.Builder builder = Obj.newBuilder() 68 | .setType(Type.FOO) 69 | .setNum32(Integer.MAX_VALUE) 70 | .setNum64(Long.MAX_VALUE) 71 | .setStr(name); 72 | if (children) { 73 | for (int i = 0; i < numChildren; i++) { 74 | builder.addChildren(buildObject("child " + (i + 1), false)); 75 | } 76 | } 77 | return builder.build(); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/glonk/benchmark/jackson/model/Obj.java: -------------------------------------------------------------------------------- 1 | package com.glonk.benchmark.jackson.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | 7 | public class Obj { 8 | 9 | protected Type type = Type.UNKNOWN; 10 | 11 | protected boolean flag; 12 | 13 | protected int num32; 14 | 15 | protected long num64; 16 | 17 | protected String str; 18 | 19 | protected List children; 20 | 21 | public void setType(Type type) { 22 | this.type = type; 23 | } 24 | 25 | public Type getType() { 26 | return type; 27 | } 28 | 29 | public void setFlag(boolean flag) { 30 | this.flag = flag; 31 | } 32 | 33 | public boolean getFlag() { 34 | return flag; 35 | } 36 | 37 | public void setNum32(int num) { 38 | this.num32 = num; 39 | } 40 | 41 | public int getNum32() { 42 | return num32; 43 | } 44 | 45 | public void setNum64(long num) { 46 | this.num64 = num; 47 | } 48 | 49 | public long getNum64() { 50 | return num64; 51 | } 52 | 53 | public void setStr(String str) { 54 | this.str = str; 55 | } 56 | 57 | public String getStr() { 58 | return str; 59 | } 60 | 61 | public void setChildren(List children) { 62 | this.children = children; 63 | } 64 | 65 | public List getChildren() { 66 | return this.children; 67 | } 68 | 69 | public static Builder newBuilder() { 70 | return new Builder(); 71 | } 72 | 73 | public static class Builder { 74 | 75 | private final Obj obj = new Obj(); 76 | 77 | private List children; 78 | 79 | public Builder setType(Type type) { 80 | obj.type = type; 81 | return this; 82 | } 83 | 84 | public Builder setFlag(boolean flag) { 85 | obj.flag = flag; 86 | return this; 87 | } 88 | 89 | public Builder setNum32(int num) { 90 | obj.num32 = num; 91 | return this; 92 | } 93 | 94 | public Builder setNum64(long num) { 95 | obj.num64 = num; 96 | return this; 97 | } 98 | 99 | public Builder setStr(String str) { 100 | obj.str = str; 101 | return this; 102 | } 103 | 104 | public Builder addChild(Obj child) { 105 | if (this.children == null) { 106 | this.children = new ArrayList<>(); 107 | } 108 | this.children.add(child); 109 | return this; 110 | } 111 | 112 | public Obj build() { 113 | obj.setChildren(children); 114 | return obj; 115 | } 116 | 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/com/glonk/benchmark/jackson/JacksonBenchmarks.java: -------------------------------------------------------------------------------- 1 | package com.glonk.benchmark.jackson; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.fasterxml.jackson.module.afterburner.AfterburnerModule; 5 | import com.glonk.benchmark.Benchmark; 6 | import com.glonk.benchmark.BenchmarkSet; 7 | import com.glonk.benchmark.jackson.model.Obj; 8 | import com.glonk.benchmark.jackson.model.Type; 9 | 10 | 11 | public class JacksonBenchmarks implements BenchmarkSet { 12 | 13 | private static final ObjectMapper objectMapper = new ObjectMapper(); 14 | 15 | private final String name; 16 | 17 | private final int numChildren; 18 | 19 | public JacksonBenchmarks(boolean withAfterburner, int numChildren) { 20 | this.numChildren = numChildren; 21 | if (withAfterburner) { 22 | name = "afterburner"; 23 | objectMapper.registerModule(new AfterburnerModule()); 24 | } else { 25 | name = "jackson"; 26 | } 27 | } 28 | 29 | @Override 30 | public String name() { 31 | return name; 32 | } 33 | 34 | @Override 35 | public Benchmark serialization() throws Exception { 36 | final Obj obj = buildObject("parent"); 37 | return new Benchmark() { 38 | @Override 39 | public String name() { 40 | return name + " serialization"; 41 | } 42 | 43 | @Override 44 | public void run() throws Exception { 45 | objectMapper.writeValueAsString(obj); 46 | } 47 | }; 48 | } 49 | 50 | @Override 51 | public Benchmark deserialization() throws Exception { 52 | final Obj obj = buildObject("parent"); 53 | String json = objectMapper.writeValueAsString(obj); 54 | return new Benchmark() { 55 | @Override 56 | public String name() { 57 | return name + " deserialization"; 58 | } 59 | 60 | @Override 61 | public void run() throws Exception { 62 | objectMapper.readValue(json, Obj.class); 63 | } 64 | }; 65 | } 66 | 67 | @Override 68 | public int encodedSize() throws Exception { 69 | Obj obj = buildObject("parent"); 70 | String json = objectMapper.writeValueAsString(obj); 71 | return json.length(); 72 | } 73 | 74 | private Obj buildObject(String name) { 75 | return buildObject(name, true); 76 | } 77 | 78 | private Obj buildObject(String name, boolean children) { 79 | Obj.Builder builder = Obj.newBuilder() 80 | .setType(Type.FOO) 81 | .setFlag(true) 82 | .setNum32(Integer.MAX_VALUE) 83 | .setNum64(Long.MAX_VALUE) 84 | .setStr(name); 85 | if (children) { 86 | for (int i = 0; i < numChildren; i++) { 87 | builder.addChild(buildObject("child " + (i + 1), false)); 88 | } 89 | } 90 | return builder.build(); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/glonk/benchmark/BenchmarkApp.java: -------------------------------------------------------------------------------- 1 | package com.glonk.benchmark; 2 | 3 | import java.text.DecimalFormat; 4 | 5 | import com.glonk.benchmark.jackson.JacksonBenchmarks; 6 | import com.glonk.benchmark.protobuf.ProtobufBenchmarks; 7 | 8 | 9 | public class BenchmarkApp { 10 | 11 | private static final DecimalFormat DECIMAL = new DecimalFormat("#,###.0"); 12 | 13 | private static final int LOOPS = 10; 14 | 15 | private static final int ITERS = 20000; 16 | 17 | public static void main(String[] args) throws Exception { 18 | System.out.printf("%30s %8s %8s %8s\n", "test", "min", "max", "avg"); 19 | System.out.println("-----------------------------------------------------------------"); 20 | 21 | for (int numChildren : new int[] { 0, 8, 16, 32 }) { 22 | System.out.println("\nwith " + numChildren + " children"); 23 | 24 | BenchmarkSet[] sets = new BenchmarkSet[] { 25 | new JacksonBenchmarks(false, numChildren), 26 | new JacksonBenchmarks(true, numChildren), 27 | new ProtobufBenchmarks(numChildren) 28 | }; 29 | 30 | for (BenchmarkSet set : sets) { 31 | run(set); 32 | } 33 | 34 | System.out.println("\nencoded sizes:"); 35 | for (BenchmarkSet set : sets) { 36 | System.out.printf("%30s %s\n", set.name(), set.encodedSize()); 37 | } 38 | System.out.println(); 39 | } 40 | } 41 | 42 | private static void run(BenchmarkSet set) throws Exception { 43 | run(set.serialization(), LOOPS, ITERS); 44 | run(set.deserialization(), LOOPS, ITERS); 45 | } 46 | 47 | private static void run(Benchmark benchmark, int loops, int iters) throws Exception { 48 | double min = 0; 49 | double max = 0; 50 | double total = 0; 51 | 52 | // warm up 53 | for (int i = 0; i < 10; i++) { 54 | benchmark.run(); 55 | } 56 | 57 | Timer timer = new Timer(); 58 | for (int i = 0; i < loops; i++) { 59 | timer.start(); 60 | 61 | // timing loop 62 | for (int j = 0; j < iters; j++) { 63 | benchmark.run(); 64 | } 65 | 66 | double elapsed = timer.elapsedMs(); 67 | if (i == 0) { 68 | min = max = elapsed; 69 | } else { 70 | min = Math.min(min, elapsed); 71 | max = Math.max(max, elapsed); 72 | } 73 | total += elapsed; 74 | } 75 | 76 | double avg = total / loops; 77 | display(benchmark, min, max, avg); 78 | } 79 | 80 | private static void display(Benchmark benchmark, double min, double max, double avg) { 81 | System.out.printf("%30s %8s %8s %8s\n", 82 | benchmark.name(), 83 | DECIMAL.format(min), 84 | DECIMAL.format(max), 85 | DECIMAL.format(avg)); 86 | } 87 | 88 | static class Timer { 89 | 90 | private long start = now(); 91 | 92 | public void start() { 93 | start = now(); 94 | } 95 | 96 | public double elapsedMs() { 97 | long now = now(); 98 | return (now - start) / 1000000.0; 99 | } 100 | 101 | private long now() { 102 | return System.nanoTime(); 103 | } 104 | 105 | } 106 | 107 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Benchmark - Protcol Buffers 3 vs Jackson JSON 3 | ------ 4 | 5 | This is a simple comparison of performance and size between 6 | Jackson (w/ Afterburner) and Protocol Buffers version 3. 7 | 8 | 9 | I came across [an article][article] comparing the two, showing PB with worse performance, in 10 | some tests nearly 2-times slower. 11 | 12 | My initial reaction was: this can't be correct. When browsing the [benchmark's 13 | source code][source] I noticed the PB version was adversely impacted by converting 14 | JodaTime to / from string, while Jackson was using a more efficient 15 | serialization. The profiler showed JodaTime conversion was taking up most of 16 | the time, making PB look far worse. 17 | 18 | Usage 19 | ----- 20 | 21 | ./gradlew run 22 | 23 | 24 | Example Run 25 | ----- 26 | 27 | JDK 8 28 | Macbook Pro Retina (mid-2012) 29 | 2.7 GHz Intel Core i7 30 | 16 GB 1600 MHz DDR3 31 | 32 | loops = 10 33 | iters = 10,000 34 | 35 | times in milliseconds 36 | sizes in bytes (protobuf) and characters (jackson) 37 | 38 | test min max avg 39 | ----------------------------------------------------------------- 40 | 41 | with 0 children 42 | jackson serialization 7.3 71.3 19.1 43 | jackson deserialization 13.6 95.6 27.2 44 | afterburner serialization 8.0 36.6 14.5 45 | afterburner deserialization 13.5 15.6 13.9 46 | protobuf serialization 1.2 12.4 3.1 47 | protobuf deserialization 1.7 12.5 4.0 48 | 49 | encoded sizes: 50 | jackson 104 51 | afterburner 104 52 | protobuf 26 53 | 54 | 55 | with 8 children 56 | jackson serialization 53.3 78.7 62.5 57 | jackson deserialization 110.1 130.9 114.9 58 | afterburner serialization 53.5 57.5 54.7 59 | afterburner deserialization 109.8 115.4 112.7 60 | protobuf serialization 10.2 82.1 19.0 61 | protobuf deserialization 19.3 35.2 25.1 62 | 63 | encoded sizes: 64 | jackson 949 65 | afterburner 949 66 | protobuf 258 67 | 68 | 69 | with 16 children 70 | jackson serialization 102.2 111.3 105.8 71 | jackson deserialization 210.4 218.6 214.7 72 | afterburner serialization 102.2 108.5 105.6 73 | afterburner deserialization 210.8 229.2 217.2 74 | protobuf serialization 19.5 23.2 20.3 75 | protobuf deserialization 37.6 47.6 40.3 76 | 77 | encoded sizes: 78 | jackson 1804 79 | afterburner 1804 80 | protobuf 497 81 | 82 | 83 | with 32 children 84 | jackson serialization 198.2 211.6 204.0 85 | jackson deserialization 403.9 427.1 416.1 86 | afterburner serialization 198.4 244.4 212.8 87 | afterburner deserialization 407.0 439.5 420.2 88 | protobuf serialization 38.0 41.4 39.5 89 | protobuf deserialization 73.8 84.0 76.9 90 | 91 | encoded sizes: 92 | jackson 3516 93 | afterburner 3516 94 | protobuf 977 95 | 96 | Example Objects 97 | ----- 98 | 99 | JSON-encoded object with 1 child (indented for readability): 207 characters 100 | 101 | { 102 | "num64": 9223372036854775807, 103 | "flag": true, 104 | "str": "parent", 105 | "type": "FOO", 106 | "children": [ 107 | { 108 | "num64": 9223372036854775807, 109 | "flag": true, 110 | "str": "child 1", 111 | "type": "FOO", 112 | "children": null, 113 | "num32": 2147483647 114 | } 115 | ], 116 | "num32": 2147483647 117 | } 118 | 119 | Protobuf-encoded object with 1 child (byte array): 55 bytes 120 | 121 | { 122 | \x08, \x01, \x18, \xff, \xff, \xff, \xff, \x07, \x20, \xff, 123 | \xff, \xff, \xff, \xff, \xff, \xff, \xff, \x7f, \x2a, \x06, 124 | 'p', 'a', 'r', 'e', 'n', 't', \x52, \x1b, \x08, \x01, \x18, 125 | \xff, \xff, \xff, \xff, \x07, \x20, \xff, \xff, \xff, \xff, 126 | \xff, \xff, \xff, \xff, \x7f, \x2a, \x07, 'c', 'h', 'i', 'l', 127 | 'd', ' ', '1' 128 | } 129 | 130 | 131 | [article]: http://technicalrex.com/2015/02/27/performance-playground-jackson-vs-protocol-buffers-part-2/ 132 | [source]: http://github.com/egillespie/performance-playground 133 | 134 | 135 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | --------------------------------------------------------------------------------