aloof-appointment-30987
05/04/2023, 3:27 PM./build.sh. I am able to configure this to run successfully using Pants 1.16 run_shell_command. Executing via ./pants run :build-flutter produces the expected artifacts. These are then copied into our docker container. If the files are present in the source files, then the files and docker_image targets work perfectly. I'm having trouble sequencing dependencies so that the script is executed before other targets. Is this supported?
Here's my BUILD file
files(
name="flutter-source",
sources=[
"./**",
]
)
shell_sources(name="shell-scripts")
# produces build artifacts in source code workspace
run_shell_command(
name="build-flutter",
command="cd realtime/cloud_ui && ./build.sh",
execution_dependencies=[":shell-scripts", ":flutter-source"]
)
files(
name="docker-assets",
dependencies=[":build-flutter"],
sources=[
"./Caddyfile",
"./docker_entrypoint.sh",
"./build/web/**",
]
)
docker_image(
name="neuroedge_cloud_ui",
dependencies=[
":docker-assets"
],
image_tags=["latest"]
)
when I execute ./pants package :neuroedge_cloud_ui, I expect the dependency chain will invoke :build-flutter to produce the required "_./build/web/**"_ files matched by :docker-assets but this is not the case. If I run :build-flutter and then package :neuroedge_cloud_ui all is well. Is it possible to ensure that :build-flutter is always run as a dependency of :build-flutter ?aloof-appointment-30987
05/04/2023, 4:13 PMfiles(
name="flutter-source",
sources=[
"./**",
]
)
shell_sources(name="shell-scripts")
shell_command(
name="build-flutter",
command="./build.sh",
tools=["basename", "bash", "cat", "chmod", "dirname", "env", "git", "flutter", "mkdir", "readlink", "rm", "sleep", "sw_vers", "uname", "which"],
execution_dependencies=[":shell-scripts", ":flutter-source"],
output_directories=["build"],
log_output=True,
timeout=120
)
files(
name="docker-assets",
sources=[
"./Caddyfile",
"./docker_entrypoint.sh",
# "./build/web/**", <- produced by :build-flutter
]
)
docker_image(
name="neuroedge_cloud_ui",
dependencies=[
":build-flutter",
":docker-assets"
],
image_tags=["latest"]
)
I am concerned about the need to specify each tool that should be available in the PATH as an update to Flutter will very likely change this but it will be rather challenging to troubleshoot for people lacking Pants expertise.happy-kitchen-89482
05/04/2023, 7:00 PMancient-vegetable-10556
05/04/2023, 7:05 PMancient-vegetable-10556
05/04/2023, 7:20 PMrunnable_dependencies transitively, but that doesn’t exist at the moment. In the meantime, it’s useful to remember that BUILD files are actually Python files, which means you can define variables if you want to (so you could make the tools list a variable.
Better still, you can define a macro for a flutter_build, which would just specify the input files, and output most of the shell_command boilerplate for each target.
Finally, I recommend looking at system_binary as a way to version test your flutter binary — that way you can make sure that you’re always running a correct version of flutter (see https://www.pantsbuild.org/v2.16/docs/adhoc-tool#using-externally-managed-tools)aloof-appointment-30987
05/16/2023, 1:00 PMancient-vegetable-10556
05/16/2023, 4:16 PMBUILD files, I thinkancient-vegetable-10556
05/16/2023, 4:16 PM