import upath from 'upath' ; import { GlobalConfig } from '../../../config/global' ; import { localPathExists , readLocalFile } from '../../../util/fs' ; import { extractGradleVersion , getJavaContraint , } from '../../gradle-wrapper/utils' ; const GradleWrapperProperties = 'gradle/wrapper/gradle-wrapper.properties' ; export async function getDockerConstraint ( gradleRoot ) { if ( GlobalConfig . get ( 'binarySource' ) !== 'docker' ) { return null ; } const fileContent = await readLocalFile ( upath . join ( gradleRoot , GradleWrapperProperties ) , 'utf8' ) ; const version = extractGradleVersion ( fileContent ) ?. version ; return getJavaContraint ( version ) ; } export async function getDockerPreCommands ( gradleRoot ) { if ( GlobalConfig . get ( 'binarySource' ) !== 'docker' ) { return null ; } if ( await localPathExists ( upath . join ( gradleRoot , GradleWrapperProperties ) ) ) { return null ; } return [ 'install-tool gradle latest' ] ; }