compiler.build.webAppArchive

Create an archive for deployment to MATLAB Web App Server

Description

example

compiler.build.webAppArchive(AppFile) creates a web app archive using a MATLAB® app specified by AppFile.

example

compiler.build.webAppArchive(AppFile,Name,Value) creates a web app archive with options specified as one or more name-value pairs. Options include the archive name, additional files to include, and the output directory.

example

compiler.build.webAppArchive(opts) creates a web app archive with options specified by a compiler.build.WebAppArchiveOptions object opts. You cannot specify any other options using name-value pairs.

example

results = compiler.build.webAppArchive(___) returns build information as a compiler.build.Results object using any of the input arguments in previous syntaxes. Build information includes the build type, the path to the compiled archive, and build options.

Examples

collapse all

Create a web app archive on a Windows® system from an existing MATLAB app named example.mlapp.

Build a web app using the compiler.build.webAppArchive command.

buildResults = compiler.build.webAppArchive('example.mlapp');

This generates the following files within a folder named examplewebapp in your current working directory:

  • example.ctf—Deployable web app archive file.

  • mccExcludedFiles.log—Log file that contains a list of any toolbox functions that were not included in the application. For more information on non-supported functions, see MATLAB Compiler Limitations.

  • requiredMCRProducts.txt—Text file that contains product IDs of products required by MATLAB Runtime to run the application.

Customize a web app archive using name-value pairs on a Windows system to specify the archive name and output directory, and automatically include data files provided as inputs to functions such as load.

compiler.build.webAppArchive('example.mlapp',...
    'ArchiveName','MyWebApp',...
    'OutputDir','D:\Documents\MATLAB\work\WebApps',...
    'AutoDetectDataFiles','on')

Customize multiple web app archives using a compiler.build.WebAppArchiveOptions object on a Windows system to specify a common output directory, include a MAT-file containing workspace variables, and enable build verbosity.

Create a WebAppArchiveOptions object.

opts = compiler.build.WebAppArchiveOptions('example.mlapp',...
    'AdditionalFiles','myvars.mat',...    
    'OutputDir','D:\Documents\MATLAB\work\WebApps',...
    'Verbose','on',...)
opts = 

  WebAppArchiveOptions with properties:

            ArchiveName: 'example'
                AppFile: 'D:\Documents\MATLAB\work\example.mlapp'
        AdditionalFiles: {'D:\Documents\MATLAB\work\myvars.mat'}
    AutoDetectDataFiles: on
              OutputDir: 'D:\Documents\MATLAB\work\WebApps'
                Verbose: on

Build a web app archive by passing the WebAppArchiveOptions object as an input to the build function.

buildResults = compiler.build.webAppArchive(opts);

You can modify property values of an existing WebAppArchiveOptions object using dot notation. For example, change the input file to example2.m.

opts.AppFile = 'example2.m';

This allows you to compile multiple archives using the same options object.

Create a web app archive and save the build type, path to the archive file, and build options to a compiler.build.Results object.

Save the compiler.build.webAppArchive information to a Results object by declaring an output variable.

results = compiler.build.webAppArchive('example.mlapp')
results = 

  Results with properties:

    BuildType: 'webAppArchive'
        Files: {'D:\Documents\MATLAB\work\examplewebAppArchive\example.ctf'}
      Options: [1×1 compiler.build.WebAppArchiveOptions]

Input Arguments

collapse all

Path to the main file, specified as a row character vector or a string scalar. The file must be a MATLAB app with the .mlapp extension. The path can be relative to the current working directory or absolute.

Example: 'mywebapp.mlapp'

Data Types: char | string

Web app build options, specified as a compiler.build.WebAppArchiveOptions object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Verbose','on'

Additional files, specified as a character vector, a string scalar, a string array, or a cell array of character vectors. The listed files are included in the web app archive. File paths can be relative to the current working directory or absolute.

Example: 'AdditionalFiles',["myvars.mat","myfunc.m"]

Data Types: char | string | cell

Name of the generated web app archive, specified as a character vector or a string scalar. The default value is the file name of AppFile.

Example: 'ArchiveName','MyWebApp'

Data Types: char | string

Flag to automatically include data files, specified as 'on' or 'off', or as numeric or logical 1 (true) or 0 (false). A value of 'on' is equivalent to true, and 'off' is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • If you set this property to 'on', then data files that are provided as inputs to certain functions (load, fopen, etc) are automatically included with the web app archive.

  • If you set this property to 'off', then data files must be added to the web app archive using the AdditionalFiles property.

Example: 'AutoDetectDataFiles','Off'

Data Types: logical

Path to the output directory, specified as a character vector or a string scalar. The path can be relative to the current working directory or absolute.

If no path is specified, a build folder named ArchiveNamewebAppArchive is created in the current working directory.

Example: 'OutputDir','D:\Documents\MATLAB\work\mymagicwebAppArchive'

Data Types: char | string

Flag to control build verbosity, specified as 'on' or 'off', or as numeric or logical 1 (true) or 0 (false). A value of 'on' is equivalent to true, and 'off' is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • If you set this property to 'on', then the MATLAB Command Window displays progress information indicating code generation stages and compiler output during the build process.

  • If you set this property to 'off', then the command window does not display progress information.

Example: 'Verbose','On'

Data Types: logical

Output Arguments

collapse all

Build results, returned as a compiler.build.Results object. The Results object contains the build type ('webAppArchive'), the path to the web app archive file (.ctf), and the build options, specified as a WebAppArchiveOptions object.

Introduced in R2020b