com.vaadin.flow.server.frontend.

Class NodeTasks.Builder

    • Field Detail

      • npmFolder

        public final File npmFolder

        Directory for npm and folders and files.

      • generatedFolder

        public final File generatedFolder

        Directory where generated files are written.

    • Constructor Detail

      • Builder

        public Builder(Lookup lookup,
                       File npmFolder)

        Create a builder instance given an specific npm folder.

        Parameters:

        lookup - a Lookup to discover services used by Flow (SPI)

        npmFolder - folder with the `package.json` file

      • Builder

        public Builder(Lookup lookup,
                       File npmFolder,
                       File generatedPath)

        Create a builder instance with custom npmFolder and generatedPath

        Parameters:

        lookup - a Lookup to discover services used by Flow (SPI)

        npmFolder - folder with the `package.json` file

        generatedPath - folder where flow generated files will be placed.

      • Builder

        public Builder(Lookup lookup,
                       File npmFolder,
                       File generatedPath,
                       File frontendDirectory)

        Create a builder instance with all parameters.

        Parameters:

        lookup - a Lookup to discover services used by Flow (SPI)

        npmFolder - folder with the `package.json` file

        generatedPath - folder where flow generated files will be placed.

        frontendDirectory - a directory with project's frontend files

    • Method Detail

      • build

        public NodeTasks build()

        Creates a NodeExecutor using this configuration.

        Returns:

        a NodeExecutor instance

      • withWebpack

        public NodeTasks.Builder withWebpack(File webpackOutputDirectory,
                                             File resourceOutputDirectory,
                                             String webpackTemplate,
                                             String webpackGeneratedTemplate)

        Sets the webpack related properties.

        Parameters:

        webpackOutputDirectory - the directory to set for webpack to output its build results, meant for serving from context root.

        resourceOutputDirectory - the directory to output generated non-served resources, such as the "config/stats.json" stats file, and the "config/flow-build-info.json" token file.

        webpackTemplate - name of the webpack resource to be used as template when creating the webpack.config.js file.

        webpackGeneratedTemplate - name of the webpack resource to be used as template when creating the webpack.generated.js file.

        Returns:

        this builder

      • enablePackagesUpdate

        public NodeTasks.Builder enablePackagesUpdate(boolean enablePackagesUpdate)

        Sets whether to enable packages and webpack file updates. Default is true.

        Parameters:

        enablePackagesUpdate - true to enable packages and webpack update, otherwise false

        Returns:

        this builder

      • enableNpmFileCleaning

        public NodeTasks.Builder enableNpmFileCleaning(boolean forceClean)

        Sets whether to perform always perform clean up procedure. Default is false. When the value is false, npm related files will only be removed when a platform version update is detected.

        Parameters:

        forceClean - true to clean npm files always, otherwise false

        Returns:

        this builder

      • enableImportsUpdate

        public NodeTasks.Builder enableImportsUpdate(boolean enableImportsUpdate)

        Sets whether to enable imports file update. Default is false. This will also enable creation of missing package files if set to true.

        Parameters:

        enableImportsUpdate - true to enable imports file update, otherwise false

        Returns:

        this builder

      • runNpmInstall

        public NodeTasks.Builder runNpmInstall(boolean runNpmInstall)

        Sets whether run npm install after updating dependencies.

        Parameters:

        runNpmInstall - run npm install. Default is false

        Returns:

        the builder

      • withFlowResourcesFolder

        public NodeTasks.Builder withFlowResourcesFolder(File flowResourcesFolder)

        Sets the appropriate npm package folder for copying flow resources in jars.

        Parameters:

        flowResourcesFolder - target folder

        Returns:

        the builder

      • copyResources

        public NodeTasks.Builder copyResources(Set<File> jars)

        Sets whether copy resources from classpath to the appropriate npm package folder so as they are available for webpack build.

        Parameters:

        jars - set of class nodes to be visited. Not null

        Returns:

        the builder

      • withEmbeddableWebComponents

        public NodeTasks.Builder withEmbeddableWebComponents(boolean generateEmbeddableWebComponents)

        Sets whether to collect and package WebComponentExporter dependencies.

        Parameters:

        generateEmbeddableWebComponents - collect dependencies. Default is true

        Returns:

        the builder

      • createMissingPackageJson

        public NodeTasks.Builder createMissingPackageJson(boolean create)

        Sets whether to create the package file if missing.

        Parameters:

        create - create the package

        Returns:

        the builder

      • copyLocalResources

        public NodeTasks.Builder copyLocalResources(File localResourcesFolder)

        Set local frontend files to be copied from given folder.

        Parameters:

        localResourcesFolder - folder to copy local frontend files from

        Returns:

        the builder, for chaining

      • useV14Bootstrap

        public NodeTasks.Builder useV14Bootstrap(boolean useDeprecatedV14Bootstrapping)

        Use V14 bootstrapping that disables index.html entry point.

        Parameters:

        useDeprecatedV14Bootstrapping - true to use legacy V14 bootstrapping

        Returns:

        the builder, for chaining

      • withConnectClientTsApiFolder

        public NodeTasks.Builder withConnectClientTsApiFolder(File connectClientTsApiFolder)

        Set the folder where Ts files should be generated.

        Parameters:

        connectClientTsApiFolder - folder for Ts files in the frontend.

        Returns:

        the builder, for chaining

      • withConnectApplicationProperties

        public NodeTasks.Builder withConnectApplicationProperties(File applicationProperties)

        Set application properties file for Spring project.

        Parameters:

        applicationProperties - application properties file.

        Returns:

        this builder, for chaining

      • withConnectGeneratedOpenApiJson

        public NodeTasks.Builder withConnectGeneratedOpenApiJson(File generatedOpenApiFile)

        Set output location for the generated OpenAPI file.

        Parameters:

        generatedOpenApiFile - the generated output file.

        Returns:

        the builder, for chaining

      • withConnectJavaSourceFolder

        public NodeTasks.Builder withConnectJavaSourceFolder(File connectJavaSourceFolder)

        Set source paths that OpenAPI generator searches for endpoints.

        Parameters:

        connectJavaSourceFolder - java source folder

        Returns:

        the builder, for chaining

      • useByteCodeScanner

        public NodeTasks.Builder useByteCodeScanner(boolean byteCodeScanner)

        Sets frontend scanner strategy: byte code scanning strategy is used if byteCodeScanner is true, full classpath scanner strategy is used otherwise (by default).

        Parameters:

        byteCodeScanner - if true then byte code scanner is used, full scanner is used otherwise (by default).

        Returns:

        the builder, for chaining

      • populateTokenFileData

        public NodeTasks.Builder populateTokenFileData(elemental.json.JsonObject object)

        Fill token file data into the provided object.

        Parameters:

        object - the object to fill with token file data

        Returns:

        the builder, for chaining

      • withTokenFile

        public NodeTasks.Builder withTokenFile(File tokenFile)

        Sets the token file (flow-build-info.json) path.

        Parameters:

        tokenFile - token file path

        Returns:

        the builder, for chaining

      • enablePnpm

        public NodeTasks.Builder enablePnpm(boolean enable)

        Enables pnpm tool.

        "pnpm" will be used instead of "npm".

        Parameters:

        enable - enables pnpm.

        Returns:

        the builder, for chaining

      • withHomeNodeExecRequired

        public NodeTasks.Builder withHomeNodeExecRequired(boolean requireHomeNodeExec)

        Requires node executable to be installed in vaadin home folder.

        Parameters:

        requireHomeNodeExec - requires vaadin home node exec

        Returns:

        the builder, for chaining

      • withNodeVersion

        public NodeTasks.Builder withNodeVersion(String nodeVersion)

        Sets the node.js version to be used when node.js is installed automatically by Vaadin, for example "v14.15.4". Defaults to .

        Parameters:

        nodeVersion - the new node version to download, not null.

        Returns:

        the builder, for chaining

      • withNodeDownloadRoot

        public NodeTasks.Builder withNodeDownloadRoot(URI nodeDownloadRoot)

        Sets the download node.js URL. Handy in heavily firewalled corporate environments where the node.js download can be provided from an intranet mirror. Defaults to NodeInstaller.DEFAULT_NODEJS_DOWNLOAD_ROOT.

        Parameters:

        nodeDownloadRoot - the new download URL to set, not null.

        Returns:

        the builder, for chaining