From 36e2cd67332085070c47bd8b80b414588b55b3f9 Mon Sep 17 00:00:00 2001 From: "alexey.afanasiev" Date: Mon, 25 Nov 2024 01:48:53 +0100 Subject: [PATCH] :bug:QD-10360 Force installPlugins to use qodana attributes of EAP and version (cherry picked from commit cb8d2791c851ec46e2749f4bf77519e3afd72d79) --- core/ide.go | 5 ++++- core/options.go | 3 +++ core/product_info.go | 2 ++ core/properties.go | 16 ++++++++++++++++ core/system.go | 4 ++-- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/core/ide.go b/core/ide.go index 46987a40..0fc92ab9 100644 --- a/core/ide.go +++ b/core/ide.go @@ -403,7 +403,10 @@ func prepareDirectories(cacheDir string, logDir string, confDir string) { } // installPlugins runs plugin installer for every plugin id in qodana.yaml. -func installPlugins(plugins []platform.Plugin) { +func installPlugins(opts *QodanaOptions, plugins []platform.Plugin) { + if len(plugins) > 0 { + setInstallPluginsVmoptions(opts) + } for _, plugin := range plugins { log.Printf("Installing plugin %s", plugin.Id) if res, err := platform.RunCmd("", platform.QuoteIfSpace(Prod.IdeScript), "installPlugins", platform.QuoteIfSpace(plugin.Id)); res > 0 || err != nil { diff --git a/core/options.go b/core/options.go index c9159bce..04bdc971 100644 --- a/core/options.go +++ b/core/options.go @@ -32,3 +32,6 @@ func (o *QodanaOptions) fixesSupported() bool { func (o *QodanaOptions) vmOptionsPath() string { return filepath.Join(o.ConfDirPath(), "ide.vmoptions") } +func (o *QodanaOptions) installPluginsVmOptionsPath() string { + return filepath.Join(o.ConfDirPath(), "install_plugins.vmoptions") +} diff --git a/core/product_info.go b/core/product_info.go index a6ae4f55..a8fdfe4b 100644 --- a/core/product_info.go +++ b/core/product_info.go @@ -31,6 +31,7 @@ import ( type product struct { Name string + IDECode string Code string Version string BaseScriptName string @@ -270,6 +271,7 @@ func guessProduct(opts *QodanaOptions) { log.Fatalf("Can't read product-info.json: %v ", err) } Prod.Version = productInfo.Version + Prod.IDECode = productInfo.ProductCode Prod.Code = toQodanaCode(productInfo.ProductCode) Prod.Name = Prod.getProductNameFromCode() Prod.Build = productInfo.BuildNumber diff --git a/core/properties.go b/core/properties.go index 3de2d52c..1109f41a 100644 --- a/core/properties.go +++ b/core/properties.go @@ -170,3 +170,19 @@ func writeProperties(opts *QodanaOptions) { // opts.confDirPath(Prod.Version) o log.Fatal(err) } } + +func setInstallPluginsVmoptions(opts *QodanaOptions) { + vmOptions := []string{ + "-Dqodana.application=true", + "-Dintellij.platform.load.app.info.from.resources=true", + fmt.Sprintf("-Dqodana.build.number=%s-%s", Prod.IDECode, Prod.Build), + } + err := os.WriteFile(opts.installPluginsVmOptionsPath(), []byte(strings.Join(vmOptions, "\n")), 0o644) + if err != nil { + log.Fatal(err) + } + err = os.Setenv(Prod.vmOptionsEnv(), opts.installPluginsVmOptionsPath()) + if err != nil { + log.Fatal(err) + } +} diff --git a/core/system.go b/core/system.go index 51690d58..03c7b6c5 100644 --- a/core/system.go +++ b/core/system.go @@ -201,7 +201,7 @@ func RunAnalysis(ctx context.Context, options *QodanaOptions) int { // this way of running needs to do bootstrap twice on different commits and will do it internally if scenario != runScenarioScoped && options.Ide != "" { platform.Bootstrap(options.QdConfig.Bootstrap, options.ProjectDir) - installPlugins(options.QdConfig.Plugins) + installPlugins(options, options.QdConfig.Plugins) } switch scenario { case runScenarioFullHistory: @@ -350,7 +350,7 @@ func runScopeScript(ctx context.Context, options *QodanaOptions, startHash strin configAtHash = options.QdConfig } platform.Bootstrap(configAtHash.Bootstrap, options.ProjectDir) - installPlugins(configAtHash.Plugins) + installPlugins(options, configAtHash.Plugins) exitCode := runQodana(ctx, options) if !(exitCode == 0 || exitCode == 255) {