Commit 692fda9d authored by Paul Merlin's avatar Paul Merlin
Browse files

Cache wrapper install when gradle-executable points to a wrapper

parent e8885a31
Loading
Loading
Loading
Loading
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+4 −2
Changes for src/cache.ts: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -9,11 +9,13 @@ const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH'
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'

export async function restoreCachedWrapperDist(
    executableDirectory: string
    gradlewDirectory: string | null
): Promise<void> {
    if (gradlewDirectory == null) return

    const wrapperSlug = extractGradleWrapperSlugFrom(
        path.join(
            path.resolve(executableDirectory),
            path.resolve(gradlewDirectory),
            'gradle/wrapper/gradle-wrapper.properties'
        )
    )
+8 −3
Changes for src/main.ts: 8 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -40,18 +40,23 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {

    const gradleExecutable = inputOrNull('gradle-executable')
    if (gradleExecutable !== null) {
        if (gradleExecutable.endsWith(gradlew.wrapperFilename())) {
            await cache.restoreCachedWrapperDist(
                path.resolve(gradleExecutable, '..')
            )
        }
        return path.resolve(baseDirectory, gradleExecutable)
    }

    const wrapperDirectory = inputOrNull('wrapper-directory')
    const executableDirectory =
    const gradlewDirectory =
        wrapperDirectory !== null
            ? path.join(baseDirectory, wrapperDirectory)
            : baseDirectory

    await cache.restoreCachedWrapperDist(executableDirectory)
    await cache.restoreCachedWrapperDist(gradlewDirectory)

    return path.resolve(executableDirectory, gradlew.wrapperFilename())
    return path.resolve(gradlewDirectory, gradlew.wrapperFilename())
}

function resolveBuildRootDirectory(baseDirectory: string): string {