mirror of
				https://github.com/gradle/gradle-build-action.git
				synced 2025-11-04 18:08:57 +08:00 
			
		
		
		
	Cache wrapper install when gradle-executable points to a wrapper
This commit is contained in:
		@@ -9,11 +9,13 @@ const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH'
 | 
			
		||||
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
 | 
			
		||||
 | 
			
		||||
export async function restoreCachedWrapperDist(
 | 
			
		||||
    executableDirectory: string
 | 
			
		||||
    gradlewDirectory: string | null
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
    if (gradlewDirectory == null) return
 | 
			
		||||
 | 
			
		||||
    const wrapperSlug = extractGradleWrapperSlugFrom(
 | 
			
		||||
        path.join(
 | 
			
		||||
            path.resolve(executableDirectory),
 | 
			
		||||
            path.resolve(gradlewDirectory),
 | 
			
		||||
            'gradle/wrapper/gradle-wrapper.properties'
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.ts
									
									
									
									
									
								
							@@ -40,18 +40,23 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
 | 
			
		||||
 | 
			
		||||
    const gradleExecutable = inputOrNull('gradle-executable')
 | 
			
		||||
    if (gradleExecutable !== null) {
 | 
			
		||||
        if (gradleExecutable.endsWith(gradlew.wrapperFilename())) {
 | 
			
		||||
            await cache.restoreCachedWrapperDist(
 | 
			
		||||
                path.resolve(gradleExecutable, '..')
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
        return path.resolve(baseDirectory, gradleExecutable)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const wrapperDirectory = inputOrNull('wrapper-directory')
 | 
			
		||||
    const executableDirectory =
 | 
			
		||||
    const gradlewDirectory =
 | 
			
		||||
        wrapperDirectory !== null
 | 
			
		||||
            ? path.join(baseDirectory, wrapperDirectory)
 | 
			
		||||
            : baseDirectory
 | 
			
		||||
 | 
			
		||||
    await cache.restoreCachedWrapperDist(executableDirectory)
 | 
			
		||||
    await cache.restoreCachedWrapperDist(gradlewDirectory)
 | 
			
		||||
 | 
			
		||||
    return path.resolve(executableDirectory, gradlew.wrapperFilename())
 | 
			
		||||
    return path.resolve(gradlewDirectory, gradlew.wrapperFilename())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function resolveBuildRootDirectory(baseDirectory: string): string {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user