Skip to content

Commit 011c94a

Browse files
committed
Add gradle project to debug jupyter note book java code
1 parent 259f3b1 commit 011c94a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1558
-0
lines changed

debug/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gradle
2+
.idea
3+
build
4+
*.zip
5+
*.jar

debug/build.gradle

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id "java"
3+
id 'idea'
4+
}
5+
6+
group "com.example"
7+
version "1.0-SNAPSHOT"
8+
9+
repositories {
10+
mavenCentral()
11+
mavenLocal()
12+
maven {
13+
url 'https://oss.sonatype.org/content/repositories/snapshots/'
14+
}
15+
}
16+
17+
configure(this) {
18+
sourceCompatibility = JavaVersion.VERSION_11
19+
20+
idea {
21+
module {
22+
outputDir = file('build/classes/java/main')
23+
testOutputDir = file('build/classes/java/test')
24+
// inheritOutputDirs = true
25+
}
26+
}
27+
28+
apply from: file("tools/gradle/java-formatter.gradle")
29+
}
30+
31+
def djl_version = "0.13.0"
32+
33+
dependencies {
34+
implementation platform("ai.djl:bom:${djl_version}")
35+
implementation "ai.djl:basicdataset"
36+
implementation "ai.djl:model-zoo"
37+
38+
implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
39+
40+
implementation "ai.djl.mxnet:mxnet-engine"
41+
implementation "ai.djl.mxnet:mxnet-native-auto"
42+
43+
implementation "ai.djl.pytorch:pytorch-engine"
44+
implementation "ai.djl.pytorch:pytorch-native-auto"
45+
46+
implementation "tech.tablesaw:tablesaw-jsplot:0.38.1"
47+
}

debug/gradle.properties

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
org.gradle.daemon=true
2+
org.gradle.jvmargs=-Xmx1024M
3+
4+
systemProp.org.gradle.internal.http.socketTimeout=120000
5+
systemProp.org.gradle.internal.http.connectionTimeout=60000
6+
7+
# FIXME: Workaround gradle publish issue: https://github.com/gradle/gradle/issues/11308
8+
systemProp.org.gradle.internal.publish.checksums.insecure=true
9+
10+
log4j_slf4j_version=2.14.1

debug/gradle/wrapper/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gradle-wrapper.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.net.*;
21+
import java.io.*;
22+
import java.nio.channels.*;
23+
import java.util.Properties;
24+
25+
public class GradleWrapperDownloader {
26+
27+
/**
28+
* URL to download the gradle-wrapper.jar from.
29+
*/
30+
private static final String DEFAULT_DOWNLOAD_URL =
31+
"https://raw.githubusercontent.com/gradle/gradle/master/gradle/wrapper/gradle-wrapper.jar";
32+
33+
/**
34+
* Path where the gradle-wrapper.jar will be saved to.
35+
*/
36+
private static final String GRADLE_WRAPPER_JAR_PATH =
37+
"gradle/wrapper/gradle-wrapper.jar";
38+
39+
public static void main(String args[]) {
40+
System.out.println("- Downloader started");
41+
File baseDirectory = new File(args[0]);
42+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
43+
44+
String url = DEFAULT_DOWNLOAD_URL;
45+
System.out.println("- Downloading from: : " + url);
46+
47+
File outputFile = new File(baseDirectory.getAbsolutePath(), GRADLE_WRAPPER_JAR_PATH);
48+
if(!outputFile.getParentFile().exists()) {
49+
if(!outputFile.getParentFile().mkdirs()) {
50+
System.out.println(
51+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
52+
}
53+
}
54+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
55+
try {
56+
downloadFileFromURL(url, outputFile);
57+
System.out.println("Done");
58+
System.exit(0);
59+
} catch (Throwable e) {
60+
System.out.println("- Error downloading");
61+
e.printStackTrace();
62+
System.exit(1);
63+
}
64+
}
65+
66+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
67+
URL website = new URL(urlString);
68+
ReadableByteChannel rbc;
69+
rbc = Channels.newChannel(website.openStream());
70+
FileOutputStream fos = new FileOutputStream(destination);
71+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
72+
fos.close();
73+
rbc.close();
74+
}
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Jan 16 22:46:13 PST 2019
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-7.2-bin.zip

debug/gradlew

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
#!/usr/bin/env sh
2+
3+
##############################################################################
4+
##
5+
## Gradle start up script for UN*X
6+
##
7+
##############################################################################
8+
9+
# Attempt to set APP_HOME
10+
# Resolve links: $0 may be a link
11+
PRG="$0"
12+
# Need this for relative symlinks.
13+
while [ -h "$PRG" ] ; do
14+
ls=`ls -ld "$PRG"`
15+
link=`expr "$ls" : '.*-> \(.*\)$'`
16+
if expr "$link" : '/.*' > /dev/null; then
17+
PRG="$link"
18+
else
19+
PRG=`dirname "$PRG"`"/$link"
20+
fi
21+
done
22+
SAVED="`pwd`"
23+
cd "`dirname \"$PRG\"`/" >/dev/null
24+
APP_HOME="`pwd -P`"
25+
cd "$SAVED" >/dev/null
26+
27+
APP_NAME="Gradle"
28+
APP_BASE_NAME=`basename "$0"`
29+
30+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31+
DEFAULT_JVM_OPTS=""
32+
33+
# Use the maximum available, or set MAX_FD != -1 to use that value.
34+
MAX_FD="maximum"
35+
36+
warn () {
37+
echo "$*"
38+
}
39+
40+
die () {
41+
echo
42+
echo "$*"
43+
echo
44+
exit 1
45+
}
46+
47+
# OS specific support (must be 'true' or 'false').
48+
cygwin=false
49+
msys=false
50+
darwin=false
51+
nonstop=false
52+
case "`uname`" in
53+
CYGWIN* )
54+
cygwin=true
55+
;;
56+
Darwin* )
57+
darwin=true
58+
;;
59+
MINGW* )
60+
msys=true
61+
;;
62+
NONSTOP* )
63+
nonstop=true
64+
;;
65+
esac
66+
67+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68+
69+
# Determine the Java command to use to start the JVM.
70+
if [ -n "$JAVA_HOME" ] ; then
71+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72+
# IBM's JDK on AIX uses strange locations for the executables
73+
JAVACMD="$JAVA_HOME/jre/sh/java"
74+
else
75+
JAVACMD="$JAVA_HOME/bin/java"
76+
fi
77+
if [ ! -x "$JAVACMD" ] ; then
78+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79+
80+
Please set the JAVA_HOME variable in your environment to match the
81+
location of your Java installation."
82+
fi
83+
else
84+
JAVACMD="java"
85+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86+
87+
Please set the JAVA_HOME variable in your environment to match the
88+
location of your Java installation."
89+
fi
90+
91+
# Increase the maximum file descriptors if we can.
92+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93+
MAX_FD_LIMIT=`ulimit -H -n`
94+
if [ $? -eq 0 ] ; then
95+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96+
MAX_FD="$MAX_FD_LIMIT"
97+
fi
98+
ulimit -n $MAX_FD
99+
if [ $? -ne 0 ] ; then
100+
warn "Could not set maximum file descriptor limit: $MAX_FD"
101+
fi
102+
else
103+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104+
fi
105+
fi
106+
107+
##########################################################################################
108+
# Extension to allow automatically downloading the gradle-wrapper.jar
109+
# This allows using the maven wrapper in projects that prohibit checking in binary data.
110+
##########################################################################################
111+
WRAPPER_JAR_PATH="$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
112+
if [ ! -r "${WRAPPER_JAR_PATH}" ]; then
113+
jarUrl="https://raw.githubusercontent.com/gradle/gradle/master/gradle/wrapper/gradle-wrapper.jar"
114+
if command -v wget > /dev/null; then
115+
wget -q "${jarUrl}" -O "${WRAPPER_JAR_PATH}"
116+
elif command -v curl > /dev/null; then
117+
curl -s -o "${WRAPPER_JAR_PATH}" "$jarUrl"
118+
else
119+
javaClass="$APP_HOME/gradle/wrapper/GradleWrapperDownloader.java"
120+
if [ -e "$javaClass" ]; then
121+
if [ ! -e "$APP_HOME/gradle/wrapper/GradleWrapperDownloader.class" ]; then
122+
# Compiling the Java class
123+
("$JAVA_HOME/bin/javac" "$javaClass")
124+
fi
125+
if [ -e "$APP_HOME/gradle/wrapper/GradleWrapperDownloader.class" ]; then
126+
("$JAVACMD" -cp gradle/wrapper GradleWrapperDownloader "$APP_HOME")
127+
fi
128+
fi
129+
fi
130+
fi
131+
##########################################################################################
132+
# End of extension
133+
##########################################################################################
134+
135+
136+
# For Darwin, add options to specify how the application appears in the dock
137+
if $darwin; then
138+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
139+
fi
140+
141+
# For Cygwin, switch paths to Windows format before running java
142+
if $cygwin ; then
143+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
144+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
145+
JAVACMD=`cygpath --unix "$JAVACMD"`
146+
147+
# We build the pattern for arguments to be converted via cygpath
148+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
149+
SEP=""
150+
for dir in $ROOTDIRSRAW ; do
151+
ROOTDIRS="$ROOTDIRS$SEP$dir"
152+
SEP="|"
153+
done
154+
OURCYGPATTERN="(^($ROOTDIRS))"
155+
# Add a user-defined pattern to the cygpath arguments
156+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
157+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
158+
fi
159+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
160+
i=0
161+
for arg in "$@" ; do
162+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
163+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
164+
165+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
166+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
167+
else
168+
eval `echo args$i`="\"$arg\""
169+
fi
170+
i=$((i+1))
171+
done
172+
case $i in
173+
(0) set -- ;;
174+
(1) set -- "$args0" ;;
175+
(2) set -- "$args0" "$args1" ;;
176+
(3) set -- "$args0" "$args1" "$args2" ;;
177+
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
178+
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
179+
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
180+
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
181+
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
182+
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
183+
esac
184+
fi
185+
186+
# Escape application args
187+
save () {
188+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
189+
echo " "
190+
}
191+
APP_ARGS=$(save "$@")
192+
193+
# Collect all arguments for the java command, following the shell quoting and substitution rules
194+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
195+
196+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
197+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
198+
cd "$(dirname "$0")"
199+
fi
200+
201+
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)