What is the purpose of [extras] and [targets] in a Julia Project.toml?
Asked Answered
D

1

8

In the following example (code copied from the Flux project.toml) what is the purpose of the [extras] and [targets] sections?

[compat]
Adapt = "3.0"
ArrayInterface = "3.1, 4, 5, 6"
CUDA = "3"
.
.
.
Zygote = "0.6.34"
julia = "1.6"

[extras]
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
.
.
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Documenter", "IterTools", "LinearAlgebra", "FillArrays", "ComponentArrays"]
Didst answered 28/7, 2022 at 7:2 Comment(1)
pkgdocs.julialang.org/v1/creating-packages/…Placida
E
4

It's used to specify dependencies for a sub-directory but at the same time these dependencies are not used by the package.

Having

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

means the target test/ uses the dependency Test. And the Test dependency is extra which means it won't be used by the package.

This is the equivalent of having test/Project.toml with the content of:

[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Note that the first method is compatible with all Julia 1.x versions unlike the second one.

Expense answered 28/7, 2023 at 19:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.