Skip to content

Commit b5f6ce1

Browse files
committed
fix the issue that workspace has the same name with prject, the dir is not found
1 parent d195b1a commit b5f6ce1

File tree

1 file changed

+11
-3
lines changed
  • plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/utils

1 file changed

+11
-3
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/utils/UTGChatUtil.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,25 @@ fun runBuildOrTestCommand(
9898

9999
// Find the nearest Gradle root directory
100100
var packageRoot: File? = testFileAbsolutePath.parentFile
101+
var foundGradleRoot = false
101102
while (packageRoot != null && packageRoot != projectRoot) {
102103
if (File(packageRoot, "settings.gradle.kts").exists() || File(packageRoot, "build.gradle.kts").exists() ||
103104
File(packageRoot, "settings.gradle").exists() || File(packageRoot, "build.gradle").exists()
104105
) {
105-
break // Stop when we find a valid Gradle project root
106+
foundGradleRoot = true
107+
break// Store the last valid Gradle root found
106108
}
107109
packageRoot = packageRoot.parentFile
108110
}
111+
var workingDir = if(foundGradleRoot){
112+
packageRoot ?: testFileAbsolutePath.parentFile
113+
}else {
114+
testFileAbsolutePath.parentFile
115+
}
116+
117+
109118
// If no valid Gradle directory is found, fallback to the project root
110-
val gradleWrapper = File(packageRoot, "gradlew")
111-
val workingDir = if (gradleWrapper.exists()) packageRoot else projectRoot
119+
val gradleWrapper = File(packageRoot ?: projectRoot, "gradlew")
112120
val console: ConsoleView = ConsoleViewImpl(project, true)
113121

114122
// Attach Console View to Build Tool Window

0 commit comments

Comments
 (0)