Commit 9d10df1
authored
[build] Improve support for building on GitHub Codespaces (#1241)
Context: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers
Context: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#using-the-default-dev-container-configuration
Context: https://github.com/orgs/community/discussions/25429
There are two issues when trying to build `Java.Interop.sln` within
a [GitHub Codespace][0]:
1. `dotnet build -t:Prepare Java.Interop.sln` fails.
2. `mono` was required on Linux environments.
`dotnet build -t:Prepare` fails because `Java.Interop.sln` references
`Xamarin.Android.Tools.AndroidSdk.csproj`, which does not exist
immediately after checkout:
/usr/share/dotnet/sdk/8.0.303/NuGet.targets(414,5): error MSB3202:
The project file "…/java-interop/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj"
was not found.
This apparently happens *before* the `Prepare` target executes, so
the `git submodule update --init --recursive` within that target
doesn't execute.
Fix this by adding a `.devcontainer/devcontainer.json` which contains
a `postCreateCommand` section which runs
`git submodule update --init --recursive`. Additionally, have
`devcontainer.json` use the
`mcr.microsoft.com/devcontainers/universal:2-linux` image, which
supports C#, Java, and C++ development (among others), which is handy
as this repo contains C#, Java, and C++ code to compile.
Once the submodule problem is addressed, `dotnet build -t:Prepare`
fails again because `mono` was required in Linux environments, and
the default environment that GitHub Codespace creates when typing
`.` within dotnet/java-interop has `dotnet` installed, but not `mono`.
This results the error:
…/java-interop/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.targets(50,5):
error MSB3073: The command "which mono" exited with code 1.
Update `Java.Interop.BootstrapTasks.targets` so that `mono` is no
longer required on Linux platforms. If `which mono` returns the
empty string, then `bin/Build*/MonoInfo.props` is not created.
Finally, the `mcr.microsoft.com/devcontainers/universal:2-linux`
image defaults to using JDK 17. The
`JniPeerMembersTests.DoesTheJmethodNeedToMatchDeclaringType()` test
crashes under JDK 17 with:
FATAL ERROR in native method: Wrong object class or methodID passed to JNI call
Update `DoesTheJmethodNeedToMatchDeclaringType()` to skip the test
when running on JDK 17 or later.
With these changes, a new GitHub codespace against dotnet/java-interop
can now build and run tests, a'la:
% dotnet build -t:Prepare Java.Interop.sln
% dotnet build Java.Interop.sln
% dotnet test bin/TestDebug-net8.0/Java.Interop-Tests.dll
…
Passed! - Failed: 0, Passed: 629, Skipped: 3, Total: 632, Duration: 4 s - Java.Interop-Tests.dll (net8.0)
~~ Oddities and annoyances with GitHub Codespaces: ~~
1. On macOS + Safari, "Hamburger menu" > File > Close Editor *says* ⌘W.
However, *using* ⌘W results in closing the
GitHub Codespaces *Safari tab*.
*Oops*.
Pressing ⌘Z will reopen the closed Safari tab.
I don't know how to close a VSCode tab without using the mouse.
Ctrl+W doesn't do it.
2. You make a change, and commit it by using `git commit` within the
Terminal (Ctrl+Shift+Backtick ⌃ ⇧ \`).
A new tab for `COMMIT_EDITMSG` opens. This is good.
If you then *search for text* that appears within that editor
window, and that text appears within the editor window --
e.g. search for "the" -- then the "return" key keeps finding the
next search match, which makes it difficult to enter blank lines.
You must either fully dismiss the search dialog by hitting
Escape ⎋ a few times, or by clicking the close `x` button on the
search panel, or use Ctrl+return ⌃return to enter a newline.
This was "odd", especially as Escape ⎋ doesn't appear to reliably
dismiss the search panel for me.
[0]: https://github.com/features/codespaces1 parent 7a058c0 commit 9d10df1
File tree
5 files changed
+81
-16
lines changed- .devcontainer
- build-tools/Java.Interop.BootstrapTasks
- tests
- Java.Interop-Tests/Java.Interop
- TestJVM
5 files changed
+81
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
40 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
41 | 54 | | |
42 | 55 | | |
43 | 56 | | |
| |||
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
70 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
71 | 86 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
75 | 90 | | |
76 | 91 | | |
77 | 92 | | |
78 | | - | |
| 93 | + | |
79 | 94 | | |
80 | 95 | | |
81 | | - | |
| 96 | + | |
82 | 97 | | |
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
87 | | - | |
| 102 | + | |
88 | 103 | | |
89 | 104 | | |
90 | | - | |
| 105 | + | |
91 | 106 | | |
92 | 107 | | |
93 | 108 | | |
94 | 109 | | |
95 | 110 | | |
96 | 111 | | |
97 | 112 | | |
98 | | - | |
| 113 | + | |
99 | 114 | | |
100 | 115 | | |
101 | 116 | | |
| |||
108 | 123 | | |
109 | 124 | | |
110 | 125 | | |
111 | | - | |
| 126 | + | |
112 | 127 | | |
113 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
114 | 134 | | |
115 | 135 | | |
116 | 136 | | |
| |||
0 commit comments