Skip to content

Commit feb9155

Browse files
authored
feat(amazonq code transform): accept java 17 projects #5860
## Problem /transform feature can only accept java 8/11 projects. ## Solution Updating user form to allow jdk 17 as source version.
1 parent 545dc4f commit feb9155

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Code Transform: Enable support for Java 17 projects."
4+
}

packages/core/src/amazonq/webview/ui/tabs/constants.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ I can help you with the following tasks:
4242
- Convert embedded SQL from Oracle databases to PostgreSQL
4343
4444
What would you like to do? You can enter 'language upgrade' or 'SQL conversion'.`
45-
: `Welcome to code transformation!
46-
47-
I can help you upgrade your Java 8 and 11 codebases to Java 17.`,
45+
: `Welcome to code transformation!`,
4846
},
4947
}

packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ export class Messenger {
191191
value: JDKVersion.JDK11,
192192
label: JDKVersion.JDK11,
193193
},
194+
{
195+
value: JDKVersion.JDK17,
196+
label: JDKVersion.JDK17,
197+
},
194198
{
195199
value: JDKVersion.UNSUPPORTED,
196200
label: 'Other',

packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ export default class MessengerUtils {
4444
} else if (os.platform() === 'darwin') {
4545
const jdkVersion = transformByQState.getSourceJDKVersion()
4646
if (jdkVersion === JDKVersion.JDK8) {
47-
javaHomePrompt += ` ${CodeWhispererConstants.macJava8HomeHelpChatMessage}`
47+
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(1.8)}`
4848
} else if (jdkVersion === JDKVersion.JDK11) {
49-
javaHomePrompt += ` ${CodeWhispererConstants.macJava11HomeHelpChatMessage}`
49+
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(11)}`
50+
} else if (jdkVersion === JDKVersion.JDK17) {
51+
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(17)}`
5052
}
5153
} else {
5254
javaHomePrompt += ` ${CodeWhispererConstants.linuxJavaHomeHelpChatMessage}`

packages/core/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ async function validateJavaHome(): Promise<boolean> {
174174
javaVersionUsedByMaven = JDKVersion.JDK8
175175
} else if (javaVersionUsedByMaven === '11.') {
176176
javaVersionUsedByMaven = JDKVersion.JDK11
177+
} else if (javaVersionUsedByMaven === '17.') {
178+
javaVersionUsedByMaven = JDKVersion.JDK17
177179
}
178180
}
179181
if (javaVersionUsedByMaven !== transformByQState.getSourceJDKVersion()) {

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ export const buildSucceededNotification =
504504
export const absolutePathDetectedMessage = (numPaths: number, buildFile: string, listOfPaths: string) =>
505505
`I detected ${numPaths} potential absolute file path(s) in your ${buildFile} file: **${listOfPaths}**. Absolute file paths might cause issues when I build your code. Any errors will show up in the build log.`
506506

507-
export const unsupportedJavaVersionChatMessage = `Sorry, currently I can only upgrade Java 8 or Java 11 projects. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
507+
export const unsupportedJavaVersionChatMessage = `I can only upgrade Java 8, Java 11, or Java 17 projects. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
508508

509509
export const selectSQLMetadataFileHelpMessage =
510510
'Next, I need the zipped metadata file from your schema conversion. You can download the metadata by going to your migration project in the AWS DMS console. Open the schema conversion and choose **Convert the embedded SQL in your application**. You can downloaded the metadata from Amazon S3 in the {schema-conversion-project}/ directory.'
@@ -590,9 +590,9 @@ export const jobPartiallyCompletedChatMessage =
590590
export const jobPartiallyCompletedNotification =
591591
'Amazon Q upgraded part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation.'
592592

593-
export const noPomXmlFoundChatMessage = `Sorry, I couldn\'t find a project that I can upgrade. I couldn\'t find a pom.xml file in any of your open projects. Currently, I can only upgrade Java 8 or Java 11 projects built on Maven. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
593+
export const noPomXmlFoundChatMessage = `I couldn\'t find a project that I can upgrade. Your Java project must be built on Maven and contain a pom.xml file. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
594594

595-
export const noPomXmlFoundNotification = `None of your open projects are supported by Amazon Q Code Transformation. Amazon Q could not find a pom.xml file in any of your open projects. Currently, Amazon Q can only upgrade Java 8 or Java 11 projects built on Maven. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
595+
export const noPomXmlFoundNotification = `None of your open modules are supported for code transformation with Amazon Q. A pom.xml is required for transformation.`
596596

597597
export const noJavaHomeFoundChatMessage = `Sorry, I couldn\'t locate your Java installation. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
598598

@@ -630,9 +630,9 @@ export const changesAppliedChatMessage = 'I applied the changes to your project.
630630

631631
export const changesAppliedNotification = 'Amazon Q applied the changes to your project.'
632632

633-
export const noOpenProjectsFoundChatMessage = `Sorry, I couldn\'t find a project that I can upgrade. Currently, I can only upgrade Java 8 or Java 11 projects built on Maven. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
633+
export const noOpenProjectsFoundChatMessage = `I couldn\'t find a project that I can upgrade. Currently, I support Java 8, Java 11, and Java 17 projects built on Maven. Make sure your project is open in the IDE. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
634634

635-
export const noJavaProjectsFoundChatMessage = `Sorry, I couldn\'t find a project that I can upgrade. Currently, I can only upgrade Java 8 or Java 11 projects built on Maven. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
635+
export const noJavaProjectsFoundChatMessage = `I couldn\'t find a project that I can upgrade. Currently, I support Java 8, Java 11, and Java 17 projects built on Maven. Make sure your project is open in the IDE. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
636636

637637
export const linkToDocsHome = 'https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
638638

@@ -657,11 +657,8 @@ export const projectPromptChatMessage =
657657
export const windowsJavaHomeHelpChatMessage =
658658
'To find the JDK path, run the following commands in a new terminal: `cd "C:/Program Files/Java"` and then `dir`. If you see your JDK version, run `cd <version>` and then `cd` to show the path.'
659659

660-
export const macJava8HomeHelpChatMessage =
661-
'To find the JDK path, run the following command in a new terminal: `/usr/libexec/java_home -v 1.8`'
662-
663-
export const macJava11HomeHelpChatMessage =
664-
'To find the JDK path, run the following command in a new terminal: `/usr/libexec/java_home -v 11`'
660+
export const macJavaVersionHomeHelpChatMessage = (version: number) =>
661+
`To find the JDK path, run the following command in a new terminal: \`/usr/libexec/java_home -v ${version}\``
665662

666663
export const linuxJavaHomeHelpChatMessage =
667664
'To find the JDK path, run the following command in a new terminal: `update-java-alternatives --list`'

0 commit comments

Comments
 (0)