| Tim Windelschmidt | 6d33a43 | 2025-02-04 14:34:25 +0100 | [diff] [blame] | 1 | // Copyright The Monogon Project Authors. |
| Leopold Schabel | 18b4d65 | 2020-12-14 18:27:07 +0100 | [diff] [blame] | 2 | // SPDX-License-Identifier: Apache-2.0 |
| Leopold Schabel | 18b4d65 | 2020-12-14 18:27:07 +0100 | [diff] [blame] | 3 | |
| Serge Bazanski | 216fe7b | 2021-05-21 18:36:16 +0200 | [diff] [blame] | 4 | // 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 Schabel | 18b4d65 | 2020-12-14 18:27:07 +0100 | [diff] [blame] | 10 | // |
| Serge Bazanski | 216fe7b | 2021-05-21 18:36:16 +0200 | [diff] [blame] | 11 | // 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 Schabel | 18b4d65 | 2020-12-14 18:27:07 +0100 | [diff] [blame] | 16 | package main |
| 17 | |
| 18 | import ( |
| 19 | "log" |
| 20 | "os" |
| 21 | "path" |
| 22 | |
| Serge Bazanski | 31370b0 | 2021-01-07 16:31:14 +0100 | [diff] [blame] | 23 | "source.monogon.dev/intellij/localconfig/watchers" |
| Leopold Schabel | 18b4d65 | 2020-12-14 18:27:07 +0100 | [diff] [blame] | 24 | ) |
| 25 | |
| 26 | func 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 | } |