2026-07-29 17:53:33 -04:00
export const id = 242 ;
export const ids = [ 242 ] ;
export const modules = {
/***/ 6242 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
O : ( ) => ( /* binding */ JavaBase )
} ) ;
// EXTERNAL MODULE: ./node_modules/@actions/tool-cache/lib/tool-cache.js + 2 modules
var tool _cache = _ _webpack _require _ _ ( 9805 ) ;
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js + 7 modules
var core = _ _webpack _require _ _ ( 3838 ) ;
// EXTERNAL MODULE: external "fs"
var external _fs _ = _ _webpack _require _ _ ( 9896 ) ;
// EXTERNAL MODULE: ./node_modules/semver/index.js
var semver = _ _webpack _require _ _ ( 2088 ) ;
var semver _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( semver ) ;
// EXTERNAL MODULE: external "path"
var external _path _ = _ _webpack _require _ _ ( 6928 ) ;
var external _path _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _path _ ) ;
// EXTERNAL MODULE: ./node_modules/@actions/http-client/lib/index.js + 1 modules
var lib = _ _webpack _require _ _ ( 4942 ) ;
// EXTERNAL MODULE: ./src/util.ts
var util = _ _webpack _require _ _ ( 4527 ) ;
// EXTERNAL MODULE: ./src/constants.ts
var constants = _ _webpack _require _ _ ( 7242 ) ;
; // CONCATENATED MODULE: ./src/retrying-http-client.ts
const RETRYABLE _HTTP _STATUS _CODES = new Set ( [ 429 , 502 , 503 , 504 , 522 ] ) ;
const RETRYABLE _NETWORK _ERROR _CODES = new Set ( [
'ETIMEDOUT' ,
'ECONNRESET' ,
'ENOTFOUND' ,
'ECONNREFUSED'
] ) ;
const RETRYABLE _HTTP _VERBS = new Set ( [ 'OPTIONS' , 'GET' , 'DELETE' , 'HEAD' ] ) ;
class RetryingHttpClient extends lib /* HttpClient */ . Qq {
maxAttempts ;
baseDelayMs ;
maxDelayMs ;
sleep ;
random ;
now ;
constructor ( userAgent , retryOptions = { } ) {
super ( userAgent , undefined , { allowRetries : false } ) ;
this . maxAttempts = retryOptions . maxAttempts ? ? 4 ;
this . baseDelayMs = retryOptions . baseDelayMs ? ? 1000 ;
this . maxDelayMs = retryOptions . maxDelayMs ? ? 10000 ;
this . sleep =
retryOptions . sleep ? ?
( delayMs => new Promise ( resolve => setTimeout ( resolve , delayMs ) ) ) ;
this . random = retryOptions . random ? ? Math . random ;
this . now = retryOptions . now ? ? Date . now ;
if ( this . maxAttempts < 1 ) {
throw new Error ( 'maxAttempts must be at least 1' ) ;
}
if ( this . baseDelayMs < 0 || this . maxDelayMs < this . baseDelayMs ) {
throw new Error ( 'baseDelayMs must be non-negative and no greater than maxDelayMs' ) ;
}
}
async request ( verb , requestUrl , data , headers ) {
if ( ! RETRYABLE _HTTP _VERBS . has ( verb ) ) {
return super . request ( verb , requestUrl , data , headers ) ;
}
for ( let attempt = 1 ; attempt <= this . maxAttempts ; attempt ++ ) {
try {
const response = await super . request ( verb , requestUrl , data , headers ) ;
const statusCode = response . message . statusCode ;
if ( ! statusCode ||
! RETRYABLE _HTTP _STATUS _CODES . has ( statusCode ) ||
attempt === this . maxAttempts ) {
return response ;
}
const delayMs = this . getDelayMs ( attempt , response . message . headers [ 'retry-after' ] ) ;
await response . readBody ( ) ;
this . logRetry ( attempt , delayMs , ` HTTP ${ statusCode } ` ) ;
await this . sleep ( delayMs ) ;
}
catch ( error ) {
if ( ! isRetryableNetworkError ( error ) || attempt === this . maxAttempts ) {
throw error ;
}
const delayMs = this . getDelayMs ( attempt ) ;
this . logRetry ( attempt , delayMs , getErrorMessage ( error ) ) ;
await this . sleep ( delayMs ) ;
}
}
throw new Error ( 'HTTP retry attempts exhausted unexpectedly' ) ;
}
getDelayMs ( failedAttempt , retryAfter ) {
const exponentialDelay = Math . min ( this . maxDelayMs , this . baseDelayMs * 2 * * ( failedAttempt - 1 ) ) ;
const jitteredDelay = Math . floor ( exponentialDelay / 2 + this . random ( ) * ( exponentialDelay / 2 ) ) ;
const retryAfterDelay = parseRetryAfter ( retryAfter , this . now ( ) ) ;
return Math . min ( this . maxDelayMs , Math . max ( jitteredDelay , retryAfterDelay ? ? 0 ) ) ;
}
logRetry ( failedAttempt , delayMs , reason ) {
core /* info */ . pq ( ` Request attempt ${ failedAttempt } of ${ this . maxAttempts } failed ( ${ reason } ); retrying in ${ delayMs } ms ` ) ;
}
}
function parseRetryAfter ( value , nowMs ) {
const retryAfter = Array . isArray ( value ) ? value [ 0 ] : value ;
if ( ! retryAfter ) {
return undefined ;
}
if ( /^\d+$/ . test ( retryAfter . trim ( ) ) ) {
return Number ( retryAfter ) * 1000 ;
}
const retryAt = Date . parse ( retryAfter ) ;
if ( Number . isNaN ( retryAt ) || retryAt <= nowMs ) {
return undefined ;
}
return retryAt - nowMs ;
}
function isRetryableNetworkError ( error ) {
if ( ! isErrorRecord ( error ) ) {
return false ;
}
if ( typeof error . code === 'string' &&
RETRYABLE _NETWORK _ERROR _CODES . has ( error . code ) ) {
return true ;
}
return ( Array . isArray ( error . errors ) &&
error . errors . some ( nestedError => isRetryableNetworkError ( nestedError ) ) ) ;
}
function isErrorRecord ( error ) {
return typeof error === 'object' && error !== null ;
}
function getErrorMessage ( error ) {
return error instanceof Error ? error . message : 'network error' ;
}
// EXTERNAL MODULE: external "os"
var external _os _ = _ _webpack _require _ _ ( 857 ) ;
var external _os _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _os _ ) ;
// EXTERNAL MODULE: external "crypto"
var external _crypto _ = _ _webpack _require _ _ ( 6982 ) ;
// EXTERNAL MODULE: external "stream/promises"
Optimize Maven configuration warm path (#1182)
* Optimize Maven configuration warm path
Avoid eager Maven XML initialization on warm JDK runs by using deterministic serializers for new Maven settings/toolchains files, lazy-loading xmlbuilder2 for existing toolchains merges, and deferring Maven configuration modules until after Java setup.
Add targeted tests for XML escaping, lazy xmlbuilder2 loading, concurrent Maven configuration, and a manual benchmark workflow for warm-path validation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
* Address Maven optimization PR feedback
Make the toolchain XML generator consistently async, remove redundant Maven configuration await handling, and reuse the existing XML test helper.
Configure CodeQL to skip generated dist output so newly split vendored chunks do not report duplicate generated-code alerts.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
* Apply rubber duck review suggestions
Document XML attribute escaping, simplify Maven configuration awaiting, and add a regression test that feeds fast-path toolchains output into the merge path.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
* Delete .github/codeql/codeql-config.yml
* Update codeql-analysis.yml
* Replace xmlbuilder2 in Maven toolchain merge
Use fast-xml-parser for existing toolchains.xml parsing and serialize merged Maven toolchains deterministically. This removes the bundled xmlbuilder2 DOM/XML builder chunk from dist while preserving merge behavior for custom attributes, custom toolchains, partial entries, duplicate filtering, and escaping.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
* Move Maven benchmark out of setup-java
Remove the Maven warm-path benchmark workflow and helper script from setup-java. Benchmark coverage is being moved to actions/setup-java-benchmarks so this action repository only carries the runtime optimization, tests, and generated distribution artifacts.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
---------
Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
2026-07-30 15:09:35 -04:00
var promises _ = _ _webpack _require _ _ ( 9786 ) ;
2026-07-29 17:53:33 -04:00
; // CONCATENATED MODULE: ./src/checksum.ts
function sanitizedSource ( source ) {
if ( ! source ) {
return '' ;
}
try {
const url = new URL ( source ) ;
return ` from ${ url . origin } ${ url . pathname } ` ;
}
catch {
return ' from an invalid checksum source' ;
}
}
// Length, in hex characters, of a digest produced by each supported algorithm.
// Exported so callers (e.g. fetchChecksum) can infer which algorithm a vendor
// actually used when it doesn't disclose it via the checksum URL/filename.
function expectedDigestLength ( algorithm ) {
return algorithm === 'sha256' ? 64 : algorithm === 'sha512' ? 128 : 0 ;
}
function normalizeExpectedDigest ( checksum ) {
const algorithm = checksum . algorithm ;
const digest = typeof checksum . value === 'string'
? checksum . value . trim ( ) . toLowerCase ( )
: '' ;
const expectedLength = expectedDigestLength ( algorithm ) ;
if ( expectedLength === 0 ) {
throw new Error ( ` Unsupported checksum algorithm ' ${ String ( algorithm ) } ' ${ sanitizedSource ( checksum . source ) } . Supported algorithms are sha256 and sha512. ` ) ;
}
if ( ! new RegExp ( ` ^[a-f0-9]{ ${ expectedLength } } $ ` ) . test ( digest ) ) {
throw new Error ( ` Malformed ${ algorithm } checksum metadata ${ sanitizedSource ( checksum . source ) } : expected a ${ expectedLength } -character hexadecimal digest. ` ) ;
}
return digest ;
}
async function calculateChecksum ( filePath , algorithm ) {
const hash = ( 0 , external _crypto _ . createHash ) ( algorithm ) ;
await ( 0 , promises _ . pipeline ) ( ( 0 , external _fs _ . createReadStream ) ( filePath ) , hash ) ;
return hash . digest ( 'hex' ) ;
}
async function verifyChecksum ( filePath , checksum , context ) {
const expected = normalizeExpectedDigest ( checksum ) ;
const actual = await calculateChecksum ( filePath , checksum . algorithm ) ;
const matches = ( 0 , external _crypto _ . timingSafeEqual ) ( Buffer . from ( expected , 'hex' ) , Buffer . from ( actual , 'hex' ) ) ;
if ( ! matches ) {
throw new Error ( ` Checksum verification failed for ${ context . distribution } version ${ context . version } : ${ checksum . algorithm } expected ${ expected } , actual ${ actual } . ` ) ;
}
}
// EXTERNAL MODULE: ./src/distributions/platform-types.ts
var platform _types = _ _webpack _require _ _ ( 7444 ) ;
; // CONCATENATED MODULE: ./src/distributions/base-installer.ts
class JavaBase {
distribution ;
http ;
version ;
architecture ;
packageType ;
stable ;
latest ;
checkLatest ;
forceDownload ;
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
cacheJdk ;
2026-07-29 17:53:33 -04:00
setDefault ;
verifySignature ;
verifySignaturePublicKey ;
constructor ( distribution , installerOptions ) {
this . distribution = distribution ;
this . http = new RetryingHttpClient ( 'actions/setup-java' ) ;
( {
version : this . version ,
stable : this . stable ,
latest : this . latest
} = this . normalizeVersion ( installerOptions . version ) ) ;
this . architecture = ( 0 , platform _types /* normalizeArchitecture */ . dV ) ( installerOptions . architecture || external _os _default ( ) . arch ( ) ) ;
this . packageType = installerOptions . packageType ;
this . checkLatest = installerOptions . checkLatest ;
this . forceDownload = installerOptions . forceDownload ? ? false ;
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
this . cacheJdk = installerOptions . cacheJdk ? ? false ;
2026-07-29 17:53:33 -04:00
this . setDefault =
installerOptions . setDefault !== undefined
? installerOptions . setDefault
: true ;
this . verifySignature = installerOptions . verifySignature ? ? false ;
this . verifySignaturePublicKey = installerOptions . verifySignaturePublicKey ;
}
async downloadAndVerify ( javaRelease ) {
const archivePath = await tool _cache /* downloadTool */ . bq ( javaRelease . url ) ;
const checksum = javaRelease . checksum ;
if ( ! checksum || ! checksum . value ? . trim ( ) ) {
core /* debug */ . Yz ( ` No authoritative checksum is available for ${ this . distribution } version ${ javaRelease . version } ; skipping checksum verification. ` ) ;
return archivePath ;
}
try {
await verifyChecksum ( archivePath , checksum , {
distribution : this . distribution ,
version : javaRelease . version
} ) ;
core /* debug */ . Yz ( ` Verified ${ checksum . algorithm } checksum for ${ this . distribution } version ${ javaRelease . version } . ` ) ;
return archivePath ;
}
catch ( error ) {
let cleanupError ;
let cleanupFailed = false ;
try {
await external _fs _ . promises . rm ( archivePath , { force : true } ) ;
}
catch ( caughtCleanupError ) {
cleanupError = caughtCleanupError ;
cleanupFailed = true ;
}
if ( cleanupFailed ) {
throw new Error ( ` ${ error . message } Failed to remove the downloaded archive after verification failure: ${ cleanupError . message } ` , { cause : error } ) ;
}
throw error ;
}
}
async fetchChecksum ( checksumUrl , algorithm ) {
// Some vendors (e.g. JetBrains) publish a single, generically-named
// checksum sibling (`.checksum`) whose digest algorithm isn't disclosed
// by the URL and has changed across releases. Accepting a list of
// candidate algorithms lets callers pass every algorithm the vendor is
// known to use; the actual algorithm is then inferred from the length of
// the returned digest.
const algorithms = Array . isArray ( algorithm ) ? algorithm : [ algorithm ] ;
const algorithmLabel = algorithms . join ( ' or ' ) ;
const response = await this . http . get ( checksumUrl ) ;
const statusCode = response . message . statusCode ;
const source = ( ( ) => {
try {
const url = new URL ( checksumUrl ) ;
return ` ${ url . origin } ${ url . pathname } ` ;
}
catch {
return 'an invalid checksum URL' ;
}
} ) ( ) ;
if ( statusCode === lib /* HttpCodes */ . Hv . NotFound ) {
core /* debug */ . Yz ( ` No authoritative ${ algorithmLabel } checksum is available for ${ this . distribution } from ${ source } ; skipping checksum verification. ` ) ;
return undefined ;
}
if ( statusCode !== lib /* HttpCodes */ . Hv . OK ) {
throw new Error ( ` Failed to fetch the authoritative ${ algorithmLabel } checksum for ${ this . distribution } from ${ source } (HTTP ${ statusCode } ). ` ) ;
}
const body = await response . readBody ( ) ;
const value = body . trim ( ) . split ( /\s+/ , 1 ) [ 0 ] ? ? '' ;
if ( ! value ) {
throw new Error ( ` Received an empty authoritative ${ algorithmLabel } checksum for ${ this . distribution } from ${ source } . ` ) ;
}
// Prefer the strongest algorithm whose digest length matches what was
// actually returned; fall back to the first candidate (preserving prior
// behavior/error messages) when the digest doesn't match any of them.
const resolvedAlgorithm = algorithms . find ( algo => value . length === expectedDigestLength ( algo ) ) ? ?
algorithms [ 0 ] ;
return { algorithm : resolvedAlgorithm , value , source : checksumUrl } ;
}
async setupJava ( ) {
if ( this . verifySignature && ! this . supportsSignatureVerification ( ) ) {
throw new Error ( ` Input 'verify-signature' is not supported for distribution ' ${ this . distribution } '. ` ) ;
}
let foundJava = this . forceDownload ? null : this . findInToolcache ( ) ;
if ( foundJava && ! this . checkLatest && ! this . latest ) {
core /* info */ . pq ( ` Resolved Java ${ foundJava . version } from tool-cache ` ) ;
}
else {
core /* info */ . pq ( 'Trying to resolve the latest version from remote' ) ;
try {
const javaRelease = await this . findPackageForDownload ( this . version ) ;
core /* info */ . pq ( ` Resolved latest version as ${ javaRelease . version } ` ) ;
if ( ! this . forceDownload && foundJava ? . version === javaRelease . version ) {
core /* info */ . pq ( ` Resolved Java ${ foundJava . version } from tool-cache ` ) ;
}
else {
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
let jdkCache ;
if ( this . cacheJdk ) {
const { getJdkVerificationIdentity } = await Promise . all ( /* import() */ [ _ _webpack _require _ _ . e ( 824 ) , _ _webpack _require _ _ . e ( 971 ) , _ _webpack _require _ _ . e ( 779 ) ] ) . then ( _ _webpack _require _ _ . bind ( _ _webpack _require _ _ , 5779 ) ) ;
jdkCache = {
distribution : this . distribution ,
packageType : this . packageType ,
architecture : this . architecture ,
version : javaRelease . version ,
source : this . getJdkReleaseIdentity ( javaRelease ) ,
verification : getJdkVerificationIdentity ( this . verifySignature , this . verifySignaturePublicKey ) ,
path : this . getJdkCachePath ( javaRelease . version )
} ;
}
if ( ! this . forceDownload && jdkCache ) {
const { restoreJdk } = await Promise . all ( /* import() */ [ _ _webpack _require _ _ . e ( 824 ) , _ _webpack _require _ _ . e ( 971 ) , _ _webpack _require _ _ . e ( 779 ) ] ) . then ( _ _webpack _require _ _ . bind ( _ _webpack _require _ _ , 5779 ) ) ;
const restored = await restoreJdk ( jdkCache ) ;
if ( restored ) {
const restoredPath = this . getRestoredJdkPath ( javaRelease . version ) ;
if ( restoredPath ) {
foundJava = {
version : javaRelease . version ,
path : restoredPath
} ;
}
}
}
if ( ! foundJava || foundJava . version !== javaRelease . version ) {
core /* info */ . pq ( 'Trying to download...' ) ;
foundJava = await this . downloadTool ( javaRelease ) ;
core /* info */ . pq ( ` Java ${ foundJava . version } was downloaded ` ) ;
if ( jdkCache ) {
// Register after the installation exists so its identity is
// captured; the post-job save refuses to upload a path whose
// installation was replaced afterwards.
const { registerJdk } = await Promise . all ( /* import() */ [ _ _webpack _require _ _ . e ( 824 ) , _ _webpack _require _ _ . e ( 971 ) , _ _webpack _require _ _ . e ( 779 ) ] ) . then ( _ _webpack _require _ _ . bind ( _ _webpack _require _ _ , 5779 ) ) ;
registerJdk ( jdkCache ) ;
}
}
2026-07-29 17:53:33 -04:00
}
}
catch ( error ) {
this . logSetupError ( error ) ;
throw error ;
}
}
if ( ! foundJava ) {
throw new Error ( 'Failed to resolve Java version' ) ;
}
// JDK folder may contain postfix "Contents/Home" on macOS
const macOSPostfixPath = external _path _default ( ) . join ( foundJava . path , constants /* MACOS_JAVA_CONTENT_POSTFIX */ . PG ) ;
if ( process . platform === 'darwin' && external _fs _ . existsSync ( macOSPostfixPath ) ) {
foundJava . path = macOSPostfixPath ;
}
if ( this . setDefault ) {
core /* info */ . pq ( ` Setting Java ${ foundJava . version } as the default ` ) ;
this . setJavaDefault ( foundJava . version , foundJava . path ) ;
}
else {
core /* info */ . pq ( ` Installing Java ${ foundJava . version } (not setting as default) ` ) ;
this . setJavaEnvironment ( foundJava . version , foundJava . path ) ;
}
return foundJava ;
}
logSetupError ( error ) {
const httpStatusCode = error instanceof tool _cache /* HTTPError */ . Hl
? error . httpStatusCode
: error instanceof lib /* HttpClientError */ . Kg
? error . statusCode
: undefined ;
if ( httpStatusCode ) {
if ( httpStatusCode === 403 ) {
core /* error */ . z3 ( 'HTTP 403: Permission denied or access restricted.' ) ;
}
else if ( httpStatusCode === 429 ) {
core /* warning */ . $e ( 'HTTP 429: Rate limit exceeded. Please retry later.' ) ;
}
else {
core /* error */ . z3 ( ` HTTP ${ httpStatusCode } : ${ error . message } ` ) ;
}
}
else if ( error && error . errors && Array . isArray ( error . errors ) ) {
core /* error */ . z3 ( ` Java setup failed due to network or configuration error(s) ` ) ;
if ( error instanceof Error && error . stack ) {
core /* debug */ . Yz ( error . stack ) ;
}
for ( const err of error . errors ) {
const endpoint = err ? . address || err ? . hostname || '' ;
const port = err ? . port ? ` : ${ err . port } ` : '' ;
const message = err ? . message || 'Aggregate error' ;
const endpointInfo = ! message . includes ( endpoint )
? ` ${ endpoint } ${ port } `
: '' ;
const localInfo = err . localAddress && err . localPort
? ` - Local ( ${ err . localAddress } : ${ err . localPort } ) `
: '' ;
const logMessage = ` ${ message } ${ endpointInfo } ${ localInfo } ` ;
core /* error */ . z3 ( logMessage ) ;
core /* debug */ . Yz ( ` ${ err . stack || err . message } ` ) ;
Object . entries ( err ) . forEach ( ( [ key , value ] ) => {
core /* debug */ . Yz ( ` " ${ key } ": ${ JSON . stringify ( value ) } ` ) ;
} ) ;
}
}
else {
const message = error instanceof Error ? error . message : JSON . stringify ( error ) ;
core /* error */ . z3 ( ` Java setup process failed due to: ${ message } ` ) ;
if ( typeof error ? . code === 'string' ) {
core /* debug */ . Yz ( error . stack ) ;
}
const errorDetails = {
name : error . name ,
message : error . message ,
... Object . getOwnPropertyNames ( error )
. filter ( prop => ! [ 'name' , 'message' , 'stack' ] . includes ( prop ) )
. reduce ( ( acc , prop ) => {
acc [ prop ] = error [ prop ] ;
return acc ;
} , { } )
} ;
Object . entries ( errorDetails ) . forEach ( ( [ key , value ] ) => {
core /* debug */ . Yz ( ` " ${ key } ": ${ JSON . stringify ( value ) } ` ) ;
} ) ;
}
}
get toolcacheFolderName ( ) {
return ` Java_ ${ this . distribution } _ ${ this . packageType } ` ;
}
supportsSignatureVerification ( ) {
return false ;
}
getToolcacheVersionName ( version ) {
if ( ! this . stable ) {
if ( version . includes ( '+' ) ) {
return version . replace ( '+' , '-ea.' ) ;
}
else {
return ` ${ version } -ea ` ;
}
}
// Kotlin and some Java dependencies don't work properly when Java path contains "+" sign
// so replace "/hostedtoolcache/Java/11.0.3+4/x64" to "/hostedtoolcache/Java/11.0.3-4/x64" when saves to cache
// related issue: https://github.com/actions/virtual-environments/issues/3014
return version . replace ( '+' , '-' ) ;
}
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
getJdkCachePath ( version ) {
const toolCache = process . env [ 'RUNNER_TOOL_CACHE' ] ;
if ( ! toolCache ) {
return '' ;
}
return external _path _default ( ) . join ( toolCache , this . toolcacheFolderName , this . getToolcacheVersionName ( version ) ) ;
}
getRestoredJdkPath ( version ) {
const basePath = this . getJdkCachePath ( version ) ;
if ( ! basePath ) {
return null ;
}
const architecturePath = external _path _default ( ) . join ( basePath , this . architecture ) ;
return external _fs _ . existsSync ( architecturePath ) &&
external _fs _ . existsSync ( ` ${ architecturePath } .complete ` )
? architecturePath
: null ;
}
getJdkReleaseIdentity ( javaRelease ) {
if ( javaRelease . checksum ) {
return ` ${ javaRelease . checksum . algorithm } : ${ javaRelease . checksum . value } ` ;
}
try {
const url = new URL ( javaRelease . url ) ;
return ` ${ url . origin } ${ url . pathname } ` ;
}
catch {
return javaRelease . url ;
}
}
2026-07-29 17:53:33 -04:00
findInToolcache ( ) {
// we can't use tc.find directly because firstly, we need to filter versions by stability flag
// if *-ea is provided, take only ea versions from toolcache, otherwise - only stable versions
const availableVersions = tool _cache /* findAllVersions */ . iq ( this . toolcacheFolderName , this . architecture )
. map ( item => {
return {
version : item
. replace ( '-ea.' , '+' )
. replace ( /-ea$/ , '' )
// Kotlin and some Java dependencies don't work properly when Java path contains "+" sign
// so replace "/hostedtoolcache/Java/11.0.3-4/x64" to "/hostedtoolcache/Java/11.0.3+4/x64" when retrieves to cache
// related issue: https://github.com/actions/virtual-environments/issues/3014
. replace ( '-' , '+' ) ,
path : ( 0 , util /* getToolcachePath */ . yH ) ( this . toolcacheFolderName , item , this . architecture ) || '' ,
stable : ! item . includes ( '-ea' )
} ;
} )
. filter ( item => item . stable === this . stable ) ;
const satisfiedVersions = availableVersions
. filter ( item => ( 0 , util /* isVersionSatisfies */ . y ) ( this . version , item . version ) )
. filter ( item => item . path )
. sort ( ( a , b ) => {
return - semver _default ( ) . compareBuild ( a . version , b . version ) ;
} ) ;
if ( ! satisfiedVersions || satisfiedVersions . length === 0 ) {
return null ;
}
return {
version : satisfiedVersions [ 0 ] . version ,
path : satisfiedVersions [ 0 ] . path
} ;
}
normalizeVersion ( version ) {
let stable = true ;
const latest = false ;
// Support the `latest` alias (case-insensitive), which floats to the newest
// available stable/GA release. It is translated to the SemVer wildcard `x`
// so the existing "newest satisfying version wins" resolution applies.
const normalized = version . trim ( ) . toLowerCase ( ) ;
if ( normalized === 'latest' ) {
return {
version : 'x' ,
stable : true ,
latest : true
} ;
}
// Reject `latest` combined with any qualifier (e.g. `latest-ea`). Such inputs
// would otherwise have their `-ea` suffix stripped and fall through to the
// generic SemVer check, which fails with a confusing "'latest' is not valid
// SemVer" message even though `latest` is a supported value. Fail early with a
// targeted explanation instead.
if ( normalized . startsWith ( 'latest' ) ) {
throw new Error ( ` The 'latest' alias resolves stable (GA) releases only and cannot be combined with '-ea' or other qualifiers (received ' ${ version } '). Use 'latest' on its own, or specify a concrete version. ` ) ;
}
if ( version . endsWith ( '-ea' ) ) {
version = version . replace ( /-ea$/ , '' ) ;
stable = false ;
}
else if ( version . includes ( '-ea.' ) ) {
// transform '11.0.3-ea.2' -> '11.0.3+2'
version = version . replace ( '-ea.' , '+' ) ;
stable = false ;
}
// Java uses a versioning scheme (JEP 322) that can contain more numeric
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
// exact versions to SemVer build notation ('18.0.1+1') so they are
// accepted. Ranges and versions that already carry build metadata are
// left untouched.
if ( /^\d+(\.\d+){3,}$/ . test ( version ) ) {
version = ( 0 , util /* convertVersionToSemver */ . ZY ) ( version ) ;
}
if ( ! semver _default ( ) . validRange ( version ) ) {
throw new Error ( ` The string ' ${ version } ' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information ` ) ;
}
return {
version ,
stable ,
latest
} ;
}
createVersionNotFoundError ( versionOrRange , availableVersions , additionalContext ) {
const parts = [
` No matching version found for SemVer ' ${ versionOrRange } '. ` ,
` Distribution: ${ this . distribution } ` ,
` Package type: ${ this . packageType } ` ,
` Architecture: ${ this . architecture } `
] ;
// Add additional context if provided (e.g., platform/OS info)
if ( additionalContext ) {
parts . push ( additionalContext ) ;
}
if ( availableVersions && availableVersions . length > 0 ) {
const maxVersionsToShow = core /* isDebug */ . _o ( ) ? availableVersions . length : 50 ;
const versionsToShow = availableVersions . slice ( 0 , maxVersionsToShow ) ;
const truncated = availableVersions . length > maxVersionsToShow ;
parts . push ( ` Available versions: ${ versionsToShow . join ( ', ' ) } ${ truncated ? ', ...' : '' } ` ) ;
if ( truncated ) {
parts . push ( ` (showing first ${ maxVersionsToShow } of ${ availableVersions . length } versions, enable debug mode to see all) ` ) ;
}
}
const error = new Error ( parts . join ( '\n' ) ) ;
error . name = 'VersionNotFoundError' ;
return error ;
}
setJavaDefault ( version , toolPath ) {
core /* exportVariable */ . dN ( 'JAVA_HOME' , toolPath ) ;
core /* addPath */ . fM ( external _path _default ( ) . join ( toolPath , 'bin' ) ) ;
this . setJavaEnvironment ( version , toolPath ) ;
}
setJavaEnvironment ( version , toolPath ) {
const majorVersion = version . split ( '.' ) [ 0 ] ;
core /* setOutput */ . uH ( 'distribution' , this . distribution ) ;
core /* setOutput */ . uH ( 'path' , toolPath ) ;
core /* setOutput */ . uH ( 'version' , version ) ;
core /* exportVariable */ . dN ( ` JAVA_HOME_ ${ majorVersion } _ ${ this . architecture . toUpperCase ( ) } ` , toolPath ) ;
}
distributionArchitecture ( ) {
return this . architecture ;
}
}
/***/ } )
} ;