Class BuildFrontendMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.vaadin.flow.plugin.maven.FlowModeAbstractMojo
com.vaadin.flow.plugin.maven.BuildFrontendMojo
All Implemented Interfaces:
PluginAdapterBase, PluginAdapterBuild, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="build-frontend", requiresDependencyResolution=COMPILE_PLUS_RUNTIME, defaultPhase=PROCESS_CLASSES) public class BuildFrontendMojo extends FlowModeAbstractMojo implements PluginAdapterBuild
Goal that builds the frontend bundle. It performs the following actions when creating a package:
  • Update Constants.PACKAGE_JSON file with the NpmPackage annotations defined in the classpath,
  • Copy resource files used by flow from `.jar` files to the `node_modules` folder
  • Install dependencies by running npm install
  • Update the FrontendUtils.IMPORTS_NAME file imports with the JsModule Theme and JavaScript annotations defined in the classpath,
  • Update FrontendUtils.VITE_CONFIG file.
Since:
2.0
  • Constructor Details

    • BuildFrontendMojo

      public BuildFrontendMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • cleanFrontendFiles

      protected boolean cleanFrontendFiles()
      Define if frontend files generated by bundle build should be cleaned or not.

      The targeted frontend files are files that do not exist when build-frontend target is executed.

      Extending mojo can override this method to return false so that any frontend files created for the bundle build are not removed.

      Returns:
      true to remove created files, false to keep files
    • frontendResourcesDirectory

      public File frontendResourcesDirectory()
      Specified by:
      frontendResourcesDirectory in interface PluginAdapterBuild
    • generateBundle

      public boolean generateBundle()
      Specified by:
      generateBundle in interface PluginAdapterBuild
    • generateEmbeddableWebComponents

      public boolean generateEmbeddableWebComponents()
      Specified by:
      generateEmbeddableWebComponents in interface PluginAdapterBuild
    • optimizeBundle

      public boolean optimizeBundle()
      Specified by:
      optimizeBundle in interface PluginAdapterBuild
    • runNpmInstall

      public boolean runNpmInstall()
      Specified by:
      runNpmInstall in interface PluginAdapterBuild
    • ciBuild

      public boolean ciBuild()
      Specified by:
      ciBuild in interface PluginAdapterBuild
    • forceProductionBuild

      public boolean forceProductionBuild()
      Specified by:
      forceProductionBuild in interface PluginAdapterBuild