MCPcopy Index your code
hub / github.com/github/awesome-copilot / detectJavaVersion

Function detectJavaVersion

extensions/java-modernization-studio/scan.mjs:334–350  ·  view source on GitHub ↗
(pom, gradle)

Source from the content-addressed store, hash-verified

332}
333
334function detectJavaVersion(pom, gradle) {
335 const text = `${pom || ""}\n${gradle || ""}`;
336 const grab = (re) => {
337 const m = text.match(re);
338 return m ? m[1].replace(/^1\./, "") : null;
339 };
340 return (
341 grab(/<maven\.compiler\.release>\s*([\d.]+)\s*</) ||
342 grab(/<maven\.compiler\.source>\s*([\d.]+)\s*</) ||
343 grab(/<java\.version>\s*([\d.]+)\s*</) ||
344 grab(/<source>\s*([\d.]+)\s*</) ||
345 grab(/<release>\s*([\d.]+)\s*</) ||
346 grab(/sourceCompatibility\s*=?\s*['"]?(?:JavaVersion\.VERSION_)?([\d.]+)/) ||
347 grab(/languageVersion[^)]*?(\d+)/) ||
348 null
349 );
350}
351
352// Match a dependency signature against build text. Plain substring matching makes
353// short alpha tokens dangerous ("ant" used to hit "important/constant", and a bare

Callers 1

buildAssessmentFunction · 0.85

Calls 1

grabFunction · 0.85

Tested by

no test coverage detected