The --project-root
option is specific to the DAML Compiler and even for that it suffers from some issues, see Why does --project-root not pick up the SDK version of the project?.
What you can use with every tool is to set the DAML_PROJECT
environment variable, e.g.,
DAML_PROJECT=foobar daml codegen java
However, there is currently a bug where this doesn’t work for the Java codegen, I’ve opened daml codegen java should resolve DAR relative to project root · Issue #8406 · digital-asset/daml · GitHub to track this.
So for now, you are unfortunately stuck changing the working directory before calling daml codegen java
.