diff --git a/.github/scripts/emu_setup.sh b/.github/scripts/emu_setup.sh index a416d22..ead90f1 100755 --- a/.github/scripts/emu_setup.sh +++ b/.github/scripts/emu_setup.sh @@ -1,16 +1,7 @@ #!/bin/bash +adb wait-for-devices + echo "Cleaning up old emulator data" adb uninstall com.dropbox.dropshots.test || true adb shell rm -rf /storage/emulated/0/Download/screenshots || true - -adb wait-for-devices -adb shell settings put global sysui_demo_allowed 1 -adb shell am broadcast -a com.android.systemui.demo -e command enter -adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1234 -adb shell am broadcast -a com.android.systemui.demo -e command battery -e plugged false -adb shell am broadcast -a com.android.systemui.demo -e command battery -e level 100 -adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4 -adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype none -e level 4 -adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false -adb shell cmd overlay enable com.android.internal.systemui.navbar.gestural diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fcb8ff8..981bcd1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,25 +11,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1 + uses: gradle/actions/wrapper-validation@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }} - restore-keys: | - ${{ runner.os }}-gradle - - - name: Install JDK 11 - uses: actions/setup-java@v3 + - name: Install JDK 17 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Build run: ./gradlew assemble --stacktrace @@ -39,25 +33,19 @@ jobs: needs: [build] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1 + uses: gradle/actions/wrapper-validation@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }} - restore-keys: | - ${{ runner.os }}-gradle - - - name: Install JDK 11 - uses: actions/setup-java@v3 + - name: Install JDK 17 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Run Tests run: ./gradlew check --no-daemon --stacktrace @@ -68,7 +56,7 @@ jobs: - name: (Fail-only) Upload the build report if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: unit-test-report path: unit-test-build-reports.zip @@ -107,25 +95,19 @@ jobs: sudo udevadm trigger --name-match=kvm - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v2 - - - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }} - restore-keys: | - ${{ runner.os }}-gradle + uses: gradle/actions/wrapper-validation@v4 - - name: Install JDK 11 + - name: Install JDK 17 uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 # Retrieve the cached emulator snapshot. - name: AVD cache @@ -209,7 +191,7 @@ jobs: - name: Upload the build report if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: instrumentation-test-report path: instrumentation-test-build-reports.zip @@ -220,37 +202,24 @@ jobs: needs: [unitTests] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }} - restore-keys: | - ${{ runner.os }}-gradle - - - name: Install JDK 11 - uses: actions/setup-java@v3 + - name: Gradle Wrapper Validation + uses: gradle/actions/wrapper-validation@v4 + + - name: Install JDK 17 + uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Upload Snapshot - run: ./gradlew clean publish -Pdropshots.releaseMode=true --no-daemon --no-parallel --no-configuration-cache --stacktrace + run: ./gradlew publish -Pdropshots.releaseMode=true --no-daemon --no-parallel --no-configuration-cache --stacktrace env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }} ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} - - - name: Retrieve Version - run: echo "VERSION_NAME=$(./gradlew -q :printVersionName)" >> $GITHUB_ENV - - - name: Publish release (main only) - run: ./gradlew closeAndReleaseRepository --no-daemon --no-parallel - if: success() && !endsWith(env.VERSION_NAME, '-SNAPSHOT') - env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/dropshots-gradle-plugin/build.gradle.kts b/dropshots-gradle-plugin/build.gradle.kts index 5aa534d..3db93cb 100644 --- a/dropshots-gradle-plugin/build.gradle.kts +++ b/dropshots-gradle-plugin/build.gradle.kts @@ -70,12 +70,6 @@ tasks.withType().configureEach { } } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - tasks.withType().configureEach { options.release.set(11) } diff --git a/dropshots-gradle-plugin/src/test/projects/configuration-cache-compatible/module/build.gradle b/dropshots-gradle-plugin/src/test/projects/configuration-cache-compatible/module/build.gradle index 99715f5..707f3ee 100644 --- a/dropshots-gradle-plugin/src/test/projects/configuration-cache-compatible/module/build.gradle +++ b/dropshots-gradle-plugin/src/test/projects/configuration-cache-compatible/module/build.gradle @@ -5,12 +5,12 @@ plugins { } android { - namespace = "com.dropbox.dropshots.test.configuration-cache-compatible" - compileSdk = 32 + namespace = "com.dropbox.dropshots.test.configuration_cache_compatible" + compileSdk = 34 defaultConfig { minSdk = 24 - targetSdk = 32 + targetSdk = 34 } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/dropshots-gradle-plugin/src/test/projects/dropshots-before-android-plugin/module/build.gradle b/dropshots-gradle-plugin/src/test/projects/dropshots-before-android-plugin/module/build.gradle index 770cb56..f5f5bbc 100644 --- a/dropshots-gradle-plugin/src/test/projects/dropshots-before-android-plugin/module/build.gradle +++ b/dropshots-gradle-plugin/src/test/projects/dropshots-before-android-plugin/module/build.gradle @@ -5,12 +5,12 @@ plugins { } android { - namespace = "com.dropbox.dropshots.test.configuration-cache-compatible" - compileSdk = 32 + namespace = "com.dropbox.dropshots.test.configuration_cache_compatible" + compileSdk = 34 defaultConfig { minSdk = 24 - targetSdk = 32 + targetSdk = 34 } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/dropshots-gradle-plugin/src/test/projects/prints-res-values/module/build.gradle b/dropshots-gradle-plugin/src/test/projects/prints-res-values/module/build.gradle index 96f9647..e32616d 100644 --- a/dropshots-gradle-plugin/src/test/projects/prints-res-values/module/build.gradle +++ b/dropshots-gradle-plugin/src/test/projects/prints-res-values/module/build.gradle @@ -5,12 +5,12 @@ plugins { } android { - namespace = "com.dropbox.dropshots.test.application-project" - compileSdk = 32 + namespace = "com.dropbox.dropshots.test.application_project" + compileSdk = 34 defaultConfig { minSdk = 24 - targetSdk = 32 + targetSdk = 34 } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/dropshots/api/dropshots.api b/dropshots/api/dropshots.api index b581b08..e551b5e 100644 --- a/dropshots/api/dropshots.api +++ b/dropshots/api/dropshots.api @@ -1,10 +1,3 @@ -public final class com/dropbox/dropshots/BuildConfig { - public static final field BUILD_TYPE Ljava/lang/String; - public static final field DEBUG Z - public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; - public fun ()V -} - public final class com/dropbox/dropshots/Dropshots : org/junit/rules/TestRule { public fun ()V public fun (Lkotlin/jvm/functions/Function1;ZLcom/dropbox/differ/ImageComparator;Lkotlin/jvm/functions/Function1;)V diff --git a/dropshots/build.gradle.kts b/dropshots/build.gradle.kts index ec3c523..3ed0c5e 100644 --- a/dropshots/build.gradle.kts +++ b/dropshots/build.gradle.kts @@ -11,11 +11,12 @@ plugins { android { namespace = "com.dropbox.dropshots" - compileSdk = 32 + compileSdk = 34 + testOptions.targetSdk = 34 + lint.targetSdk = 34 defaultConfig { - minSdk = 19 - targetSdk = 32 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -55,6 +56,7 @@ dependencies { androidTestImplementation(libs.androidx.test.ext.junit) androidTestImplementation(libs.androidx.test.rules) androidTestImplementation(libs.androidx.test.runner) + androidTestImplementation(libs.androidx.test.uiautomator) } mavenPublishing { diff --git a/dropshots/src/androidTest/assets/MatchesActivityScreenshot.png b/dropshots/src/androidTest/assets/MatchesActivityScreenshot.png index 61e0ca5..7fd674a 100644 Binary files a/dropshots/src/androidTest/assets/MatchesActivityScreenshot.png and b/dropshots/src/androidTest/assets/MatchesActivityScreenshot.png differ diff --git a/dropshots/src/androidTest/assets/MatchesFullScreenshot.png b/dropshots/src/androidTest/assets/MatchesFullScreenshot.png index a3b2665..3b9543d 100644 Binary files a/dropshots/src/androidTest/assets/MatchesFullScreenshot.png and b/dropshots/src/androidTest/assets/MatchesFullScreenshot.png differ diff --git a/dropshots/src/androidTest/kotlin/com/dropbox/dropshots/DropshotsTest.kt b/dropshots/src/androidTest/kotlin/com/dropbox/dropshots/DropshotsTest.kt index f25772f..bab0ac4 100644 --- a/dropshots/src/androidTest/kotlin/com/dropbox/dropshots/DropshotsTest.kt +++ b/dropshots/src/androidTest/kotlin/com/dropbox/dropshots/DropshotsTest.kt @@ -18,6 +18,9 @@ class DropshotsTest { private val fakeValidator = FakeResultValidator() private val isRecordingScreenshots = isRecordingScreenshots() + @get:Rule + val emulatorConfigRule = EmulatorConfigRule() + @get:Rule val activityScenarioRule = ActivityScenarioRule(TestActivity::class.java) diff --git a/dropshots/src/androidTest/kotlin/com/dropbox/dropshots/EmulatorConfigRule.kt b/dropshots/src/androidTest/kotlin/com/dropbox/dropshots/EmulatorConfigRule.kt new file mode 100644 index 0000000..fb21b45 --- /dev/null +++ b/dropshots/src/androidTest/kotlin/com/dropbox/dropshots/EmulatorConfigRule.kt @@ -0,0 +1,42 @@ +package com.dropbox.dropshots + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import org.junit.rules.TestRule +import org.junit.runner.Description +import org.junit.runners.model.Statement + +class EmulatorConfigRule : TestRule { + override fun apply(base: Statement, description: Description): Statement = + EmulatorConfigStatement(base) + + private class EmulatorConfigStatement( + private val base: Statement, + ) : Statement() { + override fun evaluate() { + enableDemoMode() + base.evaluate() + disableDemoMode() + } + + private fun enableDemoMode() { + UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + .apply { + executeShellCommand("cmd overlay enable com.android.internal.systemui.navbar.gestural") + executeShellCommand("settings put global sysui_demo_allowed 1") + executeShellCommand("am broadcast -a com.android.systemui.demo -e command enter") + executeShellCommand("am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1234") + executeShellCommand("am broadcast -a com.android.systemui.demo -e command battery -e plugged false") + executeShellCommand("am broadcast -a com.android.systemui.demo -e command battery -e level 100") + executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4") + executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype none -e level 4") + executeShellCommand("am broadcast -a com.android.systemui.demo -e command notifications -e visible false") + } + } + + private fun disableDemoMode() { + UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + .executeShellCommand("am broadcast -a com.android.systemui.demo -e command exit") + } + } +} diff --git a/dropshots/src/debug/kotlin/com/dropbox/dropshots/TestActivity.kt b/dropshots/src/debug/kotlin/com/dropbox/dropshots/TestActivity.kt index 3f2df45..fd2ad63 100644 --- a/dropshots/src/debug/kotlin/com/dropbox/dropshots/TestActivity.kt +++ b/dropshots/src/debug/kotlin/com/dropbox/dropshots/TestActivity.kt @@ -1,3 +1,3 @@ package com.dropbox.dropshots -class TestActivity : androidx.fragment.app.FragmentActivity() +public class TestActivity : androidx.fragment.app.FragmentActivity() diff --git a/dropshots/src/main/java/com/dropbox/dropshots/Dropshots.kt b/dropshots/src/main/java/com/dropbox/dropshots/Dropshots.kt index 5f40dda..3647f6f 100644 --- a/dropshots/src/main/java/com/dropbox/dropshots/Dropshots.kt +++ b/dropshots/src/main/java/com/dropbox/dropshots/Dropshots.kt @@ -77,7 +77,7 @@ public class Dropshots( view: View, name: String = snapshotName, filePath: String? = null, - ) = assertSnapshot(Screenshot.capture(view).bitmap, name, filePath) + ): Unit = assertSnapshot(Screenshot.capture(view).bitmap, name, filePath) /** * Compares a screenshot of the activity to a reference screenshot from the test application's assets. @@ -91,7 +91,7 @@ public class Dropshots( activity: Activity, name: String = snapshotName, filePath: String? = null, - ) = assertSnapshot(Screenshot.capture(activity).bitmap, name, filePath) + ): Unit = assertSnapshot(Screenshot.capture(activity).bitmap, name, filePath) /** * Compares a screenshot of the visible screen content to a reference screenshot from the test application's assets. @@ -104,7 +104,7 @@ public class Dropshots( public fun assertSnapshot( name: String = snapshotName, filePath: String? = null, - ) = assertSnapshot(Screenshot.capture().bitmap, name, filePath) + ): Unit = assertSnapshot(Screenshot.capture().bitmap, name, filePath) @Suppress("LongMethod") public fun assertSnapshot( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dc7ab9b..d26ff39 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,23 +1,24 @@ [versions] -kotlin = "1.7.22" -agp = "7.4.0" -androidx-core = "1.7.0" +kotlin = "1.9.20" +agp = "8.7.1" +androidx-core = "1.13.1" [libraries] android = { module = "com.android.tools.build:gradle", version.ref = "agp" } -androidx-activity = { module = "androidx.activity:activity-ktx", version = "1.4.0" } -androidx-annotation = { module = "androidx.annotation:annotation", version = "1.1.0" } -androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.4.1" } +androidx-activity = { module = "androidx.activity:activity-ktx", version = "1.9.2" } +androidx-annotation = { module = "androidx.annotation:annotation", version = "1.8.2" } +androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.0" } androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version = "2.1.4" } androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } -androidx-fragment = { module = "androidx.fragment:fragment-ktx", version = "1.3.6" } -androidx-test-core = { module = "androidx.test:core-ktx", version = "1.5.0" } -androidx-test-ext-junit = { module = "androidx.test.ext:junit-ktx", version = "1.1.5" } -androidx-test-rules = { module = "androidx.test:rules", version = "1.5.0" } -androidx-test-runner = { module = "androidx.test:runner", version = "1.5.2" } -differ = "com.dropbox.differ:differ:0.0.1-alpha1" -junit = "junit:junit:4.12" -truth = "com.google.truth:truth:1.1.3" +androidx-fragment = { module = "androidx.fragment:fragment-ktx", version = "1.8.4" } +androidx-test-core = { module = "androidx.test:core-ktx", version = "1.6.1" } +androidx-test-ext-junit = { module = "androidx.test.ext:junit-ktx", version = "1.2.1" } +androidx-test-rules = { module = "androidx.test:rules", version = "1.6.1" } +androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" } +androidx-test-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version = "2.3.0" } +differ = "com.dropbox.differ:differ:0.0.2" +junit = "junit:junit:4.13.2" +truth = "com.google.truth:truth:1.4.2" kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" } kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -25,10 +26,10 @@ kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotl [plugins] android-library = { id = "com.android.library", version.ref = "agp" } android-application = { id = "com.android.application", version.ref = "agp" } -dokka = { id = "org.jetbrains.dokka", version = "1.7.20" } +dokka = { id = "org.jetbrains.dokka", version = "1.9.20" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "11.4.2" } -mavenPublish = { id = "com.vanniktech.maven.publish.base", version = "0.25.2" } +mavenPublish = { id = "com.vanniktech.maven.publish.base", version = "0.29.0" } binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.13.0" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927..943f0cb 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 070cb70..c44c230 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..65dcd68 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,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/HEAD/subprojects/plugins/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,10 +80,10 @@ 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##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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"' @@ -143,12 +143,16 @@ fi 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=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=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# 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 ac1b06f..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal 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,7 +41,7 @@ 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. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 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 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal