How can I separate the DAML files from multiple projects depending on them?
I.e.
- DAML files project.
- Front end npm/nodejs project depending on 1).
- Back end java/gradle project depending on 1).
Thanks,
Per
How can I separate the DAML files from multiple projects depending on them?
I.e.
Thanks,
Per
The way I like to do it is to have my daml code in the root project directory and then supporting sections (like /ui
) in their own folder. This is also what’s done with create-daml-app for example.
You can also take a look at reference apps like ex-inventory-management which puts a daml
folder beside their java
backend code.
Ultimately it’s up to you but a common thread is that /daml
, /ui
, and /java
code folders are all beside each other in most projects.
Yes, but I want multiple dependent projects. One for DAML, one for frontend, and one for backend. The build and deploy system would detect changes and do the right thing.
One possibility there is to use git’s submodules which would enable you to have multiple repositories and then a master repository that handles building and deployment.
Yes, understood. But I mean really independent, which is quite common IMHO.
For example, say you have protobuf definitions in one project, N different frontend teams working of those, as well as M backend teams at the same time.
You might not want to use git submodules for that, too coupled.
Anyway, I will look into submodules.
[submodule “daml”]
path = daml
url = git@github.com:perbergman/daml.git
@perbergman
If you were looking for a gradle project structure, here is an idea (sample settings.gradle.kts)
rootProject.name = "Sample"
include("daml-model")
include("daml-codegen-js")
include("daml-codegen-java")
include("front")
include("back")
Under each subfolder, you will have a build.gradle[.kts] to define the build tasks
daml-model
daml source goes here
e.g.
daml damlc ....
daml-codegen-js
daml codegen javascript source here
e.g.
npm build ...
daml-codegen-java
daml codegen java source here
e.g.
gradle assemble
front
you UI frontend source here
This will depends on the modules from #2
e.g.
npm build ...
back
This will depends on the modules from #3
you Java backend source here
e.g.
gradle assemble
Yes, combining this with submodules might work.
I am after a multi-developer setup with isolation of code, build and deploy. So lots of small repos, not a big one with all in.
My personal recommendation re: submodules is to just pretend they don’t exist. I’ve never seen them bring about anything but pain.
If you want multiple, independent projects, I believe you’ll be better off depending on released artifacts from other projects than from trying to tie together their source code. In the case of the DAML project, just have your build system export the corresponding dar file, and other projects can depend on that.
If you really do need source-level integration, I would still recommend a git clone
ran by the build system over submodules for almost any situation.
Yes, I agree. Maybe put the DAR in Nexus?
gradle snippet:
def darFile = file(".daml/dist/iou-1.0.0.dar")
def darArtifact = artifacts.add('archives', darFile) {
type 'dar'
builtBy 'dar'
}
task dar(type: Exec) {
commandLine '/usr/local/bin/daml', 'build'
}
publishing {
publications {
maven(MavenPublication) {
artifact darArtifact
}
}
}
and to use:
configurations {
damlDep
}
dependencies {
damlDep 'damlsrc:damlsrc:1.0.0'
}
task copyDependencies(type: Copy) {
from configurations.damlDep
into '.daml/dist'
}
task codegen(type: Exec) {
commandLine '/usr/local/bin/daml', 'codegen', 'java'
}