Skip to content

Commit

Permalink
🐛QD-10360 Force installPlugins to use qodana attributes of EAP and ve…
Browse files Browse the repository at this point in the history
…rsion

(cherry picked from commit cb8d279)
  • Loading branch information
avafanasiev committed Nov 26, 2024
1 parent 66f5271 commit 36e2cd6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion core/ide.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 2 additions & 0 deletions core/product_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

type product struct {
Name string
IDECode string
Code string
Version string
BaseScriptName string
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions core/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions core/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 36e2cd6

Please sign in to comment.