Julia Project Files
A project file is a plain text file that names a project and lists its parts. In Julia, that file is called Project.toml.
A project file names a project
This block writes a small project file. Reading it back prints the name and the unique id.
write("Project.toml", "name = \"GreeterApp\"\nuuid = \"11111111-1111-1111-1111-111111111111\"")
println(read("Project.toml", String))The deps section lists packages
This block writes a project file with a deps section. Reading it back prints all three lines.
write("Project.toml", "name = \"CounterApp\"\nuuid = \"22222222-2222-2222-2222-222222222222\"\n[deps]")
println(read("Project.toml", String))One line can be read back on its own
This block writes a project file first. It then prints only its first line.
write("Project.toml", "name = \"ReaderApp\"\nuuid = \"33333333-3333-3333-3333-333333333333\"\n[deps]")
lines = readlines("Project.toml")
println(lines[1])Example
mkpath("DemoApp")
write("DemoApp/Project.toml", "name = \"DemoApp\"\nuuid = \"44444444-4444-4444-4444-444444444444\"\n[deps]\nDemoKit = \"55555555-5555-5555-5555-555555555555\"")
println(read("DemoApp/Project.toml", String))Key points
- Project file: a plain text file that describes one Julia project.
- Name entry: the name line gives the project its name.
- UUID: a long identifier that stays unique to one project.
- Deps section: the deps section lists the packages a project uses.
- Read back: reading the file back shows the exact text that was written.
In this example, a DemoApp folder is created and a project file is written inside it. The file names the project, gives it a unique id, and lists DemoKit under deps. Reading the file back prints all four lines.
Note
Project.toml is plain text, so it can be read like any other text file.
Try it Yourself
Edit the code, then press Run.
Running is simulated · JuliaHub
Exercise
What does the deps section of Project.toml list?