-
Notifications
You must be signed in to change notification settings - Fork 89
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
Open
FluoriteCafe-work
wants to merge
48
commits into
microsoft:main
Choose a base branch
from
FluoriteCafe-work:feat/java-upgrade-tool-notification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
3872005
feat(jdtls): add `PomPath` to metadata
FluoriteCafe-work 5574787
feat: MetadataManager
FluoriteCafe-work 3988de5
feat: add command `triggerJavaUpgradeTool`
FluoriteCafe-work bf7eb04
feat: NotificationManager
FluoriteCafe-work 18be55e
feat: IssueManager
FluoriteCafe-work 560048c
feat(upgradeManager): collect issues on load and workspace folder update
FluoriteCafe-work 0503046
feat: integrate the flow
FluoriteCafe-work b2406d9
feat: add context menu to open modernization tool
FluoriteCafe-work fa488ef
fix: only show modernization menu when related extension is installed
FluoriteCafe-work 9fbc1c2
fix: typo
FluoriteCafe-work c3ee610
chore: fmt
FluoriteCafe-work 0e998ba
feat: control reminder display by settings
FluoriteCafe-work 3b62771
feat: don't scan when upgrade extension does not exist
FluoriteCafe-work 9043db4
chore: make class methods static as there are no states here
FluoriteCafe-work 06c14d9
fix: typo
FluoriteCafe-work 1fac1f0
chore: add copyright headers
FluoriteCafe-work 97a044a
chore: skip package dependency check when JRE version issue is found
FluoriteCafe-work a554cca
chore: check Settings first as it's cheaper (?)
FluoriteCafe-work 67fba26
chore: revise fix prompts
FluoriteCafe-work c667fa2
chore: call `javaupgrade.gotoAgentMode` to trigger prompts
FluoriteCafe-work cda24ca
feat: revise notification message
FluoriteCafe-work 5817721
fix: only trigger notification on the first issue found
FluoriteCafe-work f6db20c
feat: allow "Not Now" or "Don't Show Again" for notifications
FluoriteCafe-work 4bc2e93
fix(upgradeManager): command calling
FluoriteCafe-work b93017d
chore: Java uses the word `runtime` instead of `engine`
FluoriteCafe-work 2da82b0
chore: remove debug strings
FluoriteCafe-work 802f9de
feat: support deprecated dependencies (and add Java EE as an example)
FluoriteCafe-work 82aaf05
fix: use 21 when showing latest version
FluoriteCafe-work 887261c
chore: string polishment
FluoriteCafe-work 535e190
fix: fix prompt version insertion issues
FluoriteCafe-work 6655cd8
chore: centralize JRE metadata together
FluoriteCafe-work cabb469
chore: rename settings `java.dependency.showUpgradeReminder` -> `java…
FluoriteCafe-work 7c606cb
fix: only show Modernize Java Project under Java project environment
FluoriteCafe-work 4bdc6d6
chore: `java.view.modernizeJavaProject` -> `_java.view.modernizeJavaP…
FluoriteCafe-work 81b9905
chore: `java.view.triggerJavaUpgradeTool` -> `_java.upgrade.triggerUp…
FluoriteCafe-work 76a8261
chore: change JRE package ID to `java:*`
FluoriteCafe-work 56084e6
chore: centralize `LATEST_JAVA_LTS_VESRION` and `SESSION_COUNT_BEFORE…
FluoriteCafe-work 28d2ee4
chore: `_java.upgrade.triggerUpgrade` -> `_java.upgradeWithCopilot`
FluoriteCafe-work 2789537
chore: no need for `PomPath`
FluoriteCafe-work 1f0a36f
fix(notificationManager): use settings to control whether to send not…
FluoriteCafe-work fbe2d5f
chore: split assessment part to `assessmentManager`
FluoriteCafe-work 790a5ea
feat: use `DisplayInterface` to organize user faced presentations
FluoriteCafe-work 1872705
chore: string improvements
FluoriteCafe-work e9b6917
chore: get all issues for notification
FluoriteCafe-work e25d0b6
feat: add telemetry
FluoriteCafe-work 46f78a8
fix: add current version to telemetry
FluoriteCafe-work c2c4cf6
chore: restore formatting
FluoriteCafe-work 1c1fef6
fix: pass `suggestedVersion` to `UpgradeIssue`
FluoriteCafe-work File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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[] { | ||
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)) | ||
} | ||
); | ||
}) | ||
); | ||
return issues; | ||
} | ||
|
||
export default { | ||
getProjectIssues | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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.
Show resolved
Hide resolved
|
||
"org.springframework.boot:*": { | ||
"reason": UpgradeReason.END_OF_LIFE, | ||
"name": "Spring Boot", | ||
"supportedVersion": "2.7.x || >=3.2.x", | ||
"suggestedVersion": "6.2", | ||
}, | ||
"org.springframework:*": { | ||
"reason": UpgradeReason.END_OF_LIFE, | ||
"name": "Spring Framework", | ||
"supportedVersion": "5.3.x || >=6.2.x", | ||
"suggestedVersion": "3.5" | ||
}, | ||
"javax:javaee-api": { | ||
"reason": UpgradeReason.DEPRECATED, | ||
"name": "Java EE", | ||
"alternative": "Jakarta EE 10", | ||
}, | ||
"javax:javaee-web-api": { | ||
"reason": UpgradeReason.DEPRECATED, | ||
"name": "Java EE", | ||
"alternative": "Jakarta EE 10", | ||
}, | ||
[Upgrade.PACKAGE_ID_FOR_JAVA_RUNTIME]: DEPENDENCY_JAVA_RUNTIME, | ||
}; | ||
|
||
export default DEPENDENCIES_TO_SCAN; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting are restored in c2c4cf6.