embulk-filter-add_time 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +3 -0
  5. data/COPYING +14 -0
  6. data/README.md +212 -0
  7. data/build.gradle +82 -0
  8. data/gradle/check.gradle +34 -0
  9. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  10. data/gradle/wrapper/gradle-wrapper.properties +6 -0
  11. data/gradlew +164 -0
  12. data/gradlew.bat +90 -0
  13. data/lib/embulk/filter/add_time.rb +3 -0
  14. data/src/main/java/org/embulk/filter/add_time/AddTimeFilterPlugin.java +208 -0
  15. data/src/main/java/org/embulk/filter/add_time/converter/ColumnConverter.java +14 -0
  16. data/src/main/java/org/embulk/filter/add_time/converter/ColumnDuplicator.java +72 -0
  17. data/src/main/java/org/embulk/filter/add_time/converter/LongValueCastConverter.java +33 -0
  18. data/src/main/java/org/embulk/filter/add_time/converter/SchemaConverter.java +257 -0
  19. data/src/main/java/org/embulk/filter/add_time/converter/SimpleColumnConverter.java +62 -0
  20. data/src/main/java/org/embulk/filter/add_time/converter/StringValueCastConverter.java +33 -0
  21. data/src/main/java/org/embulk/filter/add_time/converter/TimestampValueCastConverter.java +23 -0
  22. data/src/main/java/org/embulk/filter/add_time/converter/ValueCastConverter.java +108 -0
  23. data/src/main/java/org/embulk/filter/add_time/converter/ValueConverter.java +22 -0
  24. data/src/main/java/org/embulk/filter/add_time/converter/ValueNoConverter.java +46 -0
  25. data/src/main/java/org/embulk/filter/add_time/reader/AbstractColumnReader.java +55 -0
  26. data/src/main/java/org/embulk/filter/add_time/reader/BooleanColumnReader.java +35 -0
  27. data/src/main/java/org/embulk/filter/add_time/reader/ColumnReader.java +14 -0
  28. data/src/main/java/org/embulk/filter/add_time/reader/DoubleColumnReader.java +35 -0
  29. data/src/main/java/org/embulk/filter/add_time/reader/LongColumnReader.java +35 -0
  30. data/src/main/java/org/embulk/filter/add_time/reader/StringColumnReader.java +35 -0
  31. data/src/main/java/org/embulk/filter/add_time/reader/TimeValueGenerator.java +177 -0
  32. data/src/main/java/org/embulk/filter/add_time/reader/TimestampColumnReader.java +36 -0
  33. data/src/test/java/org/embulk/filter/add_time/TestAddTimeFilterPlugin.java +416 -0
  34. data/src/test/java/org/embulk/filter/add_time/converter/TestSchemaConverter.java +338 -0
  35. metadata +107 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d4e2b549cb21e8c80956270dffd3a7d3fde0a96
4
+ data.tar.gz: da794c2b1309cf71015a035876eb142e0056dfdb
5
+ SHA512:
6
+ metadata.gz: 14cff8010192c946d9349fe1d22198784205f4ddbc8d4537b2b9ceb98269553abeeff028fea808300a7c13489ddded45966ea39e81add2835cf36b474bbe9e6e
7
+ data.tar.gz: 66d5eada349e6502a170d05236d4f92223083b131a424bb3b946d856b5462523b19d923df03c2b73e60646e57995f0da3aa2977e4d268d108d364d6934feb0d7
@@ -0,0 +1,15 @@
1
+ *~
2
+ /pkg/
3
+ /tmp/
4
+ *.gemspec
5
+ .gradle/
6
+ /.gradle
7
+ /classpath/
8
+ build/
9
+ *.iml
10
+ .idea
11
+ /.settings/
12
+ /.metadata/
13
+ .classpath
14
+ .project
15
+ /pkg/
@@ -0,0 +1,7 @@
1
+ language: java
2
+ jdk: oraclejdk7
3
+
4
+ script: ./gradlew clean test
5
+
6
+ after_success:
7
+ - ./gradlew check jacocoRootReport
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 - 2016-01-28
2
+
3
+ The first release!!
data/COPYING ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (C) 2016 Muga Nishizawa
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
@@ -0,0 +1,212 @@
1
+ # Add time filter plugin for Embulk
2
+
3
+ The `embulk-filter-add_time` plugin allows users to add a new time-based column to the existing schema either by copying the value from another existing column in the schema or by specifying the value. The latter use case is particularly useful to tag all events bulk loaded with one Embulk run with a specific timestamp or time range.
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: filter
8
+
9
+ ## Configuration
10
+
11
+ ### to_column configuration
12
+
13
+ This configuration is **required**.
14
+
15
+ The `to_column` configuration specifies the name, type, and optional format of a new column to be added to the Embulk schema.
16
+
17
+ This configuration specifies the name, type, and format for the added time column as a set of key-value pairs:
18
+ - **name**<br/>
19
+ a string specifying the name of the new column (**required**).
20
+ - **type**<br/>
21
+ a string specifying the data type of the column: `long` or `timestamp` are the supported values for this parameter since they need to express a valid timestamp (**required**).
22
+ - **unix_timestamp_unit**<br/>
23
+ a string specifying the unit for the unix timestamp - it is required if the column type is `long`. `sec`, `milli` (for milliseconds), `micro` (for microseconds), or `nano` (for nanoseconds) are the supported values for this option (default is `sec`).
24
+
25
+ For example, the `to_column` configuration can be used to add a `'time'` column to the schema:
26
+
27
+ ```yaml
28
+ filters:
29
+ - type: add_time
30
+ to_column:
31
+ name: time
32
+ type: timestamp
33
+ ...
34
+ ```
35
+
36
+ Note that if a column with the **same name** as `name` already exists in the schema, the existing column name is changed by appending '\_' to its name. For example, if `'created_at'` is specified as `to_column` but the column name already exists, the existing column name is changed to `'created_at_'`.
37
+
38
+ When `long` type is specified for the `type` parameter, `unix_timestamp_unit` is required to convert from the unit timestamp value to `long` and tell the plugin how to exactly parse the timestamp number; `sec` for seconds, `milli` for milliseconds, `micro` for microseconds, or `nano` for nanoseconds are the supported values for this option:
39
+
40
+ ```yaml
41
+ filters:
42
+ - type: add_time
43
+ to_column:
44
+ name: time
45
+ type: long
46
+ unix_timestamp_unit: sec
47
+ ...
48
+ ```
49
+
50
+ ### from_value configuration
51
+
52
+ This configuration is mutually exclusive with `from_column` below. One amongst `from_column` and `from_value` configurations is required.
53
+
54
+ The `from_value` configuration specifies a specific value or range to be used as value of the column added by the `to_column` configuration. This configuration supports different modes and the behavior will vary accordingly. Refer to the examples below.
55
+
56
+ This configuration specifies the mode, the timestamp_format, and one amongst value, from and to, or nothing depending on the mode of choice as a set of key-value pairs.
57
+ These parameters are required:
58
+ - **mode**<br/>
59
+ a string specifying the mode. There are 3 valid modes (default is `fixed_time`):
60
+ * `fixed_time`<br/>
61
+ In this mode, all values of the added `to_column` column are set with the fixed value specified by the `value` parameter, which becomes a required parameter, see below;
62
+ * `incremental_time`<br/>
63
+ In this mode, all values of the added `to_column` column are set to a value that increments by 1 second for each record, starting at `from` timestamp and up to `to` timestamp, after which it wrap around and starts from `from` again and so on - hence the additional `from` and `to` parameters are required in this mode.
64
+ * `upload_time`<br/>
65
+ In this mode, all values of the added `to_column` column are set with the fixed value corresponding to the time the Embulk upload was started. This mode does not require additional parameters.
66
+ - **timestamp_format**<br/>
67
+ a string specifying how to parse the string value provided as either `value` or `from`/`to` parameters depending on the `mode` in use (default is `"%Y-%m-%d %H:%M:%S %z"`).<br/>
68
+ It follow the [Ruby's `strptime` format](http://ruby-doc.org/stdlib-2.0.0/libdoc/date/rdoc/DateTime.html#method-c-strptime). Note that at the moment also Unix timestamps and epoch times need to be specified as string, therefore the `timestamp_format` parameter needs to specify how to parse it.
69
+ - **unix_timestamp_unit**<br/>
70
+ a string specifying the expected unit of the unix timestamp for the long value provides as either `value` or `from`/`to` parameters `sec`, `milli` (for milliseconds), `micro` (for microseconds), or `nano` (for nanoseconds) are the supported values for this option (default is `sec`).
71
+
72
+ These parameters are mutually exclusive and the usage depend on the `mode`. The type of them is string or long. The format of the string value used here needs to match the rule provided in the `timestamp_format` parameter. The long value is converted to the unix timestamp with the unit provided in the `unix_timestamp_unit` parameter:
73
+ - **value**<br/>
74
+ a string or long values specifying a fixed value for the added time column. This options is required if the mode is `fixed_time`.
75
+ - **from** and **to**<br/>
76
+ two strings or long values specifying the value for the beginning and end of the range of time for `mode: incremental_time`. The format needs to be consistent between these two parameters.
77
+
78
+ Example: `mode: fixed_time`
79
+ ```yaml
80
+ filters:
81
+ - type: add_time
82
+ to_column:
83
+ name: time
84
+ type: timestamp
85
+ from_value:
86
+ mode: fixed_time
87
+ value: "2016-01-01 00:00:00 UTC"
88
+ timestamp_format: "%Y-%m-%d %H:%M:%S %z"
89
+ ```
90
+
91
+ The mode `fixed_time` is default and can be omitted:
92
+
93
+ ```yaml
94
+ filters:
95
+ - type: add_time
96
+ to_column:
97
+ name: time
98
+ type: timestamp
99
+ from_value:
100
+ value: "2016-01-01 00:00:00 UTC"
101
+ ```
102
+ ```yaml
103
+ filters:
104
+ - type: add_time
105
+ to_column:
106
+ name: time
107
+ type: timestamp
108
+ from_value:
109
+ value: 1453939479
110
+ ```
111
+
112
+ where in this example the format of the value is also corresponding to the default, therefore the `timestamp_format` option is also omitted.
113
+
114
+ Example: `mode: incremental_time`
115
+ ```yaml
116
+ filters:
117
+ - type: add_time
118
+ to_column:
119
+ name: time
120
+ type: timestamp
121
+ from_value:
122
+ mode: incremental_time
123
+ from: "2016-01-01 00:00:00 UTC"
124
+ to: "2016-01-01 01:00:00 UTC"
125
+ ```
126
+
127
+ Example: `mode: upload_time`
128
+ ```yaml
129
+ filters:
130
+ - type: add_time
131
+ to_column:
132
+ name: time
133
+ type: timestamp
134
+ from_value:
135
+ mode: upload_time
136
+ ```
137
+
138
+ where neither of the additional parameters `value`, `to`, and `from` is specified. Embulk will associate the fixed bulk upload start time to every record.
139
+
140
+ ### from_column configuration
141
+
142
+ This configuration is mutually exclusive with `from_value` above. One amongst `from_column` and `from_value` configurations is required.
143
+
144
+ The `from_column` configuration specifies the name of one of the columns found in the Embulk schema and the format to be used to parse and feed values in the column added by the `to_column` configuration. This configuration makes a copy of the values from the column specified by `name`, instead of renaming the source column itself.
145
+ The parameters for this configuration are expressed as a set of key-value pairs.
146
+ - **name**<br/>
147
+ a string specifying the name of the source column from the Embulk schema. The column type must be one of `long`, `timestamp` or `string` (**required**).
148
+ - **unix_timestamp_unit**<br/>
149
+ a string specifying the expected unit of the unix timestamp for the values of the source column: it is **required** only if the type of the source column is `long` (see above for supported types). The supported values are `sec` for seconds, `milli` for milliseconds, `micro` for microseconds, and `nano` for nanoseconds (default is `sec`).
150
+ - **timestamp_format**<br/>
151
+ a string specifying the expected format of the values in the source column: it is **required** only if the type of the column is `string` (see above for supported types) (default is `"%Y-%m-%d %H:%M:%S %z"`). It follow the [Ruby's `strptime` format](http://ruby-doc.org/stdlib-2.0.0/libdoc/date/rdoc/DateTime.html#method-c-strptime).
152
+
153
+ Note that if neither `timestamp_format` or `unix_timestamp_unit` parameters are specified, the column type is expected to be `timestamp`.
154
+
155
+ Example: `created_at` column with `timestamp` data type
156
+ ```yaml
157
+ filters:
158
+ - type: add_time
159
+ to_column:
160
+ name: time
161
+ type: timestamp
162
+ from_column:
163
+ name: created_at
164
+ ```
165
+
166
+ In this example the expected type for the source column `created_at` is `timestamp`. If the `created_at` column type is string, the `timestamp_format` parameter is required to provide Embulk with a way to parse the values and convert them to a `timestamp`.
167
+
168
+ ```yaml
169
+ filters:
170
+ - type: add_time
171
+ to_column:
172
+ name: time
173
+ type: timestamp
174
+ from_column:
175
+ name: created_at
176
+ timestamp_format: "%Y-%m-%d %H:%M:%S"
177
+ timezone: UTC
178
+ ```
179
+
180
+ If the type of the source column is long, the `unix_timestamp_unit` parameter is required. The additional parameter provides Embulk the information to properly parse the `long` values of the source column and convert them to type specified in the `to_column` configuration.
181
+
182
+ ```yaml
183
+ filters:
184
+ - type: add_time
185
+ to_column:
186
+ name: time
187
+ type: long
188
+ unix_timestamp_unit: sec
189
+ from_column:
190
+ name: created_at
191
+ unixtime_unit: milli
192
+ ```
193
+
194
+ ## Install
195
+
196
+ ```
197
+ $ embulk gem install embulk-filter-add_time
198
+ ```
199
+
200
+ ## Build
201
+
202
+ ### Build by Gradle
203
+ ```
204
+ $ git clone https://github.com/treasure-data/embulk-filter-add_time.git
205
+ $ cd embulk-filter-add_time
206
+ $ ./gradlew gem classpath
207
+ ```
208
+
209
+ ### Run on Embulk
210
+ ```
211
+ $ bin/embulk run -I embulk-filter-add_time/lib/ config.yml
212
+ ```
@@ -0,0 +1,82 @@
1
+ plugins {
2
+ id "com.jfrog.bintray" version "1.1"
3
+ id "com.github.jruby-gradle.base" version "0.1.5"
4
+ id "java"
5
+ }
6
+
7
+ apply from: 'gradle/check.gradle'
8
+
9
+ import com.github.jrubygradle.JRubyExec
10
+ repositories {
11
+ mavenCentral()
12
+ jcenter()
13
+ }
14
+ configurations {
15
+ provided
16
+ }
17
+
18
+ version = "0.1.0"
19
+
20
+ compileJava.options.encoding = 'UTF-8' // source encoding
21
+ sourceCompatibility = 1.7
22
+ targetCompatibility = 1.7
23
+
24
+ dependencies {
25
+ compile "org.embulk:embulk-core:0.7.10"
26
+ provided "org.embulk:embulk-core:0.7.10"
27
+
28
+ testCompile "junit:junit:4.+"
29
+ testCompile "org.embulk:embulk-standards:0.7.10"
30
+ testCompile "org.embulk:embulk-core:0.7.10:tests"
31
+ testCompile "org.mockito:mockito-core:1.9.5"
32
+ }
33
+
34
+ task classpath(type: Copy, dependsOn: ["jar"]) {
35
+ doFirst { file("classpath").deleteDir() }
36
+ from (configurations.runtime - configurations.provided + files(jar.archivePath))
37
+ into "classpath"
38
+ }
39
+ clean { delete "classpath" }
40
+
41
+ task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
42
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
43
+ script "${project.name}.gemspec"
44
+ doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
45
+ }
46
+
47
+ task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
48
+ jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
49
+ script "pkg/${project.name}-${project.version}.gem"
50
+ }
51
+
52
+ task "package"(dependsOn: ["gemspec", "classpath"]) << {
53
+ println "> Build succeeded."
54
+ println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
55
+ }
56
+
57
+ task gemspec {
58
+ ext.gemspecFile = file("${project.name}.gemspec")
59
+ inputs.file "build.gradle"
60
+ outputs.file gemspecFile
61
+ doLast { gemspecFile.write($/
62
+ Gem::Specification.new do |spec|
63
+ spec.name = "${project.name}"
64
+ spec.version = "${project.version}"
65
+ spec.authors = ["Muga Nishizawa"]
66
+ spec.summary = %[Add time filter plugin for Embulk]
67
+ spec.description = %[Add time column to the schema]
68
+ spec.email = ["muga.nishizawa@gmail.com"]
69
+ spec.licenses = ["Apache 2.0"]
70
+ spec.homepage = "https://github.com/treasure-data/embulk-filter-add_time"
71
+
72
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
73
+ spec.test_files = spec.files.grep(%r"^(test|spec)/")
74
+ spec.require_paths = ["lib"]
75
+
76
+ spec.add_development_dependency 'bundler', ['~> 1.0']
77
+ spec.add_development_dependency 'rake', ['>= 10.0']
78
+ end
79
+ /$)
80
+ }
81
+ }
82
+ clean { delete "${project.name}.gemspec" }
@@ -0,0 +1,34 @@
1
+ // Checkstyle
2
+ // @see https://docs.gradle.org/2.5/userguide/checkstyle_plugin.html
3
+ apply plugin: 'checkstyle'
4
+ checkstyle {
5
+ ignoreFailures = true
6
+ // @see https://github.com/facebook/presto/blob/master/src/checkstyle/checks.xml
7
+ //configFile = rootProject.file('./checkstyle.xml') // default {project.projectDir}/config/checkstyle/checkstyle.xml
8
+ }
9
+
10
+ // FindBugs
11
+ // @see https://docs.gradle.org/2.5/userguide/findbugs_plugin.html
12
+ apply plugin: 'findbugs'
13
+ findbugs {
14
+ ignoreFailures = true
15
+ }
16
+
17
+ // PMD
18
+ // @see https://docs.gradle.org/2.5/userguide/pmd_plugin.html
19
+ apply plugin: 'pmd'
20
+ tasks.withType(Pmd) {
21
+ ignoreFailures = true
22
+ reports.html.enabled true
23
+ }
24
+
25
+ // JaCoCo
26
+ // @see https://docs.gradle.org/2.5/userguide/jacoco_plugin.html
27
+ apply plugin: 'jacoco'
28
+ jacocoTestReport { // will use td-client v0.6.x
29
+ afterEvaluate {
30
+ classDirectories = files(classDirectories.files.collect {
31
+ fileTree(dir: it, exclude: 'com/treasuredata/api/**')
32
+ })
33
+ }
34
+ }
@@ -0,0 +1,6 @@
1
+ #Tue Aug 11 00:26:20 PDT 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.6-bin.zip
data/gradlew ADDED
@@ -0,0 +1,164 @@
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 "$@"