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.
This commit is contained in:
Daz DeBoer 2021-06-24 10:45:43 -07:00
parent 13d33a88ca
commit 18c8a679dc
3 changed files with 23 additions and 9 deletions

View File

@ -17,11 +17,18 @@ jobs:
- name: Test wrapper - name: Test wrapper
uses: ./ uses: ./
with: with:
wrapper-directory: __tests__/data/basic
build-root-directory: __tests__/data/basic build-root-directory: __tests__/data/basic
dependencies-cache-enabled: true dependencies-cache-enabled: true
configuration-cache-enabled: true configuration-cache-enabled: true
arguments: test 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 - name: Test dist download
uses: ./ uses: ./
with: with:

2
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -11,11 +11,15 @@ import * as provision from './provision'
// Invoked by GitHub Actions // Invoked by GitHub Actions
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
const baseDirectory = process.env[`GITHUB_WORKSPACE`] || '' const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory)
const result = await execution.execute( const result = await execution.execute(
await resolveGradleExecutable(baseDirectory), await resolveGradleExecutable(
resolveBuildRootDirectory(baseDirectory), workspaceDirectory,
buildRootDirectory
),
buildRootDirectory,
parseCommandLineArguments() parseCommandLineArguments()
) )
@ -33,7 +37,10 @@ export async function run(): Promise<void> {
run() run()
async function resolveGradleExecutable(baseDirectory: string): Promise<string> { async function resolveGradleExecutable(
workspaceDirectory: string,
buildRootDirectory: string
): Promise<string> {
const gradleVersion = github.inputOrNull('gradle-version') const gradleVersion = github.inputOrNull('gradle-version')
if (gradleVersion !== null && gradleVersion !== 'wrapper') { if (gradleVersion !== null && gradleVersion !== 'wrapper') {
return path.resolve(await provision.gradleVersion(gradleVersion)) return path.resolve(await provision.gradleVersion(gradleVersion))
@ -46,14 +53,14 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
path.resolve(gradleExecutable, '..') path.resolve(gradleExecutable, '..')
) )
} }
return path.resolve(baseDirectory, gradleExecutable) return path.resolve(workspaceDirectory, gradleExecutable)
} }
const wrapperDirectory = github.inputOrNull('wrapper-directory') const wrapperDirectory = github.inputOrNull('wrapper-directory')
const gradlewDirectory = const gradlewDirectory =
wrapperDirectory !== null wrapperDirectory !== null
? path.join(baseDirectory, wrapperDirectory) ? path.resolve(workspaceDirectory, wrapperDirectory)
: baseDirectory : buildRootDirectory
await cacheWrapper.restoreCachedWrapperDist(gradlewDirectory) await cacheWrapper.restoreCachedWrapperDist(gradlewDirectory)