Skip to content

Commit 5ddf97c

Browse files
smoring2Xi Shenmanodnyab
authored
Amazon Q Transform: Always execute IDE bundled maven whenever maven command fails (#4084)
* always exe ide maven when mvn command fails due to any reasons * add log * Revert "add log" This reverts commit 4593989. * add log * fix the mvnw cmd for windows * Update CodeModernizerSessionContext.kt Co-authored-by: manodnyab <[email protected]> * resolve detekt issue * resolve detekt issue --------- Co-authored-by: Xi Shen <[email protected]> Co-authored-by: manodnyab <[email protected]>
1 parent 9fd13eb commit 5ddf97c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q Transform: Always execute IDE bundled maven whenever maven command fails"
4+
}

jetbrains-core/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.intellij.openapi.application.runInEdt
1212
import com.intellij.openapi.application.runReadAction
1313
import com.intellij.openapi.project.Project
1414
import com.intellij.openapi.projectRoots.JavaSdkVersion
15+
import com.intellij.openapi.util.SystemInfo
1516
import com.intellij.openapi.vfs.VfsUtil
1617
import com.intellij.openapi.vfs.VirtualFile
1718
import com.intellij.openapi.wm.ToolWindowManager
@@ -177,7 +178,12 @@ data class CodeModernizerSessionContext(
177178
LOG.warn { "Executing ./mvnw" }
178179
var shouldTryMvnCommand = true
179180
try {
180-
val output = runCommand("./mvnw")
181+
val mvnw = if (SystemInfo.isWindows) {
182+
"./mvnw.cmd"
183+
} else {
184+
"./mvnw"
185+
}
186+
val output = runCommand(mvnw)
181187
if (output.exitCode != 0) {
182188
LOG.error { "mvnw command output:\n$output" }
183189
val error = "The exitCode should be 0 while it was ${output.exitCode}"
@@ -224,7 +230,6 @@ data class CodeModernizerSessionContext(
224230
codeTransformMavenBuildCommand = CodeTransformMavenBuildCommand.Mvn,
225231
reason = error
226232
)
227-
return null
228233
} else {
229234
shouldTryMvnCommand = false
230235
LOG.warn { "Maven executed successfully" }
@@ -244,7 +249,6 @@ data class CodeModernizerSessionContext(
244249
reason = e.message
245250
)
246251
LOG.error(e) { e.message.toString() }
247-
throw e
248252
}
249253
}
250254

0 commit comments

Comments
 (0)