mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[gradle][eel][IDEA-364042] cleanup in GradleServerEnvironmentSetupImpl
GitOrigin-RevId: 83095063fa4b7e36606e9402d43efeb2e562b79a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a98cefa456
commit
7c14f053cf
+38
-18
@@ -115,9 +115,14 @@ internal class GradleServerEnvironmentSetupImpl(
|
||||
targetBuildParametersBuilder.useInstallation(it)
|
||||
}
|
||||
|
||||
configureJdk(javaParameters, request, consumerOperationParameters, targetPathMapper, environmentConfiguration)
|
||||
progressIndicator.checkCanceled()
|
||||
val targetArguments =
|
||||
prepareTargetEnvironmentRequest(request, consumerOperationParameters, targetPathMapper, environmentConfiguration, progressIndicator)
|
||||
val targetArguments = prepareTargetEnvironmentRequest(
|
||||
request,
|
||||
consumerOperationParameters,
|
||||
environmentConfiguration,
|
||||
progressIndicator
|
||||
)
|
||||
|
||||
progressIndicator.checkCanceled()
|
||||
val targetedCommandLineBuilder = javaParameters.toCommandLine(request)
|
||||
@@ -130,7 +135,7 @@ internal class GradleServerEnvironmentSetupImpl(
|
||||
}
|
||||
}
|
||||
|
||||
projectUploadRoot = setupTargetProjectDirectories(consumerOperationParameters, request, targetedCommandLineBuilder)
|
||||
projectUploadRoot = setupTargetProjectDirectories(consumerOperationParameters.projectDir, request, targetedCommandLineBuilder)
|
||||
val remoteEnvironment = request.prepareEnvironment(progressIndicator)
|
||||
targetEnvironment = remoteEnvironment
|
||||
EP.forEachExtensionSafe {
|
||||
@@ -146,6 +151,7 @@ internal class GradleServerEnvironmentSetupImpl(
|
||||
|
||||
progressIndicator.checkCanceled()
|
||||
targetEnvironmentProvider.supplyEnvironmentAndRunHandlers(remoteEnvironment, progressIndicator)
|
||||
targetEnvironmentProvider.uploadVolumes(progressIndicator)
|
||||
|
||||
val pathsToMap = extractPathsToMapFromInitScripts(initScripts)
|
||||
val pathMapperInitScript = createTargetPathMapperInitScript(
|
||||
@@ -168,20 +174,18 @@ internal class GradleServerEnvironmentSetupImpl(
|
||||
return targetedCommandLineBuilder.build()
|
||||
}
|
||||
|
||||
private fun setupTargetProjectDirectories(consumerOperationParameters: ConsumerOperationParameters,
|
||||
request: TargetEnvironmentRequest,
|
||||
targetedCommandLineBuilder: @NotNull TargetedCommandLineBuilder): TargetEnvironment.UploadRoot {
|
||||
private fun setupTargetProjectDirectories(
|
||||
workingDir: File,
|
||||
request: TargetEnvironmentRequest,
|
||||
targetedCommandLineBuilder: @NotNull TargetedCommandLineBuilder,
|
||||
): TargetEnvironment.UploadRoot {
|
||||
val pathsToUpload: MutableSet<String> = HashSet()
|
||||
|
||||
val workingDir = consumerOperationParameters.projectDir
|
||||
val gradleProjectDirectory = FileUtilRt.toSystemDependentName(workingDir.path)
|
||||
pathsToUpload.add(gradleProjectDirectory)
|
||||
|
||||
val projectSettings = GradleSettings.getInstance(project).getLinkedProjectSettings(
|
||||
ExternalSystemApiUtil.toCanonicalPath(workingDir.path))
|
||||
projectSettings?.modules
|
||||
?.filter { Files.exists(Path.of(it)) }
|
||||
?.mapTo(pathsToUpload) { FileUtilRt.toSystemDependentName(it) }
|
||||
val projectModules = getProjectModules(workingDir)
|
||||
pathsToUpload.addAll(projectModules)
|
||||
|
||||
val commonAncestor = findCommonAncestor(pathsToUpload)
|
||||
val uploadPath = Paths.get(FileUtilRt.toSystemDependentName(commonAncestor!!))
|
||||
@@ -208,6 +212,16 @@ internal class GradleServerEnvironmentSetupImpl(
|
||||
return uploadRoot
|
||||
}
|
||||
|
||||
private fun getProjectModules(workingDir: File): Set<String> {
|
||||
val externalProjectPath = ExternalSystemApiUtil.toCanonicalPath(workingDir.path)
|
||||
val projectSettings = GradleSettings.getInstance(project).getLinkedProjectSettings(externalProjectPath)
|
||||
return projectSettings?.modules
|
||||
?.filter { Files.exists(Path.of(it)) }
|
||||
?.map { FileUtilRt.toSystemDependentName(it) }
|
||||
?.toSet()
|
||||
?: emptySet()
|
||||
}
|
||||
|
||||
private fun findCommonAncestor(paths: Set<String>): String? {
|
||||
var commonRoot: File? = null
|
||||
for (path in paths) {
|
||||
@@ -258,11 +272,13 @@ internal class GradleServerEnvironmentSetupImpl(
|
||||
return mapperInitScript.toString()
|
||||
}
|
||||
|
||||
private fun prepareTargetEnvironmentRequest(request: TargetEnvironmentRequest,
|
||||
consumerOperationParameters: ConsumerOperationParameters,
|
||||
targetPathMapper: PathMapper?,
|
||||
environmentConfiguration: TargetEnvironmentConfiguration,
|
||||
progressIndicator: TargetProgressIndicator): List<Pair<String, TargetValue<String>?>> {
|
||||
private fun configureJdk(
|
||||
javaParameters: SimpleJavaParameters,
|
||||
request: TargetEnvironmentRequest,
|
||||
consumerOperationParameters: ConsumerOperationParameters,
|
||||
targetPathMapper: PathMapper?,
|
||||
environmentConfiguration: TargetEnvironmentConfiguration,
|
||||
) {
|
||||
if (request is LocalTargetEnvironmentRequest) {
|
||||
javaParameters.vmParametersList.addProperty(Main.LOCAL_BUILD_PROPERTY, "true")
|
||||
val javaHomePath = consumerOperationParameters.javaHome.path
|
||||
@@ -276,9 +292,13 @@ internal class GradleServerEnvironmentSetupImpl(
|
||||
environmentConfiguration.addLanguageRuntime(javaLanguageRuntimeConfiguration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun prepareTargetEnvironmentRequest(request: TargetEnvironmentRequest,
|
||||
consumerOperationParameters: ConsumerOperationParameters,
|
||||
environmentConfiguration: TargetEnvironmentConfiguration,
|
||||
progressIndicator: TargetProgressIndicator): List<Pair<String, TargetValue<String>?>> {
|
||||
val targetArguments = requestFileArgumentsUpload(request, consumerOperationParameters, environmentConfiguration)
|
||||
|
||||
EP.forEachExtensionSafe {
|
||||
it.prepareTargetEnvironmentRequest(request, this, progressIndicator)
|
||||
}
|
||||
|
||||
+3
@@ -32,6 +32,9 @@ internal class TargetEnvironmentProvider {
|
||||
promise.blockingGet(0) // Just rethrows errors.
|
||||
}
|
||||
dependingOnEnvironmentPromise.clear()
|
||||
}
|
||||
|
||||
fun uploadVolumes(progressIndicator: GradleServerProgressIndicator) {
|
||||
for (upload in uploads) {
|
||||
progressIndicator.checkCanceled()
|
||||
upload.volume.upload(upload.relativePath, progressIndicator)
|
||||
|
||||
Reference in New Issue
Block a user