Skip to content

Commit d9b8944

Browse files
author
David Hasani
committed
more gradle updates
1 parent 1b41352 commit d9b8944

File tree

5 files changed

+724
-29
lines changed

5 files changed

+724
-29
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ class CodeTransformChatApp : AmazonQApp {
152152
}
153153

154154
private suspend fun handleMessage(message: AmazonQMessage, inboundAppMessagesHandler: InboundAppMessagesHandler) {
155-
notifyStickyInfo("message info", "message = $message")
156155
when (message) {
157156
is IncomingCodeTransformMessage.Transform -> inboundAppMessagesHandler.processTransformQuickAction(message)
158157
is IncomingCodeTransformMessage.CodeTransformStart -> inboundAppMessagesHandler.processCodeTransformStartAction(message)

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

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,24 +234,18 @@ fun buildUserBuildSystemSelectionChatContent(buildSystem: String) = CodeTransfor
234234
message = getUserBuildSystemSelectionFormattedMarkdown(buildSystem)
235235
)
236236

237-
fun buildUserInputChatContent(project: Project, validationResult: ValidationResult): CodeTransformChatMessageContent {
238-
val moduleBuildFiles = validationResult.validatedBuildFiles
239-
240-
notifyStickyInfo("build files", "validated build files = ${validationResult.validatedBuildFiles}")
241-
242-
return CodeTransformChatMessageContent(
243-
message = message("codemodernizer.chat.form.user_selection.title"),
244-
buttons = listOf(
245-
confirmUserSelectionButton,
246-
cancelUserSelectionButton,
247-
),
248-
formItems = listOf(
249-
getSelectModuleFormItem(project, moduleBuildFiles),
250-
selectTargetVersionFormItem,
251-
),
252-
type = CodeTransformChatMessageType.FinalizedAnswer,
253-
)
254-
}
237+
fun buildUserInputChatContent(project: Project, validationResult: ValidationResult) = CodeTransformChatMessageContent(
238+
message = message("codemodernizer.chat.form.user_selection.title"),
239+
buttons = listOf(
240+
confirmUserSelectionButton,
241+
cancelUserSelectionButton,
242+
),
243+
formItems = listOf(
244+
getSelectModuleFormItem(project, validationResult.validatedBuildFiles),
245+
selectTargetVersionFormItem,
246+
),
247+
type = CodeTransformChatMessageType.FinalizedAnswer,
248+
)
255249

256250
fun buildUserCancelledChatContent() = CodeTransformChatMessageContent(
257251
type = CodeTransformChatMessageType.FinalizedAnswer,

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,10 @@ class CodeTransformChatController(
261261

262262
val sourceJdk = getSourceJdk(moduleConfigurationFile)
263263

264-
notifyStickyWarn("Build File", "moduleConfigurationFile = ${moduleConfigurationFile.path}")
265-
266264
// (rare) if a module has both a pom.xml and a build.gradle / build.gradle.kts, just the pom.xml will be detected up until here
267265
// so, check if a build.gradle / build.gradle.kts is present next to the pom.xml, and if so, ask the user what build system to use
268266
if (moduleConfigurationFile.name == MAVEN_CONFIGURATION_FILE_NAME &&
269267
moduleConfigurationFile.parent.children.any { it.name == "build.gradle" || it.name == "build.gradle.kts" }) {
270-
notifyStickyInfo("Maven & Gradle found", "This project has a pom.xml and a build.gradle / build.gradle.kts")
271268
codeTransformChatHelper.addNewMessage(buildUserInputBuildSystemChatContent())
272269
return
273270
}

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.toolwindow.CodeMo
3434
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getPathToHilArtifactPomFolder
3535
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getPathToHilDependenciesRootDir
3636
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getPathToHilUploadZip
37+
import software.aws.toolkits.jetbrains.utils.notifyStickyInfo
3738
import software.aws.toolkits.resources.message
3839
import java.io.File
3940
import java.io.IOException
4041
import java.nio.file.FileVisitOption
4142
import java.nio.file.FileVisitResult
4243
import java.nio.file.Files
4344
import java.nio.file.Path
45+
import java.nio.file.Paths
4446
import java.nio.file.SimpleFileVisitor
4547
import java.nio.file.attribute.BasicFileAttributes
4648
import java.util.zip.ZipOutputStream
@@ -156,15 +158,16 @@ data class CodeModernizerSessionContext(
156158
}
157159
}
158160

161+
// TODO: figure out why this isn't working
159162
private fun runGradleScript(sourceFolder: File, buildLogBuilder: StringBuilder, logger: Logger, project: Project): LocalBuildResult {
160163
val pythonExecutable = getPythonExecutable() ?: return LocalBuildResult.Failure("Python not found")
161164
val gradleWrapperExists = checkAndCreateGradleWrapper(sourceFolder)
162165
if (!gradleWrapperExists) {
163166
return LocalBuildResult.Failure("Gradle wrapper could not be created")
164167
}
165-
val scriptPath = "/pythonScript/gradle_copy_deps.py" // AwsToolkit.PLUGINS_INFO.getValue(AwsPlugin.Q).path?.resolve("codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/gradle_copy_deps.py")
166-
// TO-DO: evaluate if withWorkDirectory is needed here, and whether to use path or absolutePath
167-
val commandLine = GeneralCommandLine("$pythonExecutable $scriptPath ${sourceFolder.path}")
168+
val scriptPath = Paths.get("plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/gradle_copy_deps.py").toAbsolutePath().toString() // AwsToolkit.PLUGINS_INFO.getValue(AwsPlugin.Q).path?.resolve("codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/gradle_copy_deps.py")
169+
// TODO: evaluate if withWorkDirectory is needed here, and whether to use path or absolutePath
170+
val commandLine = GeneralCommandLine("$pythonExecutable $scriptPath ${sourceFolder.path}").withWorkDirectory(sourceFolder)
168171
try {
169172
val processOutput = ExecUtil.execAndGetOutput(commandLine)
170173
LOG.warn { "gradle_copy_deps.py finished with exitCode = ${processOutput.exitCode} and output = ${processOutput.stdout}\n${processOutput.stderr}" }
@@ -302,10 +305,10 @@ data class CodeModernizerSessionContext(
302305
val outputFile = createTemporaryZipFile { zip ->
303306
// 1) Manifest file
304307
val dependenciesRoot = "$ZIP_DEPENDENCIES_PATH/${depDirectory?.name}"
305-
// TO-DO: fix backend issue where this needs to be equalsIgnoreCase: https://code.amazon.com/packages/ElasticGumbyCodeGenAgent/blobs/e4002a60a410da75c55aad1279a314204919bd80/--/src/main/java/com/amazonaws/elasticgumby/codegen/build/inference/FileBasedBuildSystemInference.java#L62
306-
// then the below "GRADLE" can just be "Gradle"
307-
val buildTool = if (configurationFile.name == MAVEN_CONFIGURATION_FILE_NAME) "Maven" else "GRADLE"
308-
mapper.writeValueAsString(ZipManifest(dependenciesRoot = dependenciesRoot, buildTool = buildTool))
308+
// TODO: fix backend issue where this needs to be equalsIgnoreCase: FileBasedBuildSystemInference.java#L62
309+
val buildTool = if (configurationFile.name == MAVEN_CONFIGURATION_FILE_NAME) MAVEN_BUILD_SYSTEM else GRADLE_BUILD_SYSTEM
310+
// buildTool needs to be uppercase for backend until we use equalsIgnoreCase
311+
mapper.writeValueAsString(ZipManifest(dependenciesRoot = dependenciesRoot, buildTool = buildTool.uppercase()))
309312
.byteInputStream()
310313
.use {
311314
zip.putNextEntry(Path(MANIFEST_PATH).toString(), it)

0 commit comments

Comments
 (0)