mirror of
				https://github.com/gradle/gradle-build-action.git
				synced 2025-10-31 07:08:56 +08:00 
			
		
		
		
	Use multiline input parameters instead of JSON input
The `gradle-home-cache-includes` and `gradle-home-cache-excludes` parameters were initially implemented as JSON string inputs. This makes these inputs non-idiomatic and easier to get wrong. This change converts them to multi-line input parameters. Fixes #106
This commit is contained in:
		
							
								
								
									
										12
									
								
								.github/workflows/integTest-caching-config.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								.github/workflows/integTest-caching-config.yml
									
									
									
									
										vendored
									
									
								
							| @@ -28,9 +28,11 @@ jobs: | |||||||
|         # Add "wrapper" to main cache entry and remove 'wrapper-zips' bundle |         # Add "wrapper" to main cache entry and remove 'wrapper-zips' bundle | ||||||
|         # Exclude build-cache from main cache entry |         # Exclude build-cache from main cache entry | ||||||
|         gradle-home-cache-includes: | |         gradle-home-cache-includes: | | ||||||
|             ["caches", "notifications", "wrapper"] |             caches | ||||||
|  |             notifications | ||||||
|  |             wrapper | ||||||
|         gradle-home-cache-excludes: | |         gradle-home-cache-excludes: | | ||||||
|             ["caches/build-cache-1"] |             caches/build-cache-1 | ||||||
|         gradle-home-cache-artifact-bundles: | |         gradle-home-cache-artifact-bundles: | | ||||||
|             [ |             [ | ||||||
|               ["generated-gradle-jars", "caches/*/generated-gradle-jars/*.jar"], |               ["generated-gradle-jars", "caches/*/generated-gradle-jars/*.jar"], | ||||||
| @@ -57,9 +59,11 @@ jobs: | |||||||
|         cache-read-only: true |         cache-read-only: true | ||||||
|         # Need the same configuration when restoring state from cache |         # Need the same configuration when restoring state from cache | ||||||
|         gradle-home-cache-includes: | |         gradle-home-cache-includes: | | ||||||
|             ["caches", "notifications", "wrapper"] |             caches | ||||||
|  |             notifications | ||||||
|  |             wrapper | ||||||
|         gradle-home-cache-excludes: | |         gradle-home-cache-excludes: | | ||||||
|             ["caches/build-cache-1"] |             caches/build-cache-1 | ||||||
|         gradle-home-cache-artifact-bundles: | |         gradle-home-cache-artifact-bundles: | | ||||||
|             [ |             [ | ||||||
|               ["generated-gradle-jars", "caches/*/generated-gradle-jars/*.jar"], |               ["generated-gradle-jars", "caches/*/generated-gradle-jars/*.jar"], | ||||||
|   | |||||||
| @@ -191,10 +191,12 @@ The contents to be cached can be fine tuned by including and excluding certain p | |||||||
| ```yaml | ```yaml | ||||||
| # Cache downloaded JDKs in addition to the default directories. | # Cache downloaded JDKs in addition to the default directories. | ||||||
| gradle-home-cache-includes: | | gradle-home-cache-includes: | | ||||||
|     ["caches", "notifications", "jdks"] |     caches | ||||||
|  |     notifications | ||||||
|  |     jdks | ||||||
| # Exclude the local build-cache from the directories cached. | # Exclude the local build-cache from the directories cached. | ||||||
| gradle-home-cache-excludes: | | gradle-home-cache-excludes: | | ||||||
|     ["caches/build-cache-1"] |     caches/build-cache-1 | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| You can specify any number of fixed paths or patterns to include or exclude.  | You can specify any number of fixed paths or patterns to include or exclude.  | ||||||
|   | |||||||
| @@ -36,13 +36,13 @@ inputs: | |||||||
|     description: Paths within Gradle User Home to cache. |     description: Paths within Gradle User Home to cache. | ||||||
|     required: false |     required: false | ||||||
|     default: | |     default: | | ||||||
|         ["caches", "notifications"] |         caches | ||||||
|  |         notifications | ||||||
|  |  | ||||||
|   gradle-home-cache-excludes: |   gradle-home-cache-excludes: | ||||||
|     description: Paths within Gradle User Home to exclude from cache. |     description: Paths within Gradle User Home to exclude from cache. | ||||||
|     required: false |     required: false | ||||||
|     default: | |    | ||||||
|         []  |  | ||||||
|   # e.g. Use the following setting to prevent the local build cache from being saved/restored |   # e.g. Use the following setting to prevent the local build cache from being saved/restored | ||||||
|   #      gradle-home-cache-excludes: | |   #      gradle-home-cache-excludes: | | ||||||
|   #           ["caches/build-cache-1"] |   #           ["caches/build-cache-1"] | ||||||
|   | |||||||
| @@ -84,8 +84,8 @@ export class GradleUserHomeCache extends AbstractCache { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private removeExcludedPaths(): void { |     private removeExcludedPaths(): void { | ||||||
|         const rawPaths: string[] = JSON.parse( |         const rawPaths: string[] = core.getMultilineInput( | ||||||
|             core.getInput(EXCLUDE_PATHS_PARAMETER) |             EXCLUDE_PATHS_PARAMETER | ||||||
|         ) |         ) | ||||||
|         const resolvedPaths = rawPaths.map(x => |         const resolvedPaths = rawPaths.map(x => | ||||||
|             path.resolve(this.gradleUserHome, x) |             path.resolve(this.gradleUserHome, x) | ||||||
| @@ -193,8 +193,8 @@ export class GradleUserHomeCache extends AbstractCache { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected getCachePath(): string[] { |     protected getCachePath(): string[] { | ||||||
|         const rawPaths: string[] = JSON.parse( |         const rawPaths: string[] = core.getMultilineInput( | ||||||
|             core.getInput(INCLUDE_PATHS_PARAMETER) |             INCLUDE_PATHS_PARAMETER | ||||||
|         ) |         ) | ||||||
|         rawPaths.push(META_FILE_DIR) |         rawPaths.push(META_FILE_DIR) | ||||||
|         const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x)) |         const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user