mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-26 11:02:10 +00:00
Cleanup code to resolve Gradle wrapper script
This commit is contained in:
parent
378bd0b6f8
commit
d20d631365
2 changed files with 9 additions and 11 deletions
|
@ -3,7 +3,7 @@ import fs from 'fs'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
export function wrapperFilename(): string {
|
export function wrapperScriptFilename(): string {
|
||||||
return IS_WINDOWS ? 'gradlew.bat' : 'gradlew'
|
return IS_WINDOWS ? 'gradlew.bat' : 'gradlew'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,9 +11,14 @@ export function installScriptFilename(): string {
|
||||||
return IS_WINDOWS ? 'gradle.bat' : 'gradle'
|
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(
|
const wrapperProperties = path.resolve(
|
||||||
gradlewDirectory,
|
buildRootDirectory,
|
||||||
'gradle/wrapper/gradle-wrapper.properties'
|
'gradle/wrapper/gradle-wrapper.properties'
|
||||||
)
|
)
|
||||||
if (!fs.existsSync(wrapperProperties)) {
|
if (!fs.existsSync(wrapperProperties)) {
|
||||||
|
|
|
@ -59,14 +59,7 @@ async function resolveGradleExecutable(
|
||||||
return path.resolve(workspaceDirectory, gradleExecutable)
|
return path.resolve(workspaceDirectory, gradleExecutable)
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapperDirectory = core.getInput('wrapper-directory')
|
return gradlew.locateGradleWrapperScript(buildRootDirectory)
|
||||||
const gradlewDirectory =
|
|
||||||
wrapperDirectory !== ''
|
|
||||||
? path.resolve(workspaceDirectory, wrapperDirectory)
|
|
||||||
: buildRootDirectory
|
|
||||||
|
|
||||||
gradlew.validateGradleWrapper(gradlewDirectory)
|
|
||||||
return path.resolve(gradlewDirectory, gradlew.wrapperFilename())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveBuildRootDirectory(baseDirectory: string): string {
|
function resolveBuildRootDirectory(baseDirectory: string): string {
|
||||||
|
|
Loading…
Reference in a new issue