-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
64 lines (51 loc) · 1.99 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//go:generate go install -v github.com/josephspurrier/goversioninfo/cmd/goversioninfo
//go:generate goversioninfo -icon=res/papp.ico -manifest=res/papp.manifest
package main
import (
"os"
"strings"
"github.com/portapps/portapps/v3"
"github.com/portapps/portapps/v3/pkg/log"
"github.com/portapps/portapps/v3/pkg/utl"
)
var (
app *portapps.App
)
const (
vmOptionsFile = "idea.vmoptions"
)
func init() {
var err error
// Init app
if app, err = portapps.New("intellij-idea-community-portable", "IntelliJ IDEA Community"); err != nil {
log.Fatal().Err(err).Msg("Cannot initialize application. See log file for more info.")
}
}
func main() {
ideaExe := "idea64.exe"
ideaVmOptionsFile := "idea64.exe.vmoptions"
utl.CreateFolder(app.DataPath)
app.Process = utl.PathJoin(app.AppPath, "bin", ideaExe)
app.WorkingDir = utl.PathJoin(app.AppPath, "bin")
// override idea.properties
ideaPropContent := strings.Replace(`# DO NOT EDIT! AUTOMATICALLY GENERATED BY PORTAPPS.
idea.config.path={{ DATA_PATH }}/config
idea.system.path={{ DATA_PATH }}/system
idea.plugins.path={{ DATA_PATH }}/plugins
idea.log.path={{ DATA_PATH }}/log`, "{{ DATA_PATH }}", utl.FormatUnixPath(app.DataPath), -1)
ideaPropPath := utl.PathJoin(app.DataPath, "idea.properties")
if err := utl.CreateFile(ideaPropPath, ideaPropContent); err != nil {
log.Fatal().Err(err).Msg("Cannot write idea.properties")
}
// https://www.jetbrains.com/help/idea/tuning-intellij-idea.html#configure-platform-properties
os.Setenv("IDEA_PROPERTIES", ideaPropPath)
// https://www.jetbrains.com/help/idea/tuning-the-ide.html#configure-jvm-options
os.Setenv("IDEA_VM_OPTIONS", utl.PathJoin(app.DataPath, vmOptionsFile))
if !utl.Exists(utl.PathJoin(app.DataPath, vmOptionsFile)) {
utl.CopyFile(utl.PathJoin(app.AppPath, "bin", ideaVmOptionsFile), utl.PathJoin(app.DataPath, vmOptionsFile))
} else {
utl.CopyFile(utl.PathJoin(app.DataPath, vmOptionsFile), utl.PathJoin(app.AppPath, "bin", ideaVmOptionsFile))
}
defer app.Close()
app.Launch(os.Args[1:])
}