-
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 50 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,104 @@ | ||
| // 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.data"; | ||
| import { Upgrade } from '../constants'; | ||
| import { buildPackageId } from './utility'; | ||
| import metadataManager from './metadataManager'; | ||
|
|
||
| function getJavaIssues(data: INodeData): UpgradeIssue[] { | ||
| const javaVersion = data.metaData?.MaxSourceVersion as number | undefined; | ||
| const { name, reason, supportedVersion, suggestedVersion } = DEPENDENCY_JAVA_RUNTIME; | ||
| if (!javaVersion) { | ||
| return []; | ||
| } | ||
| const currentSemVer = semver.coerce(javaVersion); | ||
| if (currentSemVer && !semver.satisfies(currentSemVer, supportedVersion)) { | ||
| return [{ | ||
| packageId: Upgrade.PACKAGE_ID_FOR_JAVA_RUNTIME, | ||
| packageDisplayName: name, | ||
| currentVersion: String(javaVersion), | ||
| reason, | ||
| suggestedVersion, | ||
| }]; | ||
| } | ||
|
|
||
| return []; | ||
| } | ||
|
|
||
| function getUpgrade(versionString: string, supportedVersionDefinition: DependencyCheckItem): Omit<UpgradeIssue, "packageId"> | null { | ||
FluoriteCafe-work marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const { reason } = supportedVersionDefinition; | ||
| switch (reason) { | ||
| case UpgradeReason.DEPRECATED: { | ||
| const { alternative } = supportedVersionDefinition; | ||
| return { | ||
| packageDisplayName: supportedVersionDefinition.name, | ||
| reason, | ||
| currentVersion: versionString, | ||
| suggestedVersion: alternative, | ||
| } | ||
| } | ||
| case UpgradeReason.END_OF_LIFE: { | ||
| const currentSemVer = semver.coerce(versionString); | ||
| if (currentSemVer && !semver.satisfies(currentSemVer, supportedVersionDefinition.supportedVersion)) { | ||
| return { | ||
| packageDisplayName: supportedVersionDefinition.name, | ||
| reason, | ||
| currentVersion: versionString, | ||
| suggestedVersion: supportedVersionDefinition.suggestedVersion, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| function getDependencyIssues(data: INodeData): UpgradeIssue[] { | ||
FluoriteCafe-work marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 []; | ||
| } | ||
|
|
||
| const upgrade = getUpgrade(versionString, supportedVersionDefinition); | ||
| if (upgrade) { | ||
| return [{ ...upgrade, packageId }]; | ||
| } | ||
| return []; | ||
| } | ||
|
|
||
| async function getProjectIssues(projectNode: INodeData): Promise<UpgradeIssue[]> { | ||
| const issues: UpgradeIssue[] = []; | ||
| issues.push(...getJavaIssues(projectNode)); | ||
| const packageData = await Jdtls.getPackageData({ kind: NodeKind.Project, projectUri: projectNode.uri }); | ||
| await Promise.allSettled( | ||
| packageData | ||
| .filter(x => x.kind === NodeKind.Container) | ||
| .map(async (packageContainer) => { | ||
| const packages = await Jdtls.getPackageData({ | ||
| kind: NodeKind.Container, | ||
| projectUri: projectNode.uri, | ||
| path: packageContainer.path, | ||
| }); | ||
| packages.forEach( | ||
| (pkg) => { | ||
| issues.push(...getDependencyIssues(pkg)) | ||
| } | ||
| ); | ||
| }) | ||
| ); | ||
FluoriteCafe-work marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return issues; | ||
| } | ||
|
|
||
| export default { | ||
| getProjectIssues | ||
| }; | ||
FluoriteCafe-work marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { Upgrade } from "../constants"; | ||
| import { UpgradeReason, type DependencyCheckMetadata } from "./type"; | ||
|
|
||
| const LATEST_JAVA_LTS_VESRION = 21; | ||
|
|
||
| export const DEPENDENCY_JAVA_RUNTIME = { | ||
| "name": "Java Runtime", | ||
| "reason": UpgradeReason.JRE_TOO_OLD, | ||
| "supportedVersion": `>=${LATEST_JAVA_LTS_VESRION}`, | ||
| "suggestedVersion": String(LATEST_JAVA_LTS_VESRION), | ||
| } as const; | ||
|
|
||
| const DEPENDENCIES_TO_SCAN: DependencyCheckMetadata = { | ||
FluoriteCafe-work marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "org.springframework.boot:*": { | ||
| "reason": UpgradeReason.END_OF_LIFE, | ||
| "name": "Spring Boot", | ||
| "supportedVersion": "2.7.x || >=3.2.x", | ||
| "suggestedVersion": "3.5", | ||
| }, | ||
| "org.springframework:*": { | ||
| "reason": UpgradeReason.END_OF_LIFE, | ||
| "name": "Spring Framework", | ||
| "supportedVersion": "5.3.x || >=6.2.x", | ||
| "suggestedVersion": "6.2" | ||
| }, | ||
| "org.springframework.security:*": { | ||
| "reason": UpgradeReason.END_OF_LIFE, | ||
| "name": "Spring Security", | ||
| "supportedVersion": "5.7.x || 5.8.x || >=6.2.x", | ||
| "suggestedVersion": "6.5" | ||
| }, | ||
| "javax:*": { | ||
| "reason": UpgradeReason.DEPRECATED, | ||
| "name": "Java EE", | ||
| "alternative": "Jakarta EE 10", | ||
| }, | ||
| [Upgrade.PACKAGE_ID_FOR_JAVA_RUNTIME]: DEPENDENCY_JAVA_RUNTIME, | ||
| }; | ||
|
|
||
| export default DEPENDENCIES_TO_SCAN; | ||
Uh oh!
There was an error while loading. Please reload this page.