mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-27 02:30:56 -05:00
15a8123fbc
- Provide a more useful error message when no Gradle wrapper can be located, and 'gradle-version' or 'gradle-executable' is not used. - Add test for case where wrapper is missing. This isn't really a "test" per-se, but this failing build invocation makes it easy to verify the GitHub action behaviour when the build is misconfigured.
24 lines
768 B
TypeScript
24 lines
768 B
TypeScript
import * as path from 'path'
|
|
import fs from 'fs'
|
|
|
|
const IS_WINDOWS = process.platform === 'win32'
|
|
|
|
export function wrapperFilename(): string {
|
|
return IS_WINDOWS ? 'gradlew.bat' : 'gradlew'
|
|
}
|
|
|
|
export function installScriptFilename(): string {
|
|
return IS_WINDOWS ? 'gradle.bat' : 'gradle'
|
|
}
|
|
|
|
export function validateGradleWrapper(gradlewDirectory: string): void {
|
|
const wrapperProperties = path.resolve(
|
|
gradlewDirectory,
|
|
'gradle/wrapper/gradle-wrapper.properties'
|
|
)
|
|
if (!fs.existsSync(wrapperProperties)) {
|
|
throw new Error(
|
|
`Cannot locate a Gradle wrapper properties file at '${wrapperProperties}'. Specify 'gradle-version' or 'gradle-executable' for projects without Gradle wrapper configured.`
|
|
)
|
|
}
|
|
}
|