Toolbox export using 19a style project files
7 views (last 30 days)
I'm very confused about these new project files. I have a .prj file that I've used for ages to package my code into a .mltbx file. With 19a we have what looks like a different sort of project file, also with the .prj extension. They do have different icons in the MATLAB file browser, but the documentation seems to treat the term "project file" interchangeably.
The new project file seems like a useful improvement, it knows all about the project, what files are included etc. I don't see why we need both kinds of project file.
If I use the programmatic interface (matlab.addons.toolbox.packageToolbox) to package my toolbox it will only work with the first sort of .prj file, not the second sort - that generates the error message "Invalid MATLAB toolbox project".
- is it proper to call both of these file types "project files"? The documention does.
- when adding or subtracting files to my project do I have to update both files? The 19a project file can export the sort of project file that can be used for packaging (ToolboxPackagingConfiguration.prj), but that exported file is missing all the metadata (image, author, description etc.) which should logically live in the 19a style project file.
- what's the rationale for having two files? Could all the information about my project, including how to package it (ie. the metadata) live in the one file?
Gavin Walker on 5 Oct 2019
In R2019a we introduced Projects to MATLAB -- https://www.mathworks.com/help/matlab/projects.html
A lot of this functionality will be familiar to Simulink users, who've had access to these capabilities for many releases under the old name of "Simulink Projects". A project is used to set up and manage your MATLAB environment: it contains all the files you need for your work and it can set-up (and tear down) your MATLAB path automatically. It includes file dependency analysis capabilities that let you see how your project is structured, check for missing files and see what toolboxes it needs.
And projects have a lot of other capabilities to support working across a team like nice integration with source control tools, proejct shortcuts to help others find the important files in your project and project labels that let you add more information to the project about what specific files do. For example, when those labels are used to define which of your files are tests, then other featues, like runtests (https://www.mathworks.com/help/matlab/ref/runtests.html) can find and run those tests automatically.
So a project is the place where you develop things. It has all your source code, your tests, requirements and so on. If you want to share this with a collegue who is going to help develop it with you (or perhaps test it), then you can share the whole project with them, usually via a source control repository.
When you want to share your work with someone else who just wants to use it, not develop it, then it might make sense to package it as a toolbox and create an MLTBX file. This can be done right from the project from the "share" button. Likely, the toolbox will not include all the files in the project (you might strip out the tests and requirements files, for example) and those same project labels can help here, too. ( https://www.mathworks.com/help/simulink/ug/share-project-as-a-matlab-toolbox.html )
To answer your other question, today you have to manually keep the two different definitions (files in my project; subset I want to package as a toolbox) up-to-date manually but this is really helpful feedback for us as we continue to develop these features.