64 Local dependencies
The app declares a direct dependency on library in module.norm. Package the separate library into the local package repository first, then run the consumer; the app uses the dependency declaration and public Greeting type.
Library module description:
Module module() {
return module(name: "library", version: 1, exports: ["model.Greeting"])
}Public type:
package library.model
public value Greeting {
public String text
}Consumer module description:
Module module() {
return module(
name: "app",
version: 1,
exports: ["Main"],
dependencies: [dependency(repository: "github", name: "library", version: 1)]
)
}Consumer entry:
package app
import library.model.Greeting
main() {
Greeting greeting = Greeting(text: "Norm")
printLine(greeting.text)
}From the repository root, prepare the local package and run the app (--output points to the local Norm package cache):
norm package norm/tests/docs/dependency/producer/library/module.norm --output "$HOME/.norm/cache/packages"
norm run norm/tests/docs/dependency/app/Main.normExpected output:
NormThe library project lives outside the consumer source tree. The checked example also runs a copied consumer without library source, proving that the packaged dependency is used.
Try it: Change the library greeting, package the library again, and rerun the consumer to observe the new value.
Precise rules: Module and dependencies.