2021-06-24 12:13:54 -07:00
import * as path from 'path'
import fs from 'fs'
2020-06-13 13:44:30 +02:00
const IS_WINDOWS = process . platform === 'win32'
2019-09-23 12:10:49 +02:00
2021-09-07 14:38:41 -06:00
export function wrapperScriptFilename ( ) : string {
2020-06-13 13:44:30 +02:00
return IS_WINDOWS ? 'gradlew.bat' : 'gradlew'
2019-09-21 16:01:53 +02:00
}
2019-09-23 12:10:49 +02:00
export function installScriptFilename ( ) : string {
2020-06-13 13:44:30 +02:00
return IS_WINDOWS ? 'gradle.bat' : 'gradle'
2019-09-21 16:01:53 +02:00
}
2021-06-24 12:13:54 -07:00
2021-09-07 14:38:41 -06:00
export function locateGradleWrapperScript ( buildRootDirectory : string ) : string {
validateGradleWrapper ( buildRootDirectory )
return path . resolve ( buildRootDirectory , wrapperScriptFilename ( ) )
}
function validateGradleWrapper ( buildRootDirectory : string ) : void {
2021-10-29 07:34:44 -06:00
const wrapperProperties = path . resolve ( buildRootDirectory , 'gradle/wrapper/gradle-wrapper.properties' )
2021-06-24 12:13:54 -07:00
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. `
)
}
}