Skip to content

Commit a5a02ad

Browse files
author
David Hasani
committed
use exact build command, not flag
1 parent c218d8f commit a5a02ad

File tree

8 files changed

+16
-17
lines changed

8 files changed

+16
-17
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
667667
customerSelection.configurationFile,
668668
customerSelection.sourceJavaVersion,
669669
customerSelection.targetJavaVersion,
670-
customerSelection.skipTestsFlag
670+
customerSelection.customBuildCommand
671671
),
672672
)
673673

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private fun getUserSkipTestsFlagSelectionFormattedMarkdown(skipTestsSelection: S
175175
// just for correct grammar
176176
var skipTestsText = skipTestsSelection
177177
if (skipTestsText == "Do not skip tests") skipTestsText = "not skip tests"
178-
return "Got it! Amazon Q will ${skipTestsText.lowercase()} when building your project."
178+
return "Ok, I will ${skipTestsText.lowercase()} when building your project."
179179
}
180180

181181
private fun getUserHilSelectionMarkdown(dependencyName: String, currentVersion: String, selectedVersion: String): String = """

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,17 @@ class CodeTransformChatController(
224224
// should never happen since at this point user has already selected a module with a build file
225225
if (configurationFile == null) throw RuntimeException("No build file selected")
226226
val sourceJdk = getSourceJdk(configurationFile!!)
227-
val skipTestsFlag = when (message.skipTestsSelection) {
228-
"Do not skip tests" -> ""
229-
"Skip integration tests" -> "-DskipITs"
230-
"Skip all tests" -> "-DskipTests"
231-
else -> ""
227+
val customBuildCommand = when (message.skipTestsSelection) {
228+
"Skip integration tests" -> "test"
229+
"Skip all tests" -> "test-compile"
230+
else -> "verify"
232231
}
233232
codeTransformChatHelper.addNewMessage(buildUserSkipTestsFlagSelectionChatContent(message.skipTestsSelection))
234233
val selection = CustomerSelection(
235234
configurationFile!!,
236235
sourceJdk,
237236
JavaSdkVersion.JDK_17,
238-
skipTestsFlag
237+
customBuildCommand
239238
)
240239

241240
// Publish metric to capture user selection before local build starts

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ data class CodeModernizerSessionContext(
5353
val configurationFile: VirtualFile,
5454
val sourceJavaVersion: JavaSdkVersion,
5555
val targetJavaVersion: JavaSdkVersion,
56-
val skipTestsFlag: String,
56+
val customBuildCommand: String,
5757
) {
5858
private val mapper = jacksonObjectMapper()
5959
private val ignoredDependencyFileExtensions = setOf(INVALID_SUFFIX_SHA, INVALID_SUFFIX_REPOSITORIES)
@@ -201,7 +201,7 @@ data class CodeModernizerSessionContext(
201201
val outputFile = createTemporaryZipFile { zip ->
202202
// 1) Manifest file
203203
val dependenciesRoot = if (depDirectory != null) "$ZIP_DEPENDENCIES_PATH/${depDirectory.name}" else null
204-
mapper.writeValueAsString(ZipManifest(dependenciesRoot = dependenciesRoot, skipTestsFlag = skipTestsFlag))
204+
mapper.writeValueAsString(ZipManifest(dependenciesRoot = dependenciesRoot, customBuildCommand = customBuildCommand))
205205
.byteInputStream()
206206
.use {
207207
zip.putNextEntry(Path(MANIFEST_PATH).toString(), it)

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CustomerSelection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ data class CustomerSelection(
1010
val configurationFile: VirtualFile,
1111
val sourceJavaVersion: JavaSdkVersion,
1212
val targetJavaVersion: JavaSdkVersion,
13-
val skipTestsFlag: String,
13+
val customBuildCommand: String,
1414
)

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/ZipManifest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ data class ZipManifest(
1616
val version: String = UPLOAD_ZIP_MANIFEST_VERSION.toString(),
1717
val hilCapabilities: List<String> = listOf(HIL_1P_UPGRADE_CAPABILITY),
1818
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1),
19-
val skipTestsFlag: String = "",
19+
val customBuildCommand: String = "",
2020
)

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/state/CodeModernizerState.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum class JobDetails {
1616
CONFIGURATION_FILE_PATH,
1717
TARGET_JAVA_VERSION,
1818
SOURCE_JAVA_VERSION,
19-
SKIP_TESTS_FLAG,
19+
CUSTOM_BUILD_COMMAND,
2020
}
2121

2222
enum class StateFlags {
@@ -30,7 +30,7 @@ fun buildState(context: CodeModernizerSessionContext, isJobOngoing: Boolean, job
3030
JobDetails.CONFIGURATION_FILE_PATH to context.configurationFile.path,
3131
JobDetails.TARGET_JAVA_VERSION to context.targetJavaVersion.description,
3232
JobDetails.SOURCE_JAVA_VERSION to context.sourceJavaVersion.description,
33-
JobDetails.SKIP_TESTS_FLAG to context.skipTestsFlag
33+
JobDetails.CUSTOM_BUILD_COMMAND to context.customBuildCommand
3434
)
3535
)
3636
flags.putAll(
@@ -58,6 +58,6 @@ class CodeModernizerState : BaseState() {
5858
lastJobContext[JobDetails.SOURCE_JAVA_VERSION] ?: throw RuntimeException("Expected source language for migration path of previous job but was null")
5959
val targetJavaSdkVersion = JavaSdkVersion.fromVersionString(targetString) ?: throw RuntimeException("Invalid Java SDK version $targetString")
6060
val sourceJavaSdkVersion = JavaSdkVersion.fromVersionString(sourceString) ?: throw RuntimeException("Invalid Java SDK version $sourceString")
61-
return CodeModernizerSessionContext(project, configurationFile, sourceJavaSdkVersion, targetJavaSdkVersion, lastJobContext[JobDetails.SKIP_TESTS_FLAG] ?: "")
61+
return CodeModernizerSessionContext(project, configurationFile, sourceJavaSdkVersion, targetJavaSdkVersion, lastJobContext[JobDetails.CUSTOM_BUILD_COMMAND] ?: "")
6262
}
6363
}

plugins/amazonq/codetransform/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codemodernizer/CodeWhispererCodeModernizerSessionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class CodeWhispererCodeModernizerSessionTest : CodeWhispererCodeModernizerTestBa
143143
assertFalse(roots.isEmpty() || roots.size > 1)
144144
assert(rootManager.dependencies.isEmpty())
145145
val root = roots[0]
146-
val context = CodeModernizerSessionContext(project, root.children[0], JavaSdkVersion.JDK_1_8, JavaSdkVersion.JDK_11, "-DskipTests")
146+
val context = CodeModernizerSessionContext(project, root.children[0], JavaSdkVersion.JDK_1_8, JavaSdkVersion.JDK_11, "test-compile")
147147
val mockFile = mock(File::class.java)
148148
val mockStringBuilder = mock(StringBuilder::class.java)
149149
val file = runInEdtAndGet {
@@ -158,7 +158,7 @@ class CodeWhispererCodeModernizerSessionTest : CodeWhispererCodeModernizerTestBa
158158
when (Path(entry.name)) {
159159
Path("manifest.json") -> {
160160
assertNotNull(fileContent)
161-
assertTrue(fileContent.contains("-DskipTests"))
161+
assertTrue(fileContent.contains("test-compile"))
162162
}
163163
Path("sources/src/tmp.txt") -> assertEquals(fileText, fileContent)
164164
Path("build-logs.txt") -> assertNotNull(fileContent)

0 commit comments

Comments
 (0)