Skip to content

Commit 5f2c89c

Browse files
jiangzhodongjoon-hyun
authored andcommitted
[SPARK-47889] Setup gradle as build tool for operator repository
This is a breakdown from #2 : set up [gradle](https://gradle.org/) as the build-tool for operator Closes #4 from jiangzho/gradle. Authored-by: zhou-jiang <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 7a3a7e8 commit 5f2c89c

File tree

6 files changed

+310
-0
lines changed

6 files changed

+310
-0
lines changed

.github/.licenserc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ header:
1414
- 'LICENSE'
1515
- 'NOTICE'
1616
- '.asf.yaml'
17+
- '**/*.gradle'
1718

1819
comment: on-failure

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,13 @@
66
.vscode
77
/lib/
88
target/
9+
10+
# Gradle Files #
11+
################
12+
.gradle
13+
.m2
14+
.out/
15+
build
16+
dependencies.lock
17+
**/dependencies.lock
18+
gradle/wrapper/gradle-wrapper.jar

LICENSE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,13 @@
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202+
203+
--------------------------------------------------------------------------------
204+
205+
This product includes a gradle wrapper.
206+
207+
* gradlew and gradle/wrapper/gradle-wrapper.properties
208+
209+
Copyright: 2015-2021 Gradle Authors.
210+
Home page: https://github.com/gradle/gradle
211+
License: https://www.apache.org/licenses/LICENSE-2.0

build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
subprojects {
2+
apply plugin: 'idea'
3+
apply plugin: 'eclipse'
4+
apply plugin: 'java'
5+
sourceCompatibility = 17
6+
targetCompatibility = 17
7+
8+
repositories {
9+
mavenCentral()
10+
jcenter()
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
distributionBase=GRADLE_USER_HOME
19+
distributionPath=wrapper/dists
20+
distributionSha256Sum=194717442575a6f96e1c1befa2c30e9a4fc90f701d7aee33eb879b79e7ff05c0
21+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
22+
networkTimeout=10000
23+
zipStoreBase=GRADLE_USER_HOME
24+
zipStorePath=wrapper/dists

gradlew

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
#!/bin/sh
2+
3+
#
4+
# Copyright © 2015-2021 the original authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
##############################################################################
20+
#
21+
# Gradle start up script for POSIX generated by Gradle.
22+
#
23+
# Important for running:
24+
#
25+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26+
# noncompliant, but you have some other compliant shell such as ksh or
27+
# bash, then to run this script, type that shell name before the whole
28+
# command line, like:
29+
#
30+
# ksh Gradle
31+
#
32+
# Busybox and similar reduced shells will NOT work, because this script
33+
# requires all of these POSIX shell features:
34+
# * functions;
35+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37+
# * compound commands having a testable exit status, especially «case»;
38+
# * various built-in commands including «command», «set», and «ulimit».
39+
#
40+
# Important for patching:
41+
#
42+
# (2) This script targets any POSIX shell, so it avoids extensions provided
43+
# by Bash, Ksh, etc; in particular arrays are avoided.
44+
#
45+
# The "traditional" practice of packing multiple parameters into a
46+
# space-separated string is a well documented source of bugs and security
47+
# problems, so this is (mostly) avoided, by progressively accumulating
48+
# options in "$@", and eventually passing that to Java.
49+
#
50+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52+
# see the in-line comments for details.
53+
#
54+
# There are tweaks for specific operating systems such as AIX, CygWin,
55+
# Darwin, MinGW, and NonStop.
56+
#
57+
# (3) This script is generated from the Groovy template
58+
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59+
# within the Gradle project.
60+
#
61+
# You can find Gradle at https://github.com/gradle/gradle/.
62+
#
63+
##############################################################################
64+
65+
# Attempt to set APP_HOME
66+
67+
# Resolve links: $0 may be a link
68+
app_path=$0
69+
70+
# Need this for daisy-chained symlinks.
71+
while
72+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73+
[ -h "$app_path" ]
74+
do
75+
ls=$( ls -ld "$app_path" )
76+
link=${ls#*' -> '}
77+
case $link in #(
78+
/*) app_path=$link ;; #(
79+
*) app_path=$APP_HOME$link ;;
80+
esac
81+
done
82+
83+
# This is normally unused
84+
# shellcheck disable=SC2034
85+
APP_BASE_NAME=${0##*/}
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
88+
89+
if [ ! -e $APP_HOME/gradle/wrapper/gradle-wrapper.jar ]; then
90+
curl -o $APP_HOME/gradle/wrapper/gradle-wrapper.jar https://raw.githubusercontent.com/gradle/gradle/v8.7.0/gradle/wrapper/gradle-wrapper.jar
91+
fi
92+
93+
# Use the maximum available, or set MAX_FD != -1 to use that value.
94+
MAX_FD=maximum
95+
96+
warn () {
97+
echo "$*"
98+
} >&2
99+
100+
die () {
101+
echo
102+
echo "$*"
103+
echo
104+
exit 1
105+
} >&2
106+
107+
# OS specific support (must be 'true' or 'false').
108+
cygwin=false
109+
msys=false
110+
darwin=false
111+
nonstop=false
112+
case "$( uname )" in #(
113+
CYGWIN* ) cygwin=true ;; #(
114+
Darwin* ) darwin=true ;; #(
115+
MSYS* | MINGW* ) msys=true ;; #(
116+
NONSTOP* ) nonstop=true ;;
117+
esac
118+
119+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
120+
121+
122+
# Determine the Java command to use to start the JVM.
123+
if [ -n "$JAVA_HOME" ] ; then
124+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
125+
# IBM's JDK on AIX uses strange locations for the executables
126+
JAVACMD=$JAVA_HOME/jre/sh/java
127+
else
128+
JAVACMD=$JAVA_HOME/bin/java
129+
fi
130+
if [ ! -x "$JAVACMD" ] ; then
131+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
132+
133+
Please set the JAVA_HOME variable in your environment to match the
134+
location of your Java installation."
135+
fi
136+
else
137+
JAVACMD=java
138+
if ! command -v java >/dev/null 2>&1
139+
then
140+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
141+
142+
Please set the JAVA_HOME variable in your environment to match the
143+
location of your Java installation."
144+
fi
145+
fi
146+
147+
# Increase the maximum file descriptors if we can.
148+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
149+
case $MAX_FD in #(
150+
max*)
151+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
152+
# shellcheck disable=SC2039,SC3045
153+
MAX_FD=$( ulimit -H -n ) ||
154+
warn "Could not query maximum file descriptor limit"
155+
esac
156+
case $MAX_FD in #(
157+
'' | soft) :;; #(
158+
*)
159+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
160+
# shellcheck disable=SC2039,SC3045
161+
ulimit -n "$MAX_FD" ||
162+
warn "Could not set maximum file descriptor limit to $MAX_FD"
163+
esac
164+
fi
165+
166+
# Collect all arguments for the java command, stacking in reverse order:
167+
# * args from the command line
168+
# * the main class name
169+
# * -classpath
170+
# * -D...appname settings
171+
# * --module-path (only if needed)
172+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
173+
174+
# For Cygwin or MSYS, switch paths to Windows format before running java
175+
if "$cygwin" || "$msys" ; then
176+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
177+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
178+
179+
JAVACMD=$( cygpath --unix "$JAVACMD" )
180+
181+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
182+
for arg do
183+
if
184+
case $arg in #(
185+
-*) false ;; # don't mess with options #(
186+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
187+
[ -e "$t" ] ;; #(
188+
*) false ;;
189+
esac
190+
then
191+
arg=$( cygpath --path --ignore --mixed "$arg" )
192+
fi
193+
# Roll the args list around exactly as many times as the number of
194+
# args, so each arg winds up back in the position where it started, but
195+
# possibly modified.
196+
#
197+
# NB: a `for` loop captures its iteration list before it begins, so
198+
# changing the positional parameters here affects neither the number of
199+
# iterations, nor the values presented in `arg`.
200+
shift # remove old arg
201+
set -- "$@" "$arg" # push replacement arg
202+
done
203+
fi
204+
205+
206+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
207+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
208+
209+
# Collect all arguments for the java command:
210+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
211+
# and any embedded shellness will be escaped.
212+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
213+
# treated as '${Hostname}' itself on the command line.
214+
215+
set -- \
216+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
217+
-classpath "$CLASSPATH" \
218+
org.gradle.wrapper.GradleWrapperMain \
219+
"$@"
220+
221+
# Stop when "xargs" is not available.
222+
if ! command -v xargs >/dev/null 2>&1
223+
then
224+
die "xargs is not available"
225+
fi
226+
227+
# Use "xargs" to parse quoted args.
228+
#
229+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
230+
#
231+
# In Bash we could simply go:
232+
#
233+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
234+
# set -- "${ARGS[@]}" "$@"
235+
#
236+
# but POSIX shell has neither arrays nor command substitution, so instead we
237+
# post-process each arg (as a line of input to sed) to backslash-escape any
238+
# character that might be a shell metacharacter, then use eval to reverse
239+
# that process (while maintaining the separation between arguments), and wrap
240+
# the whole thing up as a single "set" statement.
241+
#
242+
# This will of course break if any of these variables contains a newline or
243+
# an unmatched quote.
244+
#
245+
246+
eval "set -- $(
247+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
248+
xargs -n1 |
249+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
250+
tr '\n' ' '
251+
)" '"$@"'
252+
253+
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)