Class Options

java.lang.Object
com.vaadin.flow.server.frontend.Options
All Implemented Interfaces:
Serializable

public class Options extends Object implements Serializable
Build a NodeExecutor instance.
See Also:
  • Constructor Details

    • Options

      public Options(Lookup lookup, File npmFolder)
      Creates a new instance.
      Parameters:
      lookup - a Lookup to discover services used by Flow (SPI)
      npmFolder - a project's base folder
    • Options

      public Options(Lookup lookup, ClassFinder classFinder, File npmFolder)
      Creates a new instance.
      Parameters:
      lookup - a Lookup to discover services used by Flow (SPI)
      classFinder - a class finder to use in node tasks
      npmFolder - a project's base folder
  • Method Details

    • withFrontendDirectory

      public Options withFrontendDirectory(File frontendDirectory)
      Sets the directory containing the project's frontend files
      Parameters:
      frontendDirectory - a directory with project's frontend files
      Returns:
      this
    • withBuildDirectory

      public Options withBuildDirectory(String buildDirectory)
      Use the specified directory name (inside the project folder) for the build output.
      Parameters:
      buildDirectory - project build directory
      Returns:
      this builder
    • withBuildResultFolders

      public Options withBuildResultFolders(File webappResourcesDirectory, File resourceOutputDirectory)
      Sets the folders where frontend build results should be stored.
      Parameters:
      webappResourcesDirectory - the directory to set for build tool 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.
      Returns:
      this builder
    • enablePackagesUpdate

      public Options enablePackagesUpdate(boolean enablePackagesUpdate)
      Sets whether to enable packages and frontend file updates. Default is true.
      Parameters:
      enablePackagesUpdate - true to enable packages and frontend update, otherwise false
      Returns:
      this builder
    • enableImportsUpdate

      public Options 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
    • withRunNpmInstall

      public Options withRunNpmInstall(boolean runNpmInstall)
      Sets whether run npm install after updating dependencies.
      Parameters:
      runNpmInstall - run npm install. Default is false
      Returns:
      the builder
    • withJarFrontendResourcesFolder

      public Options withJarFrontendResourcesFolder(File jarFrontendResourcesFolder)
      Sets the appropriate npm package folder for copying flow resources in jars.
      Parameters:
      jarFrontendResourcesFolder - target folder
      Returns:
      the builder
    • copyResources

      public Options copyResources(Set<File> jars)
      Sets whether copy resources from classpath to the appropriate npm package folder so as they are available for frontend build.
      Parameters:
      jars - set of class nodes to be visited. Not null
      Returns:
      the builder
    • withCopyTemplates

      public Options withCopyTemplates(boolean copyTemplates)
      Sets whether copy templates to META-INF/VAADIN/config/templates.
      Parameters:
      copyTemplates - whether to copy templates
      Returns:
      the builder
    • withEmbeddableWebComponents

      public Options withEmbeddableWebComponents(boolean generateEmbeddableWebComponents)
      Sets whether to collect and package WebComponentExporter dependencies.
      Parameters:
      generateEmbeddableWebComponents - collect dependencies. Default is true
      Returns:
      the builder
    • createMissingPackageJson

      public Options createMissingPackageJson(boolean create)
      Sets whether to create the package file if missing.
      Parameters:
      create - create the package
      Returns:
      the builder
    • copyLocalResources

      public Options 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
    • withFrontendGeneratedFolder

      public Options withFrontendGeneratedFolder(File frontendGeneratedFolder)
      Set the folder where frontend files should be generated.
      Parameters:
      frontendGeneratedFolder - folder to generate frontend files in.
      Returns:
      the builder, for chaining
    • getFrontendGeneratedFolder

      public File getFrontendGeneratedFolder()
      Gets the folder where frontend files should be generated.
      Returns:
      folder to generate frontend files in
    • useByteCodeScanner

      public Options 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 Options populateTokenFileData(tools.jackson.databind.JsonNode 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 Options withTokenFile(File tokenFile)
      Sets the token file (flow-build-info.json) path.
      Parameters:
      tokenFile - token file path
      Returns:
      the builder, for chaining
    • withEnablePnpm

      public Options withEnablePnpm(boolean enable)
      Enables pnpm tool.

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

      Parameters:
      enable - enables pnpm.
      Returns:
      the builder, for chaining
    • withEnableBun

      public Options withEnableBun(boolean enable)
      Enables bun tool.

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

      Parameters:
      enable - enables bun.
      Returns:
      the builder, for chaining
    • withCiBuild

      public Options withCiBuild(boolean ciBuild)
      Enables ci build.

      "npm ci" will be used instead of "npm install". "--frozen-lockfile" will be used if pnpm is used instead of npm.

      Parameters:
      ciBuild - true to enable ci build
      Returns:
      the builder, for chaining
    • withForceProductionBuild

      public Options withForceProductionBuild(boolean forceProductionBuild)
      Setting this to true will force a build of the production build even if there is a default production bundle that could be used.
      Parameters:
      forceProductionBuild - true to force production build
      Returns:
      the builder, for chaining
    • useGlobalPnpm

      public Options useGlobalPnpm(boolean useGlobalPnpm)
      Uses globally installed pnpm tool for frontend packages installation.
      Parameters:
      useGlobalPnpm - uses globally installed pnpm instead of default one, see FrontendTools.DEFAULT_PNPM_VERSION.
      Returns:
      the builder, for chaining
    • withHomeNodeExecRequired

      public Options 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 Options withNodeVersion(String nodeVersion)
      Sets the node.js version to be used when node.js is installed automatically by Vaadin, for example "v16.0.0". Defaults to "v24.10.0".
      Parameters:
      nodeVersion - the new node version to download, not null.
      Returns:
      the builder, for chaining
    • withNodeDownloadRoot

      public Options 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
    • withProductionMode

      public Options withProductionMode(boolean productionMode)
      Sets the production mode.
      Parameters:
      productionMode - true to enable production mode, otherwise false
      Returns:
      this builder
    • withFrontendHotdeploy

      public Options withFrontendHotdeploy(boolean frontendHotdeploy)
      Whether to run with a dev server (when not in production mode).
      Parameters:
      frontendHotdeploy - true to run with a dev server, false to run in development bundle mode
      Returns:
      this builder
    • withFrontendIgnoreVersionChecks

      public Options withFrontendIgnoreVersionChecks(boolean frontendIgnoreVersionChecks)
      Whether to ignore node/npm tool version checks or not. Defaults to false.
      Parameters:
      frontendIgnoreVersionChecks - true to ignore node/npm tool version checks
      Returns:
      the builder, for chaining
    • isFrontendHotdeploy

      public boolean isFrontendHotdeploy()
      Checks if running with a dev server (when not in production mode).
      Returns:
      true to run with a dev server, false to run in development bundle mode
    • isDevBundleBuild

      public boolean isDevBundleBuild()
      Check if a dev mode bundle build should run.
      Returns:
      true to run the build, false otherwise
    • withBundleBuild

      public Options withBundleBuild(boolean bundleBuild)
      Whether to run bundle build. Needed when not using a dev server or running for production.
      Parameters:
      bundleBuild - true to run a bundle build
      Returns:
      this builder
    • isBundleBuild

      public boolean isBundleBuild()
      Check if a bundle build should run.
      Returns:
      true to run the build, false otherwise
    • setNodeAutoUpdate

      public Options setNodeAutoUpdate(boolean update)
      Sets whether it is fine to automatically update the alternate node installation if installed version is older than the current default.
      Parameters:
      update - true to update alternate node when used
      Returns:
      the builder
    • setJavaResourceFolder

      public Options setJavaResourceFolder(File javaResourceFolder)
      Set the java resources folder to be checked for feature file.

      Needed for plugin execution.

      Parameters:
      javaResourceFolder - java resources folder
      Returns:
      this builder
    • withPostinstallPackages

      public Options withPostinstallPackages(List<String> postinstallPackages)
      Sets the additional npm packages to run postinstall for.

      By default, postinstall is only run for internal dependencies which rely on post install scripts to work, e.g. esbuild

      Parameters:
      postinstallPackages - the additional npm packages to run postinstall for
      Returns:
      the builder, for chaining
    • getNpmFolder

      public File getNpmFolder()
      Get the npm folder used for this build.
      Returns:
      npmFolder
    • getWebappResourcesDirectory

      public File getWebappResourcesDirectory()
      Get the output directory for frontend build output.
      Returns:
      webappResourcesDirectory
    • getFrontendDirectory

      public File getFrontendDirectory()
      Get the defined frontend directory.
      Returns:
      frontendDirectory
    • getBuildDirectoryName

      public String getBuildDirectoryName()
      Get the name of the used build directory.

      By default this will be target for maven and build for gradle.

      Returns:
      The name of the build directory
    • getBuildDirectory

      public File getBuildDirectory()
      Gets the directory used for the build output.
      Returns:
      the build directory
    • withFeatureFlags

      public Options withFeatureFlags(FeatureFlags featureFlags)
    • getFeatureFlags

      public FeatureFlags getFeatureFlags()
      Get the available feature flags.
      Returns:
      FeatureFlags object
    • getJarFrontendResourcesFolder

      public File getJarFrontendResourcesFolder()
      Gets the folder to which frontend resources from add-on jars are copied.
      Returns:
      the jar resource folder
    • getClassFinder

      public ClassFinder getClassFinder()
      Gets the used class finder.
      Returns:
      the class finder
    • getNodeModulesFolder

      public File getNodeModulesFolder()
    • getResourceOutputDirectory

      public File getResourceOutputDirectory()
    • isEnablePackagesUpdate

      public boolean isEnablePackagesUpdate()
    • isCreateMissingPackageJson

      public boolean isCreateMissingPackageJson()
    • isEnableImportsUpdate

      public boolean isEnableImportsUpdate()
    • isEnableConfigUpdate

      public boolean isEnableConfigUpdate()
    • isRunNpmInstall

      public boolean isRunNpmInstall()
    • getJarFiles

      public Set<File> getJarFiles()
    • isGenerateEmbeddableWebComponents

      public boolean isGenerateEmbeddableWebComponents()
    • isCleanNpmFiles

      @Deprecated(since="25.0", forRemoval=true) public boolean isCleanNpmFiles()
      Deprecated, for removal: This API element is subject to removal in a future version.
      used internally only for testing, to be removed without a replacement.
      Returns:
      true if npm files should be cleaned, false otherwise
    • getLocalResourcesFolder

      public File getLocalResourcesFolder()
    • isUseByteCodeScanner

      public boolean isUseByteCodeScanner()
    • getTokenFileData

      public tools.jackson.databind.JsonNode getTokenFileData()
    • getTokenFile

      public File getTokenFile()
    • isEnablePnpm

      public boolean isEnablePnpm()
    • isEnableBun

      public boolean isEnableBun()
    • isCiBuild

      public boolean isCiBuild()
    • isForceProductionBuild

      public boolean isForceProductionBuild()
    • isUseGlobalPnpm

      public boolean isUseGlobalPnpm()
    • isRequireHomeNodeExec

      public boolean isRequireHomeNodeExec()
    • isCopyTemplates

      public boolean isCopyTemplates()
    • getNodeVersion

      public String getNodeVersion()
    • getNodeDownloadRoot

      public URI getNodeDownloadRoot()
    • isNodeAutoUpdate

      public boolean isNodeAutoUpdate()
    • getLookup

      public Lookup getLookup()
      Gets the lookup instance to use for internal lookups.
      Returns:
      the lookup instance
    • isProductionMode

      public boolean isProductionMode()
      Gets the production mode.
      Returns:
      true if production mode is enabled, otherwise false
    • getJavaResourceFolder

      public File getJavaResourceFolder()
      Gets the folder containing java resources, typically src/main/resources in a Maven project.
      Returns:
      the java resource folder
    • getPostinstallPackages

      public List<String> getPostinstallPackages()
    • skipDevBundleBuild

      public Options skipDevBundleBuild(boolean skip)
      Set to true to skip dev bundle build in case a dev bundle exists.

      Dev bundle build will not be skipped in case no dev bundle is found.

      Parameters:
      skip - true to skip rebuild of dev bundle
      Returns:
      this builder
    • isSkipDevBundle

      public boolean isSkipDevBundle()
      Is dev bundle build skipped or not.
      Returns:
      true to skip dev bundle checks, false to run normally. Default is false
    • withCompressBundle

      public Options withCompressBundle(boolean compressBundle)
      Set to false to skip frontend bundle compression.
      Parameters:
      compressBundle - false to not compress frontend bundles
      Returns:
      this builder
    • isCompressBundle

      public boolean isCompressBundle()
      Get if frontend bundle should be compressed or not.
      Returns:
      true to copress, false to skip compression
    • isReactEnabled

      public boolean isReactEnabled()
    • withReact

      public Options withReact(boolean reactEnable)
    • withCleanOldGeneratedFiles

      public Options withCleanOldGeneratedFiles(boolean clean)
      Sets whether generated files from a previous execution that are no more created should be removed.

      By default, the odl generated files are preserved.

      Parameters:
      clean - true if old generated files should be removed, false if they should be preserved.
      Returns:
      this builder
    • isCleanOldGeneratedFiles

      public boolean isCleanOldGeneratedFiles()
      Gets if generated files from a previous execution that are no more created should be removed.
      Returns:
      true if old generated files should be removed, otherwise false.
    • withFrontendExtraFileExtensions

      public Options withFrontendExtraFileExtensions(List<String> frontendExtraFileExtensions)
      Sets the extra file extensions used in the project.
      Parameters:
      frontendExtraFileExtensions - the file extensions to add for the project
      Returns:
      this builder
    • getFrontendExtraFileExtensions

      public List<String> getFrontendExtraFileExtensions()
      Gets the project file extensions.
      Returns:
      the project file extensions
    • isNpmExcludeWebComponents

      public boolean isNpmExcludeWebComponents()
      Sets whether to exclude web component npm packages in packages.json.
      Returns:
      this builder
    • withNpmExcludeWebComponents

      public Options withNpmExcludeWebComponents(boolean exclude)
      Sets whether to exclude web component npm packages in packages.json.
      Parameters:
      exclude - whether to exclude web component npm packages
      Returns:
      this builder
    • isFrontendIgnoreVersionChecks

      public boolean isFrontendIgnoreVersionChecks()
      Whether to ignore node/npm tool version checks or not.
      Returns:
      true to ignore node/npm tool version checks
    • withFrontendDependenciesScanner

      public Options withFrontendDependenciesScanner(FrontendDependenciesScanner frontendDependenciesScanner)
      Sets the frontend dependencies scanner to use.
      Parameters:
      frontendDependenciesScanner - frontend dependencies scanner
      Returns:
      this builder
    • isCommercialBannerEnabled

      public boolean isCommercialBannerEnabled()
      Checks if the commercial banner is enabled for the build.
      Returns:
      true if the commercial banner is enabled, false otherwise
    • withCommercialBanner

      public Options withCommercialBanner(boolean enableCommercialBanner)
      Sets whether the build could generate an application with a commercial banner.
      Parameters:
      enableCommercialBanner - a boolean value indicating whether the built application could add a commercial banner.
      Returns:
      this builder
    • getFrontendDependenciesScanner

      public FrontendDependenciesScanner getFrontendDependenciesScanner()
      Gets the frontend dependencies scanner to use. If not is not pre-set, this initializes a new one based on the Options set.
      Returns:
      frontend dependencies scanner
    • setCopyAssets

      public Options setCopyAssets(boolean copyAssets)
      Sets whether to copy npm assets or not. True by default.
      Parameters:
      copyAssets - boolean value indicating if npm assets should be copied.
      Returns:
      this builder
    • copyAssets

      public boolean copyAssets()
      Get if npm assets should be copied for this Options execution.

      NOTE! For a devBundleBuild copy assets will always be true!

      Returns:
      false to skip copying except for devBundleBuild.