Ir al contenido principal

Integrating Nodejs and Maven using The Maven Frontend Plugin

In this tutorial I show how to integrate nodejs with maven using the Maven Frontend Plugin, above is the vid and below you will find some useful notes.
  1. 1.

    Pre-reqs

    • Have access to an Adobe Experience Manager instance if you want to install the AEM application and test it. The same pom configs shown here can be used for different types of applications
      Have Maven installed, understand how it works and also understand how to use Adobe's archetype, you can watch my video about maven here: Creating an AEM application using Maven and Adobe's archetype
  2. 2.

    Creating the base app

    • Create the app using adobe's archetype
      mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate "-DarchetypeGroupId=com.adobe.granite.archetypes" "-DarchetypeArtifactId=aem-project-archetype" "-DarchetypeVersion=19" "-DarchetypeCatalog=https://repo.adobe.com/nexus/content/groups/public/" "-DgroupId=co.dlighthouse.aem.firstapp" "-DartifactId=aem-first-app" "-Dversion=0.1.0-SNAPSHOT" "-Dpackage=co.dlighthouse.aem.firstapp" "-DappsFolderName=first-app" "-DconfFolderName=first-app" "-DartifactName=First App Example" "-DcomponentGroupName=First App Example" "-DcontentFolderName=first-app" "-DcssId=first-app" "-DpackageGroup=first-app" "-DsiteName=First App Example" "-DoptionAemVersion=6.4.0"
      
    • Create the nodejs module inside the multimodule maven project using yeoman
      yo aem-application:galen-module
      co.dlighthouse.aem.firstapp
      aem-first-app
      0.1.0-SNAPSHOT
      
    • Don't forget to add the submodule to the list of modules inside your parent pom file
      <modules>
          <module>core</module>
          <module>ui.apps</module>
          <module>ui.content</module>
          <module>it.tests</module>
          <module>it.launcher</module>
          <module>ui.npm.galen</module>
      </modules>
      
  3. 3.

    Maven Frontend Plugin

    • The maven Frontend Plugin allows you to integrate nodejs into your build by just adding a few configurations into the POM file.
    • For this, first you need a plugin configuration on your pom file using the group and artifact Id for the frontend plugin, a version and finally a list of executions that would configure a couple of things about the plugin.
      <project>
      
          ...
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>com.github.eirslett</groupId>
                      <artifactId>frontend-maven-plugin</artifactId>
                      <version>1.8.0</version>
                      <executions>
                          ...
                      </executions>
                  </plugin>
              </plugins>
          </build>
      </project>
      
    • The first execution allows you to set the version for node and npm (you can also use yarn).
          ...
      
          <executions>
              <execution>
                  <id>install node and npm</id>
                  <goals>
                      <goal>install-node-and-npm</goal>
                  </goals>
                  <configuration>
                      <nodeVersion>v12.9.0</nodeVersion>
                      <npmVersion>6.10.2</npmVersion>
                  </configuration>
              </execution>
      
              ...
      
          </executions>
      
          ...
      
    • The second execution installs or updates the packages given what you’ve configured on the package.json file.
          ...
      
          <executions>
              ...
      
              <execution>
                  <id>npm-install</id>
                  <goals>
                      <goal>npm</goal>
                  </goals>
                  <configuration>
                      <arguments>install</arguments>
                  </configuration>
              </execution>
      
              ...
      
          </executions>
      
          ...
      
    • Finally we just need one execution for galen, here we need provide the same name of the script that we have inside the package.json file
      
          ...
      
          <executions>
              ...
      
              <execution>
                  <id>npm-galen</id>
                  <goals>
                      <goal>npm</goal>
                  </goals>
                  <configuration>
                      <arguments>run galen</arguments>
                  </configuration>
              </execution>
          </executions>
      
          ...
      
  4. 4.

Comentarios

Entradas populares de este blog

Create a custom AEM workflow process step with a dialog

In this tutorial I talk about how to create a custom workflow step process with an additional dialog for configuring it, above is the vid and below you will find some useful notes. 1. Pre-reqs Have access to an Adobe Experience Manager instance. Have Maven installed, understand how it works and also understand how to use Adobe's archetype, you can watch my video about maven here: Creating an AEM application using Maven and Adobe's archetype 2. What is an AEM Workflow and workflow model Workflows allow you to automate different tasks inside AEM by defining a s

How to create an AEM component using Reactjs

In this tutorial, I will show how to use use Adobe's archetype to create an AEM application with React.js support and also how to add a new React.js component so that it can be added into a page, above is the vid and below you will find some useful notes. In the second part we will see how to configure the Sling Model for the AEM React component. 1. Pre-reqs Have access to an Adobe Experience Manager instance. You will need aem 6.4 Service Pack 2 or newer. Have Maven installed, understand how it works and also understand how to use Adobe's archetype, you can watch my video about maven here: Creating an AEM application using Maven and Adobe's archetype 2.

Creating Docker containers for Adobe Experience Manager

This is a Docker tutorial for creating a docker image for the Galen framework, above is the vid and below you will find some of the steps followed. Adobe experience manager is a content management system which in a nutshell is an application that allows us to create web sites to be consumed by end users. You might be familiar with other such applications like wordpress or drupal which serves the same purpose A typical deployment would be comprised of two AEM instances, the author instance used for creating and modifying content, the publish instance which serves the content and finally we have a dispatcher which is a static web server used for caching, load balancing and some security purposes. We can configure an AEM instance to work as an author or publish instance by either changing the file name