diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
index 740c2ee9..c5c1754f 100644
--- a/.github/workflows/android.yml
+++ b/.github/workflows/android.yml
@@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - name: set up JDK 11
- uses: actions/setup-java@v3
+ - uses: actions/checkout@v4
+ - name: set up JDK 17
+ uses: actions/setup-java@v4
with:
- java-version: '11'
+ java-version: '17'
distribution: 'temurin'
cache: gradle
diff --git a/app/build.gradle b/app/build.gradle
index a579c94a..6aefcc6e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,12 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 33
+ namespace = "com.hewgill.android.nzsldict"
+ compileSdk 36
defaultConfig {
applicationId "com.hewgill.android.nzsldict"
- minSdkVersion 14
- targetSdkVersion 33
+ minSdk 23
+ targetSdk 36
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionCode 47
versionName "47"
@@ -15,31 +16,26 @@ android {
buildTypes {
release {
minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}
beta {
minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
versionNameSuffix "-beta"
}
}
-
- dependencies {
- implementation 'com.google.android.material:material:1.1.0'
- implementation 'io.github.inflationx:calligraphy3:3.1.1'
- implementation 'io.github.inflationx:viewpump:2.1.1'
- androidTestImplementation 'androidx.test:core:1.6.1'
- androidTestImplementation 'androidx.test.ext:junit:1.2.1'
- androidTestImplementation 'androidx.test:runner:1.6.2'
- androidTestImplementation 'androidx.test:rules:1.6.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
- androidTestImplementation 'androidx.test.espresso:espresso-web:3.6.1'
- androidTestImplementation 'androidx.test.espresso:espresso-intents:3.6.1'
- }
}
dependencies {
- implementation 'com.google.android.material:material:1.1.0'
+ implementation 'com.google.android.material:material:1.14.0'
+ implementation 'io.github.inflationx:calligraphy3:3.1.1'
+ implementation 'io.github.inflationx:viewpump:2.1.1'
+ androidTestImplementation 'androidx.test:core:1.7.0'
+ androidTestImplementation 'androidx.test.ext:junit:1.3.0'
+ androidTestImplementation 'androidx.test:runner:1.7.0'
+ androidTestImplementation 'androidx.test:rules:1.7.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-web:3.7.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-intents:3.7.0'
}
-
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2187a5a2..ac86044a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,7 +1,6 @@
@@ -30,9 +29,7 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/java/com/hewgill/android/nzsldict/Application.java b/app/src/main/java/com/hewgill/android/nzsldict/Application.java
index aedf2087..82e93607 100644
--- a/app/src/main/java/com/hewgill/android/nzsldict/Application.java
+++ b/app/src/main/java/com/hewgill/android/nzsldict/Application.java
@@ -12,7 +12,7 @@ public void onCreate() {
.addInterceptor(new CalligraphyInterceptor(
new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Montserrat-Regular.ttf")
- .setFontAttrId(R.attr.fontPath)
+ .setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
.build()))
.build());
}
diff --git a/app/src/main/java/com/hewgill/android/nzsldict/BaseActivity.java b/app/src/main/java/com/hewgill/android/nzsldict/BaseActivity.java
index aa1966da..a4e547ec 100644
--- a/app/src/main/java/com/hewgill/android/nzsldict/BaseActivity.java
+++ b/app/src/main/java/com/hewgill/android/nzsldict/BaseActivity.java
@@ -1,11 +1,16 @@
package com.hewgill.android.nzsldict;
+import android.app.Activity;
import android.content.Context;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
+import androidx.core.graphics.Insets;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.WindowInsetsCompat;
import android.content.Intent;
import android.view.MenuItem;
+import android.view.View;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
@@ -20,19 +25,39 @@ protected void setupAppToolbar() {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
+ applySystemBarInsets(this);
+ }
+
+ /**
+ * Apps targeting API 35+ draw edge-to-edge. Push the toolbar below the status bar (so its
+ * background extends behind it) and keep the content clear of the navigation bar, display
+ * cutouts and the keyboard. Call after setContentView, for layouts that include R.layout.toolbar.
+ */
+ static void applySystemBarInsets(Activity activity) {
+ View content = activity.findViewById(android.R.id.content);
+ View toolbar = activity.findViewById(R.id.app_toolbar);
+ int toolbarPaddingTop = toolbar.getPaddingTop();
+ ViewCompat.setOnApplyWindowInsetsListener(content, (view, windowInsets) -> {
+ Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()
+ | WindowInsetsCompat.Type.displayCutout()
+ | WindowInsetsCompat.Type.ime());
+ view.setPadding(insets.left, 0, insets.right, insets.bottom);
+ toolbar.setPadding(toolbar.getPaddingLeft(), toolbarPaddingTop + insets.top,
+ toolbar.getPaddingRight(), toolbar.getPaddingBottom());
+ return WindowInsetsCompat.CONSUMED;
+ });
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- // Respond to the toolbar's NavigationIcon as up/home button
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_favourites:
- startActivity(new Intent(this, FavouritesActivity.class));
- break;
+ int itemId = item.getItemId();
+ // Respond to the toolbar's NavigationIcon as up/home button
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_favourites) {
+ startActivity(new Intent(this, FavouritesActivity.class));
}
return super.onOptionsItemSelected(item);
}
diff --git a/app/src/main/java/com/hewgill/android/nzsldict/DownloadReceiver.java b/app/src/main/java/com/hewgill/android/nzsldict/DownloadReceiver.java
index efbf1de3..43582b7c 100644
--- a/app/src/main/java/com/hewgill/android/nzsldict/DownloadReceiver.java
+++ b/app/src/main/java/com/hewgill/android/nzsldict/DownloadReceiver.java
@@ -9,6 +9,8 @@
import android.net.NetworkInfo;
import android.widget.Toast;
+import androidx.core.content.ContextCompat;
+
public class DownloadReceiver {
private DownloadCallback callback;
@@ -36,7 +38,8 @@ public void registerContext(Context context, DownloadCallback callback) {
IntentFilter filter = new IntentFilter();
filter.addAction(DownloadManager.ACTION_NOTIFICATION_CLICKED);
filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
- context.registerReceiver(receiver, filter);
+ // DownloadManager sends these broadcasts from another app, so the receiver must be exported.
+ ContextCompat.registerReceiver(context, receiver, filter, ContextCompat.RECEIVER_EXPORTED);
}
public void unregisterContext(Context context) {
diff --git a/app/src/main/java/com/hewgill/android/nzsldict/FavouritesActivity.java b/app/src/main/java/com/hewgill/android/nzsldict/FavouritesActivity.java
index e7163cac..793ceb5d 100644
--- a/app/src/main/java/com/hewgill/android/nzsldict/FavouritesActivity.java
+++ b/app/src/main/java/com/hewgill/android/nzsldict/FavouritesActivity.java
@@ -39,9 +39,9 @@ public class FavouritesActivity extends BaseActivity implements DictionaryAdapte
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- getSupportActionBar().setTitle("Favourites");
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_favourites);
+ setupAppToolbar();
+ getSupportActionBar().setTitle("Favourites");
mListView = (ListView) findViewById(R.id.favourites);
repo = new FavouritesRepository(this);
adapter = new DictionaryAdapter(R.layout.list_item, this, repo.all());
@@ -79,13 +79,11 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_favourites_clear:
- clearFavourites();
- break;
- case R.id.action_favourites_download:
- enqueueFavouritesDownload();
- break;
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_favourites_clear) {
+ clearFavourites();
+ } else if (itemId == R.id.action_favourites_download) {
+ enqueueFavouritesDownload();
}
invalidateOptionsMenu();
diff --git a/app/src/main/java/com/hewgill/android/nzsldict/NZSLDictionary.java b/app/src/main/java/com/hewgill/android/nzsldict/NZSLDictionary.java
index c5379d63..7b7903a9 100644
--- a/app/src/main/java/com/hewgill/android/nzsldict/NZSLDictionary.java
+++ b/app/src/main/java/com/hewgill/android/nzsldict/NZSLDictionary.java
@@ -243,6 +243,7 @@ public void onCreate(Bundle savedInstanceState) {
mSearchResultsList.setOnItemClickListener(this);
mToolbar = (Toolbar) findViewById(R.id.app_toolbar);
setSupportActionBar(mToolbar);
+ BaseActivity.applySystemBarInsets(this);
View header = LayoutInflater.from(this).inflate(R.layout.handshape, null);
getListView().addHeaderView(header, null, false);
@@ -381,24 +382,21 @@ public boolean onPrepareOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_search_mode_handshape:
- filterText.setText("(handshape search)");
- filterText.setEnabled(false);
- filterTextContainer.setVisibility(View.GONE);
- handshapeHeader.setVisibility(View.VISIBLE);
- updateHandshapeList();
- break;
- case R.id.action_search_mode_keyword:
- filterText.setText("");
- filterText.setEnabled(true);
- filterTextContainer.setVisibility(View.VISIBLE);
- handshapeHeader.setVisibility(View.GONE);
- adapter.getFilter().filter(null);
- break;
- case R.id.action_favourites:
- startActivity(new Intent(this, FavouritesActivity.class));
- break;
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_search_mode_handshape) {
+ filterText.setText("(handshape search)");
+ filterText.setEnabled(false);
+ filterTextContainer.setVisibility(View.GONE);
+ handshapeHeader.setVisibility(View.VISIBLE);
+ updateHandshapeList();
+ } else if (itemId == R.id.action_search_mode_keyword) {
+ filterText.setText("");
+ filterText.setEnabled(true);
+ filterTextContainer.setVisibility(View.VISIBLE);
+ handshapeHeader.setVisibility(View.GONE);
+ adapter.getFilter().filter(null);
+ } else if (itemId == R.id.action_favourites) {
+ startActivity(new Intent(this, FavouritesActivity.class));
}
invalidateOptionsMenu();
diff --git a/app/src/main/java/com/hewgill/android/nzsldict/NetworkManager.java b/app/src/main/java/com/hewgill/android/nzsldict/NetworkManager.java
index 9af5f530..f080920a 100644
--- a/app/src/main/java/com/hewgill/android/nzsldict/NetworkManager.java
+++ b/app/src/main/java/com/hewgill/android/nzsldict/NetworkManager.java
@@ -7,6 +7,8 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import androidx.core.content.ContextCompat;
+
public class NetworkManager {
protected boolean connected;
@@ -32,7 +34,7 @@ private void updateStatus(Context context) {
public void registerContext(Context context, NetworkCallback callback) {
this.callback = callback;
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
- context.registerReceiver(receiver, filter);
+ ContextCompat.registerReceiver(context, receiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED);
updateStatus(context);
}
diff --git a/app/src/main/res/layout/activity_favourites.xml b/app/src/main/res/layout/activity_favourites.xml
index 3339c714..fb206ae7 100644
--- a/app/src/main/res/layout/activity_favourites.xml
+++ b/app/src/main/res/layout/activity_favourites.xml
@@ -6,6 +6,14 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
+
+
\ No newline at end of file
+ app:tint="@color/accent" />
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index c8bf7f6f..a42abf49 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -11,26 +11,4 @@
- @android:color/white
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index d90e3593..fdf6764f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,19 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
- jcenter()
google()
+ mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.2.2'
+ classpath 'com.android.tools.build:gradle:9.5.0'
}
}
allprojects {
repositories {
- jcenter()
google()
+ mavenCentral()
}
}
-
-
diff --git a/gradle.properties b/gradle.properties
index dbb7bf70..5bac8ac5 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1 @@
-android.enableJetifier=true
android.useAndroidX=true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e708b1c0..9fa7f288 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index c51cbf17..988da1ab 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip
+networkTimeout=10000
+retries=0
+retryBackOffMs=500
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 1b6c7873..249efbb0 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,10 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
#
-# Gradle start up script for POSIX generated by Gradle.
+# gradlew start up script for POSIX generated by Gradle.
#
# Important for running:
#
@@ -27,7 +29,7 @@
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
-# ksh Gradle
+# ksh gradlew
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +82,11 @@ do
esac
done
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-APP_NAME="Gradle"
+# This is normally unused
+# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -114,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -133,22 +132,29 @@ location of your Java installation."
fi
else
JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -165,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -193,18 +198,27 @@ if "$cygwin" || "$msys" ; then
done
fi
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- org.gradle.wrapper.GradleWrapperMain \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
diff --git a/gradlew.bat b/gradlew.bat
index ac1b06f9..03754c4c 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -13,19 +13,49 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
-@if "%DEBUG%" == "" @echo off
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
-@rem Gradle startup script for Windows
+@rem gradlew startup script for Windows
@rem
@rem ##########################################################################
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
+@rem Set local scope for the variables, and ensure extensions are enabled
+setlocal EnableExtensions
+
+@rem Catch executions from older scripts and ensure they exit cleanly.
+@rem This can be removed once we can be reasonably confident that few people
+@rem will be migrating directly to this new wrapper.
+goto afterSafetyNet
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+goto exitWithErrorLevel
+:afterSafetyNet
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,15 +70,16 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
+if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+1>&2 echo.
+1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+1>&2 echo.
+1>&2 echo Please set the JAVA_HOME variable in your environment to match the
+1>&2 echo location of your Java installation.
-goto fail
+"%COMSPEC%" /c exit 1
+goto exitWithErrorLevel
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -56,34 +87,26 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+1>&2 echo.
+1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+1>&2 echo.
+1>&2 echo Please set the JAVA_HOME variable in your environment to match the
+1>&2 echo location of your Java installation.
-goto fail
+"%COMSPEC%" /c exit 1
+goto exitWithErrorLevel
:execute
@rem Setup the command line
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
+@rem Execute gradlew
+@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
+@rem which allows us to clear the local environment before executing the java command
+endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel
-:omega
+@rem This label must not be changed. We rely on old scripts being able to jump to this point.
+:exitWithErrorLevel
+@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
+"%COMSPEC%" /c exit %ERRORLEVEL%