Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(amazonq): allow users to skip tests #4887

Merged
merged 18 commits into from
Sep 25, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "Amazon Q Code Transformation: allow users to skip tests"
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
private val isJobSuccessfullyResumed = AtomicBoolean(false)

private val transformationStoppedByUsr = AtomicBoolean(false)
private var codeTransformationSession: CodeModernizerSession? = null
var codeTransformationSession: CodeModernizerSession? = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see if you can make this private again

set(session) {
if (session != null) {
Disposer.register(this, session)
Expand Down Expand Up @@ -383,12 +383,7 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
CodeTransformMessageListener.instance.onMavenBuildResult(mavenCopyCommandsResult)
}

fun runLocalMavenBuild(project: Project, customerSelection: CustomerSelection) {
// Create and set a session
codeTransformationSession = null
val session = createCodeModernizerSession(customerSelection, project)
codeTransformationSession = session

fun runLocalMavenBuild(project: Project, session: CodeModernizerSession) {
projectCoroutineScope(project).launch {
isMvnRunning.set(true)
val result = session.getDependenciesUsingMaven()
Expand Down Expand Up @@ -668,14 +663,16 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
telemetry.totalRunTime(result.toString(), jobId)
}

fun createCodeModernizerSession(customerSelection: CustomerSelection, project: Project) = CodeModernizerSession(
CodeModernizerSessionContext(
project,
customerSelection.configurationFile,
customerSelection.sourceJavaVersion,
customerSelection.targetJavaVersion,
),
)
fun createCodeModernizerSession(customerSelection: CustomerSelection, project: Project) {
codeTransformationSession = CodeModernizerSession(
CodeModernizerSessionContext(
project,
customerSelection.configurationFile,
customerSelection.sourceJavaVersion,
customerSelection.targetJavaVersion,
),
)
}

fun showModernizationProgressUI() = codeModernizerBottomWindowPanelManager.showUnalteredJobUI()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private enum class CodeTransformMessageTypes(val type: String) {
CodeTransformStart("codetransform-start"),
CodeTransformStop("codetransform-stop"),
CodeTransformCancel("codetransform-cancel"),
CodeTransformConfirmSkipTests("codetransform-confirm-skip-tests"),
CodeTransformNew("codetransform-new"),
CodeTransformOpenTransformHub("codetransform-open-transform-hub"),
CodeTransformOpenMvnBuild("codetransform-open-mvn-build"),
Expand Down Expand Up @@ -64,6 +65,7 @@ class CodeTransformChatApp : AmazonQApp {
CodeTransformMessageTypes.CodeTransformStart.type to IncomingCodeTransformMessage.CodeTransformStart::class,
CodeTransformMessageTypes.CodeTransformStop.type to IncomingCodeTransformMessage.CodeTransformStop::class,
CodeTransformMessageTypes.CodeTransformCancel.type to IncomingCodeTransformMessage.CodeTransformCancel::class,
CodeTransformMessageTypes.CodeTransformConfirmSkipTests.type to IncomingCodeTransformMessage.CodeTransformConfirmSkipTests::class,
CodeTransformMessageTypes.CodeTransformNew.type to IncomingCodeTransformMessage.CodeTransformNew::class,
CodeTransformMessageTypes.CodeTransformOpenTransformHub.type to IncomingCodeTransformMessage.CodeTransformOpenTransformHub::class,
CodeTransformMessageTypes.CodeTransformOpenMvnBuild.type to IncomingCodeTransformMessage.CodeTransformOpenMvnBuild::class,
Expand Down Expand Up @@ -153,6 +155,7 @@ class CodeTransformChatApp : AmazonQApp {
is IncomingCodeTransformMessage.CodeTransformStart -> inboundAppMessagesHandler.processCodeTransformStartAction(message)
is IncomingCodeTransformMessage.CodeTransformCancel -> inboundAppMessagesHandler.processCodeTransformCancelAction(message)
is IncomingCodeTransformMessage.CodeTransformStop -> inboundAppMessagesHandler.processCodeTransformStopAction(message.tabId)
is IncomingCodeTransformMessage.CodeTransformConfirmSkipTests -> inboundAppMessagesHandler.processCodeTransformConfirmSkipTests(message)
is IncomingCodeTransformMessage.CodeTransformNew -> inboundAppMessagesHandler.processCodeTransformNewAction(message)
is IncomingCodeTransformMessage.CodeTransformOpenTransformHub -> inboundAppMessagesHandler.processCodeTransformOpenTransformHub(message)
is IncomingCodeTransformMessage.CodeTransformOpenMvnBuild -> inboundAppMessagesHandler.processCodeTransformOpenMvnBuild(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface InboundAppMessagesHandler {

suspend fun processCodeTransformStopAction(tabId: String)

suspend fun processCodeTransformConfirmSkipTests(message: IncomingCodeTransformMessage.CodeTransformConfirmSkipTests)

suspend fun processCodeTransformOpenTransformHub(message: IncomingCodeTransformMessage.CodeTransformOpenTransformHub)

suspend fun processCodeTransformOpenMvnBuild(message: IncomingCodeTransformMessage.CodeTransformOpenMvnBuild)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
id = CodeTransformButtonId.StartTransformation.id,
)

private val confirmSkipTestsSelectionButton = Button(
keepCardAfterClick = false,
waitMandatoryFormItems = true,
text = message("codemodernizer.chat.message.button.confirm"),
id = CodeTransformButtonId.ConfirmSkipTests.id,
)

private val openMvnBuildButton = Button(
id = CodeTransformButtonId.OpenMvnBuild.id,
text = message("codemodernizer.chat.message.button.view_build"),
Expand Down Expand Up @@ -134,6 +141,22 @@
)
)

private val selectSkipTestsFlagFormItem = FormItem(
id = CodeTransformFormItemId.SelectSkipTestsFlag.id,
title = message("codemodernizer.chat.form.user_selection.item.choose_skip_tests_option"),
mandatory = true,
options = listOf(
FormItemOption(
label = message("codemodernizer.chat.message.skip_tests_form.run_tests"),
value = message("codemodernizer.chat.message.skip_tests_form.run_tests"),

Check warning on line 151 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
),
FormItemOption(
label = message("codemodernizer.chat.message.skip_tests_form.skip"),
value = message("codemodernizer.chat.message.skip_tests_form.skip"),
)
)
)

private fun getUserSelectionFormattedMarkdown(moduleName: String): String = """
### ${message("codemodernizer.chat.prompt.title.details")}
-------------
Expand All @@ -156,7 +179,7 @@
""".trimIndent()

fun buildCheckingValidProjectChatContent() = CodeTransformChatMessageContent(
message = message("codemodernizer.chat.message.validation.check_eligible_projects"),

Check warning on line 182 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
type = CodeTransformChatMessageType.PendingAnswer,
)

Expand Down Expand Up @@ -184,11 +207,26 @@
)
)

fun buildAuthRestoredFollowup(): CodeTransformChatMessageContent = CodeTransformChatMessageContent(
type = CodeTransformChatMessageType.FinalizedAnswer,
followUps = listOf(
startNewTransformFollowUp
fun buildUserInputSkipTestsFlagChatIntroContent(): CodeTransformChatMessageContent =
CodeTransformChatMessageContent(
message = message("codemodernizer.chat.message.skip_tests"),
type = CodeTransformChatMessageType.FinalizedAnswer,
)

fun buildUserInputSkipTestsFlagChatContent(): CodeTransformChatMessageContent =
CodeTransformChatMessageContent(
message = message("codemodernizer.chat.form.user_selection.title"),
buttons = listOf(
confirmSkipTestsSelectionButton,
cancelUserSelectionButton,
),
formItems = listOf(selectSkipTestsFlagFormItem),
type = CodeTransformChatMessageType.FinalizedAnswer,
)

fun buildUserSkipTestsFlagSelectionChatContent(skipTestsSelection: String) = CodeTransformChatMessageContent(
type = CodeTransformChatMessageType.FinalizedAnswer,
message = message("codemodernizer.chat.message.skip_tests_form.response", skipTestsSelection.lowercase())
)

fun buildUserInputChatContent(project: Project, validationResult: ValidationResult): CodeTransformChatMessageContent {
Expand Down Expand Up @@ -255,7 +293,7 @@
type = CodeTransformChatMessageType.FinalizedAnswer,
message = "${message(
"codemodernizer.chat.message.validation.no_jdk"
)}\n\n${message(

Check warning on line 296 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
"codemodernizer.chat.message.validation.error.more_info",
CODE_TRANSFORM_TROUBLESHOOT_DOC_MVN_FAILURE
)}",
Expand All @@ -265,7 +303,7 @@
val resultMessage = when (failureReason) {
is UploadFailureReason.PRESIGNED_URL_EXPIRED -> "${message(
"codemodernizer.chat.message.upload_failed_url_expired"
)}\n\n${message(

Check warning on line 306 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
"codemodernizer.chat.message.validation.error.more_info",
CODE_TRANSFORM_TROUBLESHOOT_DOC_ALLOW_S3_ACCESS
)}"
Expand All @@ -292,7 +330,7 @@

is UploadFailureReason.SSL_HANDSHAKE_ERROR -> "${message(
"codemodernizer.chat.message.upload_failed_ssl_error"
)}\n\n${message(

Check warning on line 333 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
"codemodernizer.chat.message.validation.error.more_info",
CODE_TRANSFORM_TROUBLESHOOT_DOC_CONFIGURE_PROXY
)}"
Expand Down Expand Up @@ -441,7 +479,7 @@
)

fun buildTransformFindingLocalAlternativeDependencyChatContent() = CodeTransformChatMessageContent(
message = message("codemodernizer.chat.message.hil.searching"),

Check warning on line 482 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
type = CodeTransformChatMessageType.PendingAnswer,
)

Expand All @@ -457,7 +495,7 @@

fun buildHilResumedContent() = CodeTransformChatMessageContent(
type = CodeTransformChatMessageType.PendingAnswer,
message = message("codemodernizer.chat.message.hil.resumed"),

Check warning on line 498 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
buttons = listOf(
openTransformHubButton,
stopTransformButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserCancelledChatContent
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserHilSelection
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserInputChatContent
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserInputSkipTestsFlagChatContent
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserInputSkipTestsFlagChatIntroContent
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserSelectionSummaryChatContent
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserSkipTestsFlagSelectionChatContent
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.buildUserStopTransformChatContent
import software.aws.toolkits.jetbrains.services.codemodernizer.messages.AuthenticationNeededExceptionMessage
import software.aws.toolkits.jetbrains.services.codemodernizer.messages.CodeTransformChatMessage
Expand All @@ -66,6 +69,8 @@
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CustomerSelection
import software.aws.toolkits.jetbrains.services.codemodernizer.model.DownloadFailureReason
import software.aws.toolkits.jetbrains.services.codemodernizer.model.JobId
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MAVEN_BUILD_RUN_UNIT_TESTS
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MAVEN_BUILD_SKIP_UNIT_TESTS
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MavenCopyCommandsResult
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MavenDependencyReportCommandsResult
import software.aws.toolkits.jetbrains.services.codemodernizer.model.UploadFailureReason
Expand Down Expand Up @@ -208,26 +213,47 @@
val moduleVirtualFile: VirtualFile = modulePath.toVirtualFile() as VirtualFile
val moduleName = context.project.getModuleOrProjectNameForFile(moduleVirtualFile)

codeTransformChatHelper.run {
addNewMessage(buildUserSelectionSummaryChatContent(moduleName))
addNewMessage(buildCompileLocalInProgressChatContent())
}
codeTransformChatHelper.addNewMessage(buildUserSelectionSummaryChatContent(moduleName))

// this should never throw the RuntimeException since invalid JDK case is already handled in previous validation step
val moduleJdkVersion = ModuleUtil.findModuleForFile(moduleVirtualFile, context.project)?.tryGetJdk(context.project)
logger.info { "Found project JDK version: ${context.project.tryGetJdk()}, module JDK version: $moduleJdkVersion. Module JDK version prioritized." }
val sourceJdk = moduleJdkVersion ?: context.project.tryGetJdk() ?: throw RuntimeException("Unable to determine source JDK version")
val sourceJdk = getSourceJdk(moduleVirtualFile)

val selection = CustomerSelection(
moduleVirtualFile,
sourceJdk,
JavaSdkVersion.JDK_17
JavaSdkVersion.JDK_17,
)

// Create and set a session
codeModernizerManager.createCodeModernizerSession(selection, context.project)

// Publish metric to capture user selection before local build starts
telemetry.submitSelection("Confirm", selection)

codeModernizerManager.runLocalMavenBuild(context.project, selection)
codeTransformChatHelper.run {
addNewMessage(buildUserInputSkipTestsFlagChatIntroContent())
addNewMessage(buildUserInputSkipTestsFlagChatContent())
}
}

override suspend fun processCodeTransformConfirmSkipTests(message: IncomingCodeTransformMessage.CodeTransformConfirmSkipTests) {
val customBuildCommand = when (message.skipTestsSelection) {
message("codemodernizer.chat.message.skip_tests_form.skip") -> MAVEN_BUILD_SKIP_UNIT_TESTS
else -> MAVEN_BUILD_RUN_UNIT_TESTS
}
codeTransformChatHelper.addNewMessage(buildUserSkipTestsFlagSelectionChatContent(message.skipTestsSelection))
codeTransformChatHelper.addNewMessage(buildCompileLocalInProgressChatContent())
codeModernizerManager.codeTransformationSession?.let {
it.sessionContext.customBuildCommand = customBuildCommand
codeModernizerManager.runLocalMavenBuild(context.project, it)
}
}

private fun getSourceJdk(moduleConfigurationFile: VirtualFile): JavaSdkVersion {
// this should never throw the RuntimeException since invalid JDK case is already handled in previous validation step
val moduleJdkVersion = ModuleUtil.findModuleForFile(moduleConfigurationFile, context.project)?.tryGetJdk(context.project)
logger.info { "Found project JDK version: ${context.project.tryGetJdk()}, module JDK version: $moduleJdkVersion. Module JDK version prioritized." }
val sourceJdk = moduleJdkVersion ?: context.project.tryGetJdk() ?: error("Unable to determine source JDK version")
return sourceJdk
}

private suspend fun handleMavenBuildResult(mavenBuildResult: MavenCopyCommandsResult) {
Expand Down Expand Up @@ -599,7 +625,7 @@
hilTryResumeAfterError(message("codemodernizer.chat.message.hil.error.cannot_upload"))
return
} else if (copyDependencyResult == MavenCopyCommandsResult.Cancelled) {
hilTryResumeAfterError(message("codemodernizer.chat.message.hil.error.cancel_upload"))

Check warning on line 628 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ sealed interface CodeTransformBaseMessage : AmazonQMessage
enum class CodeTransformButtonId(val id: String) {
StartTransformation("codetransform-input-confirm"),
CancelTransformation("codetransform-input-cancel"),
ConfirmSkipTests("codetransform-input-confirm-skip-tests"),
StopTransformation("stop_transform"),
OpenTransformationHub("open_transformation_hub"),
OpenMvnBuild("open_mvn_build"),
Expand All @@ -32,6 +33,7 @@ enum class CodeTransformButtonId(val id: String) {
enum class CodeTransformFormItemId(val id: String) {
SelectModule("module"),
SelectTargetVersion("targetVersion"),
SelectSkipTestsFlag("skipTestsSelection"),
DependencyVersion("dependencyVersion"),
}

Expand Down Expand Up @@ -81,6 +83,11 @@ sealed interface IncomingCodeTransformMessage : CodeTransformBaseMessage {
@JsonProperty("tabID") val tabId: String,
) : IncomingCodeTransformMessage

data class CodeTransformConfirmSkipTests(
@JsonProperty("tabID") val tabId: String,
val skipTestsSelection: String,
) : IncomingCodeTransformMessage

data class CodeTransformOpenMvnBuild(
@JsonProperty("tabID") val tabId: String,
) : IncomingCodeTransformMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const val ZIP_SOURCES_PATH = "sources"
const val ZIP_DEPENDENCIES_PATH = "dependencies"
const val BUILD_LOG_PATH = "build-logs.txt"
const val MAVEN_CONFIGURATION_FILE_NAME = "pom.xml"
const val MAVEN_BUILD_RUN_UNIT_TESTS = "clean test"
const val MAVEN_BUILD_SKIP_UNIT_TESTS = "clean test-compile"
const val MAVEN_DEFAULT_BUILD_DIRECTORY_NAME = "target"
const val IDEA_DIRECTORY_NAME = ".idea"
const val INVALID_SUFFIX_SHA = "sha1"
Expand All @@ -53,6 +55,7 @@ data class CodeModernizerSessionContext(
val configurationFile: VirtualFile,
val sourceJavaVersion: JavaSdkVersion,
val targetJavaVersion: JavaSdkVersion,
var customBuildCommand: String = MAVEN_BUILD_RUN_UNIT_TESTS // run unit tests by default
) {
private val mapper = jacksonObjectMapper()
private val ignoredDependencyFileExtensions = setOf(INVALID_SUFFIX_SHA, INVALID_SUFFIX_REPOSITORIES)
Expand Down Expand Up @@ -200,7 +203,7 @@ data class CodeModernizerSessionContext(
val outputFile = createTemporaryZipFile { zip ->
// 1) Manifest file
val dependenciesRoot = if (depDirectory != null) "$ZIP_DEPENDENCIES_PATH/${depDirectory.name}" else null
mapper.writeValueAsString(ZipManifest(dependenciesRoot = dependenciesRoot))
mapper.writeValueAsString(ZipManifest(dependenciesRoot = dependenciesRoot, customBuildCommand = customBuildCommand))
.byteInputStream()
.use {
zip.putNextEntry(Path(MANIFEST_PATH).toString(), it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import com.intellij.openapi.vfs.VirtualFile
data class CustomerSelection(
val configurationFile: VirtualFile,
val sourceJavaVersion: JavaSdkVersion,
val targetJavaVersion: JavaSdkVersion
val targetJavaVersion: JavaSdkVersion,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ data class ZipManifest(
val buildLogs: String = BUILD_LOG_PATH,
val version: String = UPLOAD_ZIP_MANIFEST_VERSION.toString(),
val hilCapabilities: List<String> = listOf(HIL_1P_UPGRADE_CAPABILITY),
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1)
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1),
val customBuildCommand: String = MAVEN_BUILD_RUN_UNIT_TESTS,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion
import com.intellij.util.xmlb.annotations.Property
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerSessionContext
import software.aws.toolkits.jetbrains.services.codemodernizer.model.JobId
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MAVEN_BUILD_RUN_UNIT_TESTS
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.toVirtualFile

enum class JobDetails {
LAST_JOB_ID,
CONFIGURATION_FILE_PATH,
TARGET_JAVA_VERSION,
SOURCE_JAVA_VERSION,
CUSTOM_BUILD_COMMAND,
}

enum class StateFlags {
Expand All @@ -29,6 +31,7 @@ fun buildState(context: CodeModernizerSessionContext, isJobOngoing: Boolean, job
JobDetails.CONFIGURATION_FILE_PATH to context.configurationFile.path,
JobDetails.TARGET_JAVA_VERSION to context.targetJavaVersion.description,
JobDetails.SOURCE_JAVA_VERSION to context.sourceJavaVersion.description,
JobDetails.CUSTOM_BUILD_COMMAND to context.customBuildCommand
)
)
flags.putAll(
Expand Down Expand Up @@ -56,6 +59,12 @@ class CodeModernizerState : BaseState() {
lastJobContext[JobDetails.SOURCE_JAVA_VERSION] ?: throw RuntimeException("Expected source language for migration path of previous job but was null")
val targetJavaSdkVersion = JavaSdkVersion.fromVersionString(targetString) ?: throw RuntimeException("Invalid Java SDK version $targetString")
val sourceJavaSdkVersion = JavaSdkVersion.fromVersionString(sourceString) ?: throw RuntimeException("Invalid Java SDK version $sourceString")
return CodeModernizerSessionContext(project, configurationFile, sourceJavaSdkVersion, targetJavaSdkVersion)
return CodeModernizerSessionContext(
project,
configurationFile,
sourceJavaSdkVersion,
targetJavaSdkVersion,
lastJobContext[JobDetails.CUSTOM_BUILD_COMMAND] ?: MAVEN_BUILD_RUN_UNIT_TESTS // default to running unit tests
)
}
}
Loading
Loading