├── .gitignore
├── .gradle
├── 5.2.1
│ ├── gc.properties
│ ├── fileChanges
│ │ └── last-build.bin
│ ├── fileHashes
│ │ ├── fileHashes.bin
│ │ └── fileHashes.lock
│ └── executionHistory
│ │ ├── executionHistory.bin
│ │ └── executionHistory.lock
├── vcs-1
│ └── gc.properties
└── buildOutputCleanup
│ ├── cache.properties
│ ├── outputFiles.bin
│ └── buildOutputCleanup.lock
├── .idea
├── .name
├── .gitignore
├── codeStyles
│ ├── codeStyleConfig.xml
│ └── Project.xml
├── vcs.xml
├── compiler.xml
├── misc.xml
├── kotlinScripting.xml
├── gradle.xml
├── jarRepositories.xml
└── modules
│ ├── KotlinNativeGTKHelloWorld.commonTest.iml
│ ├── KotlinNativeGTKHelloWorld.commonMain.iml
│ ├── KotlinNativeGTKHelloWorld.gtkTest.iml
│ └── KotlinNativeGTKHelloWorld.gtkMain.iml
├── settings.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── src
├── nativeInterop
│ └── cinterop
│ │ ├── interop.def
│ │ ├── libcurl.def
│ │ └── gtk3.def
└── gtkMain
│ └── kotlin
│ ├── Main.kt
│ └── FirstWindow.kt
├── README.md
├── gradlew.bat
└── gradlew
/.gitignore:
--------------------------------------------------------------------------------
1 | /build/
2 |
--------------------------------------------------------------------------------
/.gradle/5.2.1/gc.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gradle/vcs-1/gc.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | KotlinNativeGTKHelloWorld
--------------------------------------------------------------------------------
/.gradle/5.2.1/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'KotlinNativeGTKHelloWorld'
2 |
3 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin.code.style=official
2 | org.jetbrains.kotlin.native.jvmArgs=-Xmx8g
3 |
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/cache.properties:
--------------------------------------------------------------------------------
1 | #Sat Sep 05 17:01:43 CEST 2020
2 | gradle.version=6.0
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KotlinNativeGTKHelloWorld/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gradle/5.2.1/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KotlinNativeGTKHelloWorld/master/.gradle/5.2.1/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/5.2.1/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KotlinNativeGTKHelloWorld/master/.gradle/5.2.1/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/outputFiles.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KotlinNativeGTKHelloWorld/master/.gradle/buildOutputCleanup/outputFiles.bin
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/buildOutputCleanup.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KotlinNativeGTKHelloWorld/master/.gradle/buildOutputCleanup/buildOutputCleanup.lock
--------------------------------------------------------------------------------
/.gradle/5.2.1/executionHistory/executionHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KotlinNativeGTKHelloWorld/master/.gradle/5.2.1/executionHistory/executionHistory.bin
--------------------------------------------------------------------------------
/.gradle/5.2.1/executionHistory/executionHistory.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KotlinNativeGTKHelloWorld/master/.gradle/5.2.1/executionHistory/executionHistory.lock
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/nativeInterop/cinterop/interop.def:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | int myFun(int i) {
4 | return i+1;
5 | }
6 |
7 | typedef int (*MyFun)(int);
8 |
9 | void accept_fun(MyFun f) {
10 | f(42);
11 | }
12 |
13 | MyFun supply_fun() {
14 | return myFun;
15 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/src/nativeInterop/cinterop/libcurl.def:
--------------------------------------------------------------------------------
1 | headers = curl/curl.h
2 | headerFilter = curl/*
3 | linkerOpts.osx = -L/opt/local/lib -L/usr/local/opt/curl/lib -lcurl
4 | linkerOpts.linux = -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lcurl
5 | linkerOpts.mingw = -lcurl
6 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/kotlinScripting.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 2147483647
6 | true
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/nativeInterop/cinterop/gtk3.def:
--------------------------------------------------------------------------------
1 | headers = gtk/gtk.h
2 | headerFilter = gtk/* gobject/* gio/*
3 | compilerOpts.osx = -I/usr/local/include/gtk-3.0 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include \
4 | -I/usr/local/include/pango-1.0 -I/usr/local/include/cairo -I/usr/local/include -I/usr/local/include/gdk-pixbuf-2.0 \
5 | -I/usr/local/include/atk-1.0
6 | compilerOpts.linux = -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/lib/glib-2.0/include -I/usr/lib64/glib-2.0/include
7 | linkerOpts.osx = -L/opt/local/lib -L/usr/local/lib -lglib-2.0 -lgdk-3.0 -lgtk-3 -lgio-2.0 -lgobject-2.0
8 | linkerOpts.linux = -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lglib-2.0 -lgdk-3 -lgtk-3 -lgio-2.0 -lgobject-2.0
9 | linkerOpts.mingw = -lglib-2.0 -lgdk-3 -lgtk-3 -lgio-2.0 -lgobject-2.0
10 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/gtkMain/kotlin/Main.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
3 | * that can be found in the license/LICENSE.txt file.
4 | */
5 |
6 | package sample.gtk
7 |
8 | import kotlinx.cinterop.*
9 | import gtk3.*
10 | import interop.myFun
11 | import interop.supply_fun
12 | import libcurl.*
13 |
14 |
15 |
16 | fun gtkMain(args: Array): Int {
17 | val app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE)!!
18 | g_signal_connect(app, "activate", staticCFunction {app: CPointer?, user_data: gpointer? ->FirstWindow(app, user_data).activate() })
19 | val status = memScoped {
20 | g_application_run(app.reinterpret(),
21 | args.size, args.map { it.cstr.ptr }.toCValues())
22 | }
23 | g_object_unref(app)
24 | return status
25 | }
26 |
27 | fun main(args: Array) {
28 | println(myFun(4))
29 | gtkMain(args)
30 | val useMe = supply_fun()
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GTK application
2 |
3 | This example shows how one may use _Kotlin/Native_ to build GUI
4 | applications with the GTK toolkit.
5 |
6 | To build use `../gradlew assemble`.
7 |
8 | Do not forget to install GTK3. See bellow.
9 |
10 | To run on Mac also install XQuartz X server (https://www.xquartz.org/), and then `../gradlew runReleaseExecutableGtk` or execute the program directly:
11 |
12 | ./build/bin/gtk/main/release/executable/gtk.kexe
13 |
14 | Dialog box with the button will be shown, and application will print message
15 | and terminate on button click.
16 |
17 |
18 | #### GTK3 Install
19 |
20 | on Mac use
21 |
22 | brew install gtk+3
23 |
24 | or
25 |
26 | port install gtk3
27 |
28 | on Debian flavours of Linux
29 |
30 | sudo apt-get install libgtk-3-dev
31 |
32 | on Fedora
33 |
34 | sudo dnf install gtk3-devel
35 |
36 | on Windows in MinGW64 console, if you do
37 | not have MSYS2-MinGW64 installed - install it first as described in http://www.msys2.org
38 |
39 | pacman -S mingw-w64-x86_64-gtk3
40 |
--------------------------------------------------------------------------------
/.idea/modules/KotlinNativeGTKHelloWorld.commonTest.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | SOURCE_SET_HOLDER
7 |
8 | gtkTest|KotlinNativeGTKHelloWorld:gtkTest|gtk
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/modules/KotlinNativeGTKHelloWorld.commonMain.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | SOURCE_SET_HOLDER
7 |
8 | runDebugExecutableGtk|KotlinNativeGTKHelloWorld:gtkMain|gtk|sample.gtk.main|true
9 | runReleaseExecutableGtk|KotlinNativeGTKHelloWorld:gtkMain|gtk|sample.gtk.main|false
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.idea/modules/KotlinNativeGTKHelloWorld.gtkTest.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | KotlinNativeGTKHelloWorld:commonTest
7 |
8 | KotlinNativeGTKHelloWorld.gtkMain
9 | KotlinNativeGTKHelloWorld.commonTest
10 | KotlinNativeGTKHelloWorld.commonMain
11 |
12 | COMPILATION_AND_SOURCE_SET_HOLDER
13 |
14 | gtkTest|KotlinNativeGTKHelloWorld:gtkTest|gtk
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/modules/KotlinNativeGTKHelloWorld.gtkMain.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | KotlinNativeGTKHelloWorld:commonMain
7 |
8 | KotlinNativeGTKHelloWorld.commonMain
9 |
10 | COMPILATION_AND_SOURCE_SET_HOLDER
11 |
12 | runDebugExecutableGtk|KotlinNativeGTKHelloWorld:gtkMain|gtk|sample.gtk.main|true
13 | runReleaseExecutableGtk|KotlinNativeGTKHelloWorld:gtkMain|gtk|sample.gtk.main|false
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS="-Xmx64m"
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/src/gtkMain/kotlin/FirstWindow.kt:
--------------------------------------------------------------------------------
1 | package sample.gtk
2 |
3 | import gtk3.*
4 | import kotlinx.cinterop.CFunction
5 | import kotlinx.cinterop.CPointer
6 | import kotlinx.cinterop.reinterpret
7 | import kotlinx.cinterop.staticCFunction
8 |
9 | // Note that all callback parameters must be primitive types or nullable C pointers.
10 | fun > g_signal_connect(
11 | obj: CPointer<*>, actionName: String,
12 | action: CPointer, data: gpointer? = null, connect_flags: GConnectFlags = 0u
13 | ) {
14 | g_signal_connect_data(
15 | obj.reinterpret(), actionName, action.reinterpret(),
16 | data = data, destroy_data = null, connect_flags = connect_flags
17 | )
18 |
19 | }
20 |
21 |
22 | interface Contract{
23 | interface View{
24 | fun closeView(widget: CPointer?)
25 | }
26 | interface Presenter{
27 | fun onCreate()
28 | fun onButtonClicked(widget: CPointer?)
29 | }
30 | }
31 |
32 | class MyPresenter(val view: Contract.View):Contract.Presenter{
33 | override fun onCreate() {
34 |
35 | }
36 |
37 | override fun onButtonClicked(widget: CPointer?) {
38 | view.closeView(widget)
39 |
40 | }
41 |
42 | }
43 |
44 |
45 | class FirstWindow(val app: CPointer?, val user_data: gpointer?) : Contract.View {
46 |
47 | val presenter : Contract.Presenter = MyPresenter(this)
48 |
49 | fun activate() {
50 | val windowWidget = gtk_application_window_new(app)!!
51 | val window = windowWidget.reinterpret()
52 | gtk_window_set_title(window, "Window")
53 | gtk_window_set_default_size(window, 200, 200)
54 |
55 | val button_box = gtk_button_box_new(
56 | GtkOrientation.GTK_ORIENTATION_HORIZONTAL
57 | )!!
58 | gtk_container_add(window.reinterpret(), button_box)
59 |
60 | val button = gtk_button_new_with_label("Hello World: clic k me!")!!
61 |
62 |
63 | g_signal_connect(
64 | button, "clicked",
65 | staticCFunction { widget: CPointer? ->
66 | gtk_widget_destroy(widget)
67 | // presenter.onButtonClicked(widget)
68 | },
69 | window, G_CONNECT_SWAPPED
70 | )
71 | gtk_container_add(button_box.reinterpret(), button)
72 |
73 |
74 | gtk_widget_show_all(windowWidget)
75 | presenter.onCreate()
76 | }
77 |
78 |
79 |
80 | override fun closeView(widget: CPointer?) {
81 | gtk_widget_destroy(widget)
82 | }
83 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
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='"-Xmx64m"'
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 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
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 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------