Commit 18c8a679 authored by Daz DeBoer's avatar Daz DeBoer
Browse files

Look for gradle wrapper in build-root-directory by default

This removes the need to specify `wrapper-directory` when using a Gradle
project that is not located in the root of the workspace.

Fixes #44.
parent 13d33a88
Loading
Loading
Loading
Loading
+8 −1
Changes for .github/workflows/prod.yml: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -17,11 +17,18 @@ jobs:
    - name: Test wrapper
      uses: ./
      with:
        wrapper-directory: __tests__/data/basic
        build-root-directory: __tests__/data/basic
        dependencies-cache-enabled: true
        configuration-cache-enabled: true
        arguments: test
    - name: Test custom wrapper location
      uses: ./
      with:
        build-root-directory: __tests__/data/basic
        wrapper-directory: __tests__/data/basic
        dependencies-cache-enabled: false
        configuration-cache-enabled: false
        arguments: test
    - name: Test dist download
      uses: ./
      with:
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+14 −7
Changes for src/main.ts: 14 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -11,11 +11,15 @@ import * as provision from './provision'
// Invoked by GitHub Actions
export async function run(): Promise<void> {
    try {
        const baseDirectory = process.env[`GITHUB_WORKSPACE`] || ''
        const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''
        const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory)

        const result = await execution.execute(
            await resolveGradleExecutable(baseDirectory),
            resolveBuildRootDirectory(baseDirectory),
            await resolveGradleExecutable(
                workspaceDirectory,
                buildRootDirectory
            ),
            buildRootDirectory,
            parseCommandLineArguments()
        )

@@ -33,7 +37,10 @@ export async function run(): Promise<void> {

run()

async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
async function resolveGradleExecutable(
    workspaceDirectory: string,
    buildRootDirectory: string
): Promise<string> {
    const gradleVersion = github.inputOrNull('gradle-version')
    if (gradleVersion !== null && gradleVersion !== 'wrapper') {
        return path.resolve(await provision.gradleVersion(gradleVersion))
@@ -46,14 +53,14 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
                path.resolve(gradleExecutable, '..')
            )
        }
        return path.resolve(baseDirectory, gradleExecutable)
        return path.resolve(workspaceDirectory, gradleExecutable)
    }

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

    await cacheWrapper.restoreCachedWrapperDist(gradlewDirectory)