From de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc Mon Sep 17 00:00:00 2001 From: Kengo TODA Date: Tue, 18 Oct 2022 00:34:41 +0800 Subject: [PATCH] feat: support Gradle version catalog (#394) --- README.md | 2 +- __tests__/cache.test.ts | 11 ++++++++++- dist/cleanup/index.js | 3 ++- dist/setup/index.js | 3 ++- src/cache.ts | 3 ++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 70922ca..4c19157 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Currently, the following distributions are supported: ### Caching packages dependencies The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files: -- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt` +- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, and `gradle/*.versions.toml` - maven: `**/pom.xml` - sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.{scala,sbt}` diff --git a/__tests__/cache.test.ts b/__tests__/cache.test.ts index 46fb994..987da4a 100644 --- a/__tests__/cache.test.ts +++ b/__tests__/cache.test.ts @@ -98,7 +98,7 @@ describe('dependency cache', () => { await expect(restore('gradle')).rejects.toThrowError( `No file in ${projectRoot( workspace - )} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt], make sure you have checked out the target repository` + )} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt,gradle/*.versions.toml], make sure you have checked out the target repository` ); }); it('downloads cache based on build.gradle', async () => { @@ -112,6 +112,15 @@ describe('dependency cache', () => { it('downloads cache based on build.gradle.kts', async () => { createFile(join(workspace, 'build.gradle.kts')); + await restore('gradle'); + expect(spyCacheRestore).toBeCalled(); + expect(spyWarning).not.toBeCalled(); + expect(spyInfo).toBeCalledWith('gradle cache is not found'); + }); + it('downloads cache based on libs.versions.toml', async () => { + createDirectory(join(workspace, 'gradle')); + createFile(join(workspace, 'gradle', 'libs.versions.toml')); + await restore('gradle'); expect(spyCacheRestore).toBeCalled(); expect(spyWarning).not.toBeCalled(); diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 201e110..82e6865 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -68224,7 +68224,8 @@ const supportedPackageManager = [ '**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/**/Versions.kt', - 'buildSrc/**/Dependencies.kt' + 'buildSrc/**/Dependencies.kt', + 'gradle/*.versions.toml' ] }, { diff --git a/dist/setup/index.js b/dist/setup/index.js index fe776b9..2820ec3 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -103427,7 +103427,8 @@ const supportedPackageManager = [ '**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/**/Versions.kt', - 'buildSrc/**/Dependencies.kt' + 'buildSrc/**/Dependencies.kt', + 'gradle/*.versions.toml' ] }, { diff --git a/src/cache.ts b/src/cache.ts index 1533ed0..20b553e 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -35,7 +35,8 @@ const supportedPackageManager: PackageManager[] = [ '**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/**/Versions.kt', - 'buildSrc/**/Dependencies.kt' + 'buildSrc/**/Dependencies.kt', + 'gradle/*.versions.toml' ] }, {