MCPcopy Index your code
hub / github.com/actions/setup-java / findInToolcache

Function findInToolcache

src/distributions/base-installer.ts:197–236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

195 }
196
197 protected findInToolcache(): JavaInstallerResults | null {
198 // we can't use tc.find directly because firstly, we need to filter versions by stability flag
199 // if *-ea is provided, take only ea versions from toolcache, otherwise - only stable versions
200 const availableVersions = tc
201 .findAllVersions(this.toolcacheFolderName, this.architecture)
202 .map(item => {
203 return {
204 version: item
205 .replace('-ea.', '+')
206 .replace(/-ea$/, '')
207 // Kotlin and some Java dependencies don't work properly when Java path contains "+" sign
208 // so replace "/hostedtoolcache/Java/11.0.3-4/x64" to "/hostedtoolcache/Java/11.0.3+4/x64" when retrieves to cache
209 // related issue: https://github.com/actions/virtual-environments/issues/3014
210 .replace('-', '+'),
211 path:
212 getToolcachePath(
213 this.toolcacheFolderName,
214 item,
215 this.architecture
216 ) || '',
217 stable: !item.includes('-ea')
218 };
219 })
220 .filter(item => item.stable === this.stable);
221
222 const satisfiedVersions = availableVersions
223 .filter(item => isVersionSatisfies(this.version, item.version))
224 .filter(item => item.path)
225 .sort((a, b) => {
226 return -semver.compareBuild(a.version, b.version);
227 });
228 if (!satisfiedVersions || satisfiedVersions.length === 0) {
229 return null;
230 }
231
232 return {
233 version: satisfiedVersions[0].version,
234 path: satisfiedVersions[0].path
235 };
236 }
237
238 protected normalizeVersion(version: string) {
239 let stable = true;

Callers

nothing calls this directly

Calls 2

getToolcachePathFunction · 0.90
isVersionSatisfiesFunction · 0.90

Tested by

no test coverage detected