blob: 9c43d0f9c0270a8c2148fe4287539ba2b7a3f9fd [file] [log] [blame]
Tim Windelschmidt6d33a432025-02-04 14:34:25 +01001// Copyright The Monogon Project Authors.
Leopold Schabel18b4d652020-12-14 18:27:07 +01002// SPDX-License-Identifier: Apache-2.0
Leopold Schabel18b4d652020-12-14 18:27:07 +01003
Serge Bazanski216fe7b2021-05-21 18:36:16 +02004// localconfig modifies the project's IntelliJ config to include project-specific
5// settings. This is usually done by checking in the .idea directory, but we do not
6// want to do this: it conflicts with the Bazel plugin's way of conducting its
7// workspace business, lacks backwards compatibility, and is a common source of
8// spurious Git diffs, especially when the IDE/JDK/random plugins are updated and
9// team members run different versions.
Leopold Schabel18b4d652020-12-14 18:27:07 +010010//
Serge Bazanski216fe7b2021-05-21 18:36:16 +020011// Instead, we use the officially supported way of shipping IntelliJ Bazel project
12// configs - a .bazelproject file that can be imported using the Bazel project
13// import wizard, with local configs. We then use this tool to mangle the local
14// configs to add additional custom configuration beyond run configurations. This
15// avoids merge conflicts and allows us to intelligently handle schema changes.
Leopold Schabel18b4d652020-12-14 18:27:07 +010016package main
17
18import (
19 "log"
20 "os"
21 "path"
22
Serge Bazanski31370b02021-01-07 16:31:14 +010023 "source.monogon.dev/intellij/localconfig/watchers"
Leopold Schabel18b4d652020-12-14 18:27:07 +010024)
25
26func main() {
27 if len(os.Args) != 2 {
28 log.Fatal("usage: localconfig <project dir>")
29 }
30
31 projectDir := os.Args[1]
32 if _, err := os.Stat(path.Join(projectDir, ".ijwb")); err != nil {
33 log.Fatalf("invalid project dir: %v", err)
34 }
35
36 if err := watchers.RewriteConfig(projectDir); err != nil {
37 log.Fatal(err)
38 }
39}