I have a snapcraft.yaml which builds a java application. I’m building with core24.
The snapcraft.yaml implements the override-build and executes as part of the build, a shipped “gradlew” script which performs the build.
My override-build looks like this:
override-build: |
echo "BEGIN BUILD OF BESU - gradlew"
./gradlew --no-daemon installDist
echo "COMPLETED BUILD OF BESU - gradlew"
mkdir -p "${CRAFT_PART_INSTALL}"/bin
cp build/install/besu/bin/besu ${CRAFT_PART_INSTALL}/bin/besu
cp build/install/besu/bin/evmtool ${CRAFT_PART_INSTALL}/bin/evmtool
The “gradlew” command starts and completes, but, nothing AFTER this is ever executed (not even echo). This is from my build log:
2024-07-08 17:51:04.767 remove directory /root/parts/besu/build
2024-07-08 17:51:09.819 :: + echo 'BEGIN BUILD OF BESU - gradlew'
2024-07-08 17:51:09.819 :: BEGIN BUILD OF BESU - gradlew
2024-07-08 17:51:09.819 :: + ./gradlew --no-daemon installDist
...
...
...
2024-07-08 17:55:03.609 :: BUILD SUCCESSFUL in 3m 53s
2024-07-08 17:55:03.609 :: 95 actionable tasks: 95 executed
2024-07-08 17:55:04.485 Building utils
2024-07-08 17:55:04.486 execute action utils:Action(part_name='utils', step=Step.BUILD, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
2024-07-08 17:55:04.486 load state file: /root/parts/utils/state/pull
2024-07-08 17:55:04.489 remove directory /root/parts/utils/build
2024-07-08 17:55:04.494 Executing PosixPath('/root/parts/utils/run/build.sh')
2024-07-08 17:55:04.495 :: + cp --archive --link --no-dereference . /root/parts/utils/install
2024-07-08 17:55:04.869 Building wrappers
2024-07-08 17:55:04.869 execute action wrappers:Action(part_name='wrappers', step=Step.BUILD, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
2024-07-08 17:55:04.870 load state file: /root/parts/wrappers/state/pull
2024-07-08 17:55:04.872 remove directory /root/parts/wrappers/build
2024-07-08 17:55:04.879 Executing PosixPath('/root/parts/wrappers/run/build.sh')
2024-07-08 17:55:04.880 :: + cp --archive --link --no-dereference . /root/parts/wrappers/install
2024-07-08 17:55:05.239 Staging besu
2024-07-08 17:55:05.240 execute action besu:Action(part_name='besu', step=Step.STAGE, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
2024-07-08 17:55:05.241 /root/parts/besu/install/bin: No such file or directory
2024-07-08 17:55:05.241 Launching shell on build environment...
2024-07-08 17:55:05.241 Emitter: Pausing control of the terminal
snapcraft-besu-on-amd64-for-amd64-33947854 ../project#
As you can see above, the string I would expect: “COMPLETED BUILD OF BESU - gradlew” never appears and the files I need to copy into place are subsequently not being copied either and failing the over all build.
It seems that the gradlew command somehow makes the rest of override-build not to execute.
I have reproduced this on core22 as well.
There seems to be a similar bug in Launchpad: Bug #1987853 “snapcraft terminates override-build script prematu...” : Bugs : Snapcraft
What is going on here and how can I fix this?