Skip to content

Commit 532de69

Browse files
committed
fix: packaged toolbox should contain missing resources files
1 parent d37d1b3 commit 532de69

File tree

5 files changed

+45
-34
lines changed

5 files changed

+45
-34
lines changed

resources/release-notes.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
## App
2-
3-
- (All) Add shortcut to open app from toolbar (quick access)
4-
- (All) Fix errors when closing app during mission selection
5-
- (IMAP) Replace `error` with `uialert` for CPT view when mode or range patterns are incorrect
6-
7-
## Software
8-
9-
- (All) Add `mag.mixin.TimeSeriesOperationSupport` for simplified operations support
10-
- (All) Fix issues with colors and legends for multiple stackedplots
11-
- (IMAP) Fix cropping of events when no events are loaded
12-
- (IMAP) Check there is data before enabling auto-compression event in `mag.imap.view.Field`
13-
141
## Package
152

16-
- Add MATLAB package definition
17-
- Remove MATLAB project definition
3+
- Add missing files (MATLAB extensions and related icons)

src/utility/+mag/+buildtool/+task/PackageTask.m

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
classdef (Sealed) PackageTask < matlab.buildtool.Task
22
% PACKAGETASK Package code into toolbox.
33

4+
properties (Constant)
5+
ToolboxName (1, 1) string = mag.internal.getPackageDetails("DisplayName")
6+
end
7+
48
properties (Constant, Access = private)
59
ToolboxUUID (1, 1) string = "69962df8-e93e-47cd-a1d6-766ad3e9da8a"
610
end
@@ -49,10 +53,10 @@ function packageToolbox(task, ~, version)
4953
end
5054

5155
toolboxOptions = matlab.addons.toolbox.ToolboxOptions(task.PackageRoot, task.ToolboxUUID, ...
52-
ToolboxName = "MAG Data Visualization", ...
56+
ToolboxName = mag.buildtool.task.PackageTask.ToolboxName, ...
5357
ToolboxVersion = version, ...
54-
Description = "Source code for MAG Data Visualization toolbox.", ...
55-
ToolboxFiles = fullfile(task.PackageRoot, ["app", "src"]), ...
58+
Description = mag.internal.getPackageDetails("Description"), ...
59+
ToolboxFiles = task.getToolboxFiles(), ...
5660
ToolboxMatlabPath = task.getMATLABPath(), ...
5761
ToolboxImageFile = fullfile(task.PackageRoot, "icons", "logo.png"), ...
5862
OutputFile = task.ToolboxPath, ...
@@ -67,13 +71,23 @@ function packageToolbox(task, ~, version)
6771
end
6872
end
6973

74+
methods (Access = private)
75+
76+
function files = getToolboxFiles(task)
77+
78+
files = fullfile(task.PackageRoot, ["app", "src", ...
79+
fullfile("resources", "extensions.json"), ...
80+
fullfile("icons", "mag.png")]);
81+
end
82+
end
83+
7084
methods (Static, Access = private)
7185

7286
function matlabPath = getMATLABPath()
7387

7488
matlabPath = string(split(path(), pathsep()));
7589

76-
locMAG = contains(matlabPath, "MAG-Data-Visualization") & contains(matlabPath, ["app", "src"]);
90+
locMAG = contains(matlabPath, "MAG-Data-Visualization") & ~contains(matlabPath, ["tests"]);
7791
matlabPath = matlabPath(locMAG);
7892
end
7993
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function details = getPackageDetails(fieldName)
2+
% GETPACKAGEDETAILS Load MATLAB package details from manifest.
3+
4+
arguments (Input)
5+
fieldName string {mustBeScalarOrEmpty, mustBeNonzeroLengthText} = string.empty()
6+
end
7+
8+
root = fullfile(fileparts(mfilename("fullpath")), "../../../../");
9+
details = readstruct(fullfile(root, "resources", "mpackage.json"));
10+
11+
if ~isempty(fieldName)
12+
13+
% If the first letter is capitalized (for compatibility with
14+
% "matlab.mpm.Package" properties), make it lowercase.
15+
fieldName = regexprep(fieldName, "(\w)(\w+)", "${lower($1)}$2");
16+
17+
details = details.(fieldName);
18+
end
19+
end

src/utility/+mag/version.m

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,7 @@
99
persistent ver;
1010

1111
if isempty(ver)
12-
13-
location = fileparts(mfilename("fullpath"));
14-
root = fullfile(location, "../../../");
15-
16-
if isMATLABReleaseOlderThan("R2025a")
17-
18-
package = readstruct(fullfile(root, "resources", "mpackage.json"));
19-
ver = package.version;
20-
else
21-
22-
package = matlab.mpm.Package(root);
23-
ver = package.Version;
24-
end
12+
ver = mag.internal.getPackageDetails("Version");
2513
end
2614

2715
v = ver;

tests/system/package/tToolbox.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
function useMATLABR2025aOrAbove(testCase)
1515
testCase.assumeFalse(isMATLABReleaseOlderThan("R2025a"), "Only MATLAB R2025a or later is supported for this test.");
1616
end
17+
18+
function checkMATLABPackage(testCase)
19+
testCase.assumeEmpty(mpmlist(mag.buildtool.task.PackageTask.ToolboxName), "MAG Data Visualization installed as a MATLAB package.");
20+
end
1721
end
1822

1923
methods (Test)
@@ -46,10 +50,10 @@ function installToolbox(testCase)
4650
testCase.assertTrue(isfile(task.ToolboxArtifact.Path), "Toolbox should be generated.");
4751

4852
matlab.addons.install(task.ToolboxArtifact.Path);
49-
testCase.addTeardown(@() matlab.addons.uninstall("MAG Data Visualization"));
53+
testCase.addTeardown(@() matlab.addons.uninstall(mag.buildtool.task.PackageTask.ToolboxName));
5054

5155
addOns = matlab.addons.installedAddons();
52-
locMAG = addOns.Name == "MAG Data Visualization";
56+
locMAG = addOns.Name == mag.internal.getPackageDetails("DisplayName");
5357

5458
testCase.verifyEqual(addOns{locMAG, "Version"}, mag.version(), "Toolbox version should be equal to MAG version.");
5559
end

0 commit comments

Comments
 (0)