|
3 | 3 | set -x |
4 | 4 | set -e |
5 | 5 |
|
6 | | -# GitHub Actions workaround; We seem to be hitting gradle wrapper download issues, and this attempts to workaround them |
7 | | -./gradlew -h |
| 6 | +if [[ "$(uname)" == "Darwin" && -n "$GITHUB_ACTION" ]]; then |
| 7 | + # WORKAROUND: GitHub Actions on macOS issue with downloading gradle wrapper |
| 8 | + # We seem to be hitting a problem when the swiftpm plugin, needs to execute gradle wrapper in a new gradle_user_home. |
| 9 | + # Normally, this would just download gradle again and kick off a build, this seems to timeout *specifically* on |
| 10 | + # github actions runners. |
| 11 | + # |
| 12 | + # It is not a sandbox problem, becuase the ./gradlew is run without sandboxing as we already execute |
| 13 | + # the entire swift build with '--disable-sandbox' for other reasons. |
| 14 | + # |
| 15 | + # We cannot use the same gradle user home as the default one since we might make gradle think we're |
| 16 | + # building the same project concurrently, which we kind of are, however only a limited subset in order |
| 17 | + # to trigger wrap-java with those dependencies. |
| 18 | + # |
| 19 | + # TODO: this may use some further improvements so normal usage does not incur another wrapper download. |
8 | 20 |
|
9 | | -GRADLE_USER_HOME="$(pwd)/.build/plugins/outputs/swiftjavaextractjnisampleapp/MySwiftLibrary/destination/JExtractSwiftPlugin/gradle-user-home" |
10 | | -if [ -d "$HOME/.gradle" ] ; then |
11 | | - echo "COPY $HOME/.gradle to $GRADLE_USER_HOME" |
12 | | - mkdir -p "$GRADLE_USER_HOME" |
13 | | - cp -r "$HOME/.gradle/*" "$GRADLE_USER_HOME/" || true |
14 | | -fi |
| 21 | + ./gradlew -h # prime ~/.gradle/wrapper/dists/... |
15 | 22 |
|
16 | | -# Verify the custom gradle home directory works # TODO: remove this once verified |
17 | | -./gradlew :SwiftKitCore:build --gradle-user-home $GRADLE_USER_HOME -p "$(pwd)/../../" --configure-on-demand --no-daemon |
| 23 | + # Worst part of workaround here; we make sure to pre-load the resolved gradle wrapper downloaded distribution |
| 24 | + # to the "known" location the plugin will use for its local builds, which are done in order to compile SwiftKitCore. |
| 25 | + # This build is only necessary in order to drive wrap-java on sources generated during the build itself |
| 26 | + # which enables the "Implement Swift protocols in Java" feature of jextract/jni mode. |
| 27 | + GRADLE_USER_HOME="$(pwd)/.build/plugins/outputs/swiftjavaextractjnisampleapp/MySwiftLibrary/destination/JExtractSwiftPlugin/gradle-user-home" |
| 28 | + if [ -d "$HOME/.gradle" ] ; then |
| 29 | + echo "COPY $HOME/.gradle to $GRADLE_USER_HOME" |
| 30 | + mkdir -p "$GRADLE_USER_HOME" |
| 31 | + cp -r "$HOME/.gradle/"* "$GRADLE_USER_HOME/" || true |
| 32 | + fi |
| 33 | +fi |
18 | 34 |
|
19 | | -swift build --disable-experimental-prebuilts --disable-sandbox --verbose # FIXME: until prebuilt swift-syntax isn't broken on 6.2 anymore: https://github.com/swiftlang/swift-java/issues/418 |
| 35 | +# FIXME: disable prebuilts until prebuilt swift-syntax isn't broken on 6.2 anymore: https://github.com/swiftlang/swift-java/issues/418 |
| 36 | +swift build --disable-experimental-prebuilts --disable-sandbox |
20 | 37 |
|
21 | 38 | ./gradlew run |
22 | 39 | ./gradlew test |
0 commit comments