Setting project-root for daml codegen java

Is there anyway to specify the --project-root path for daml codegen java? I put codegen configuration in daml.yam file and use maven to invoke the daml codegen. However it only searches the current folder for daml.yaml file and I cannot pass the --project-root. It will be handy to have --project-root option like daml build.

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.

We just merged a fix for this so starting from next week’s snapshot release, DAML_PROJECT will do the job.