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:
com.vaadin.flow.plugin.base.PluginAdapterBase, com.vaadin.flow.plugin.base.PluginAdapterBuild, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="build-frontend", requiresDependencyResolution=COMPILE_PLUS_RUNTIME, defaultPhase=PREPARE_PACKAGE) public class BuildFrontendMojo extends FlowModeAbstractMojo implements com.vaadin.flow.plugin.base.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

    • executeInternal

      protected void executeInternal() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Description copied from class: FlowModeAbstractMojo
      Perform whatever build-process behavior this Mojo implements.
      This is the main trigger for the Mojo inside the Maven system, and allows the Mojo to communicate errors.
      Specified by:
      executeInternal in class FlowModeAbstractMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayed.
      org.apache.maven.plugin.MojoFailureException - if an expected problem (such as a compilation failure) occurs. Throwing this exception causes a "BUILD FAILURE" message to be displayed.
    • 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 com.vaadin.flow.plugin.base.PluginAdapterBuild
    • generateBundle

      public boolean generateBundle()
      Specified by:
      generateBundle in interface com.vaadin.flow.plugin.base.PluginAdapterBuild
    • generateEmbeddableWebComponents

      public boolean generateEmbeddableWebComponents()
      Specified by:
      generateEmbeddableWebComponents in interface com.vaadin.flow.plugin.base.PluginAdapterBuild
    • optimizeBundle

      public boolean optimizeBundle()
      Specified by:
      optimizeBundle in interface com.vaadin.flow.plugin.base.PluginAdapterBuild
    • runNpmInstall

      public boolean runNpmInstall()
      Specified by:
      runNpmInstall in interface com.vaadin.flow.plugin.base.PluginAdapterBuild
    • ciBuild

      public boolean ciBuild()
      Specified by:
      ciBuild in interface com.vaadin.flow.plugin.base.PluginAdapterBuild
    • forceProductionBuild

      public boolean forceProductionBuild()
      Specified by:
      forceProductionBuild in interface com.vaadin.flow.plugin.base.PluginAdapterBuild
    • compressBundle

      public boolean compressBundle()
      Specified by:
      compressBundle in interface com.vaadin.flow.plugin.base.PluginAdapterBuild
    • checkRuntimeDependency

      public boolean checkRuntimeDependency(String groupId, String artifactId, Consumer<String> missingDependencyMessage)
      Specified by:
      checkRuntimeDependency in interface com.vaadin.flow.plugin.base.PluginAdapterBuild