-
Notifications
You must be signed in to change notification settings - Fork 91
Remind users to upgrade old (<21) Java and EOL Spring Boot/Framework versions #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3872005
5574787
3988de5
bf7eb04
18be55e
560048c
0503046
b2406d9
fa488ef
9fbc1c2
c3ee610
0e998ba
3b62771
9043db4
06c14d9
1fac1f0
97a044a
a554cca
67fba26
c667fa2
cda24ca
5817721
f6db20c
4bc2e93
b93017d
2da82b0
802f9de
82aaf05
887261c
535e190
6655cd8
cabb469
7c606cb
4bdc6d6
81b9905
76a8261
56084e6
28d2ee4
2789537
1f0a36f
fbe2d5f
790a5ea
1872705
e9b6917
e25d0b6
46f78a8
c2c4cf6
1c1fef6
a370292
03c85fb
daf65c5
12f8a9b
4bec023
f7f2d29
6af3122
a64a3c8
1386bfb
fa0fe9e
5e0f4b0
9fa24f9
1456262
efdff83
2578194
731d86a
803be9b
aea445f
430f7e8
440e92e
478d871
4397ccc
a0abeb9
4d271c1
3b09680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please only make necessary changes to reduce the size of of the PR. In this file, the only change is the inserted line of:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting are restored in c2c4cf6. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import * as semver from 'semver'; | ||
| import { Jdtls } from "../java/jdtls"; | ||
| import { NodeKind, type INodeData } from "../java/nodeData"; | ||
| import { type DependencyCheckItem, UpgradeReason, type UpgradeIssue } from "./type"; | ||
| import { DEPENDENCY_JAVA_RUNTIME } from "./dependency.metadata"; | ||
| import { Upgrade } from '../constants'; | ||
| import { buildPackageId } from './utility'; | ||
| import metadataManager from './metadataManager'; | ||
| import { sendInfo } from 'vscode-extension-telemetry-wrapper'; | ||
|
|
||
| function getJavaIssues(data: INodeData): UpgradeIssue[] { | ||
| const javaVersion = data.metaData?.MaxSourceVersion as number | undefined; | ||
| const { name, supportedVersion } = DEPENDENCY_JAVA_RUNTIME; | ||
| if (!javaVersion) { | ||
| return []; | ||
| } | ||
| const currentSemVer = semver.coerce(javaVersion); | ||
| if (currentSemVer && !semver.satisfies(currentSemVer, supportedVersion)) { | ||
| return [{ | ||
| ...DEPENDENCY_JAVA_RUNTIME, | ||
| packageId: Upgrade.PACKAGE_ID_FOR_JAVA_RUNTIME, | ||
| packageDisplayName: name, | ||
| currentVersion: String(javaVersion), | ||
| }]; | ||
| } | ||
|
|
||
| return []; | ||
| } | ||
|
|
||
| function getUpgradeForDependency(versionString: string, supportedVersionDefinition: DependencyCheckItem, packageId: string): UpgradeIssue | null { | ||
| const { reason } = supportedVersionDefinition; | ||
| switch (reason) { | ||
| case UpgradeReason.DEPRECATED: { | ||
| return { | ||
| ...supportedVersionDefinition, | ||
| packageDisplayName: supportedVersionDefinition.name, | ||
| reason, | ||
| currentVersion: versionString, | ||
| packageId, | ||
| }; | ||
| } | ||
| case UpgradeReason.END_OF_LIFE: { | ||
| const currentSemVer = semver.coerce(versionString); | ||
| if (currentSemVer && !semver.satisfies(currentSemVer, supportedVersionDefinition.supportedVersion)) { | ||
| return { | ||
| ...supportedVersionDefinition, | ||
| packageDisplayName: supportedVersionDefinition.name, | ||
| reason, | ||
| currentVersion: versionString, | ||
| packageId, | ||
| }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| function getDependencyIssue(data: INodeData): UpgradeIssue | null { | ||
| const versionString = data.metaData?.["maven.version"]; | ||
| const groupId = data.metaData?.["maven.groupId"]; | ||
| const artifactId = data.metaData?.["maven.artifactId"]; | ||
| const packageId = buildPackageId(groupId, artifactId); | ||
| const supportedVersionDefinition = metadataManager.getMetadataById(packageId); | ||
| if (!versionString || !groupId || !supportedVersionDefinition) { | ||
| return null; | ||
| } | ||
|
|
||
| return getUpgradeForDependency(versionString, supportedVersionDefinition, packageId); | ||
| } | ||
|
|
||
| async function getDependencyIssues(projectNode: INodeData): Promise<UpgradeIssue[]> { | ||
| const projectStructureData = await Jdtls.getPackageData({ kind: NodeKind.Project, projectUri: projectNode.uri }); | ||
| const packageContainerIssues = await Promise.allSettled( | ||
| projectStructureData | ||
| .filter(x => x.kind === NodeKind.Container) | ||
| .map(async (packageContainer) => { | ||
| const packages = await Jdtls.getPackageData({ | ||
| kind: NodeKind.Container, | ||
| projectUri: projectNode.uri, | ||
| path: packageContainer.path, | ||
| }); | ||
|
|
||
| return packages.map(getDependencyIssue).filter((x): x is UpgradeIssue => Boolean(x)); | ||
| }) | ||
| ); | ||
|
|
||
| return packageContainerIssues | ||
| .map(x => { | ||
| if (x.status === "fulfilled") { | ||
| return x.value; | ||
| } | ||
|
|
||
| sendInfo("", { | ||
| operationName: "java.dependency.assessmentManager.getDependencyIssues", | ||
| }); | ||
| return []; | ||
| }) | ||
| .reduce((a, b) => [...a, ...b]); | ||
| } | ||
|
|
||
| async function getProjectIssues(projectNode: INodeData): Promise<UpgradeIssue[]> { | ||
| const issues: UpgradeIssue[] = []; | ||
| issues.push(...getJavaIssues(projectNode)); | ||
| issues.push(...(await getDependencyIssues(projectNode))); | ||
| return issues; | ||
| } | ||
|
|
||
| async function getWorkspaceIssues(workspaceFolderUri: string): Promise<UpgradeIssue[]> { | ||
| const projects = await Jdtls.getProjects(workspaceFolderUri); | ||
| const projectsIssues = await Promise.allSettled(projects.map(async (projectNode) => { | ||
| const issues = await getProjectIssues(projectNode); | ||
| sendInfo("", { | ||
| operationName: "java.dependency.assessmentManager.getWorkspaceIssues", | ||
| issuesFoundForPackageId: JSON.stringify(issues.map(x => `${x.packageId}:${x.currentVersion}`)), | ||
| }); | ||
| return issues; | ||
| })); | ||
|
|
||
| const workspaceIssues = projectsIssues.map(x => { | ||
| if (x.status === "fulfilled") { | ||
| return x.value; | ||
| } | ||
|
|
||
| sendInfo("", { | ||
| operationName: "java.dependency.assessmentManager.getWorkspaceIssues", | ||
| }); | ||
| return []; | ||
| }).reduce((a, b) => [...a, ...b]); | ||
|
|
||
| return workspaceIssues; | ||
| } | ||
|
|
||
| export default { | ||
| getWorkspaceIssues, | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.