mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-24 11:26:19 +08:00
Cleanup code to resolve Gradle wrapper script
This commit is contained in:
parent
378bd0b6f8
commit
d20d631365
@ -3,7 +3,7 @@ import fs from 'fs'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
export function wrapperFilename(): string {
|
||||
export function wrapperScriptFilename(): string {
|
||||
return IS_WINDOWS ? 'gradlew.bat' : 'gradlew'
|
||||
}
|
||||
|
||||
@ -11,9 +11,14 @@ export function installScriptFilename(): string {
|
||||
return IS_WINDOWS ? 'gradle.bat' : 'gradle'
|
||||
}
|
||||
|
||||
export function validateGradleWrapper(gradlewDirectory: string): void {
|
||||
export function locateGradleWrapperScript(buildRootDirectory: string): string {
|
||||
validateGradleWrapper(buildRootDirectory)
|
||||
return path.resolve(buildRootDirectory, wrapperScriptFilename())
|
||||
}
|
||||
|
||||
function validateGradleWrapper(buildRootDirectory: string): void {
|
||||
const wrapperProperties = path.resolve(
|
||||
gradlewDirectory,
|
||||
buildRootDirectory,
|
||||
'gradle/wrapper/gradle-wrapper.properties'
|
||||
)
|
||||
if (!fs.existsSync(wrapperProperties)) {
|
||||
|
@ -59,14 +59,7 @@ async function resolveGradleExecutable(
|
||||
return path.resolve(workspaceDirectory, gradleExecutable)
|
||||
}
|
||||
|
||||
const wrapperDirectory = core.getInput('wrapper-directory')
|
||||
const gradlewDirectory =
|
||||
wrapperDirectory !== ''
|
||||
? path.resolve(workspaceDirectory, wrapperDirectory)
|
||||
: buildRootDirectory
|
||||
|
||||
gradlew.validateGradleWrapper(gradlewDirectory)
|
||||
return path.resolve(gradlewDirectory, gradlew.wrapperFilename())
|
||||
return gradlew.locateGradleWrapperScript(buildRootDirectory)
|
||||
}
|
||||
|
||||
function resolveBuildRootDirectory(baseDirectory: string): string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user