Packaging an Angular project as a webapp with Maven

javshak

Here's a bit of a strange question : I have an Angular project that talks to a Restful Java application. I was looking for help to package it as a Maven webapp project which can then generate/build a WAR file. Is that something that can me done easily in Maven? So far I created a bare bones app using the 'maven-archetype-webapp' archtype but not entirely sure if the Angular will play nice. The goal was to take the Angular UI and deploy it on some legacy servers (like GlassFish, IBM Websphere AS 9.0 etc.) so that it works like a regular client application. Any help is greatly appreciated.

Joe

I've done something similar with a Vue and Dropwizard based project, set up like so:

  • front end project included in the maven structure under a client directory/module
  • client pom uses the maven exec plugin to run a frontend build (npm in my case, but grunt/gulp/yarn/whatever would work too) during the compile phase of the build
  • client pom uses the maven resources plugin to copy-resources from the frontend build output directory (dist) to a target output subdirectory (${project.build.outputDirectory}/assets) during the prepare-package phase of the build
  • client pom uses the maven jar plugin to jar the output directory during the package phase of the build
  • dropwizard module depends on the client jar, and uses AssetsBundle to serve the frontend app at /assets

The details may differ slightly based on the best way to serve assets under Glassfish/Websphere/etc and the angular build process, but the above approach should be adaptable to those details.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

convert a simple maven project to a webapp

Maven multi module project packaging error

Use pom-packaging maven project as dependency

Maven - Copying resources from client project to webapp

Maven: The packaging for this project did not assign a file to the build artifact

Maven project packaging is war but also building/installing jar

maven deploy: The packaging for this project did not assign a file to the build artifact

PluginVersionResolutionException in Maven project when I set packaging to bundle

Packaging maven project and external jar and property files for GIT upload

How to create "java" folder into a maven webapp project in Intellij?

Where is the welcome page set in a Maven webapp archetype project

How to connect database mysql in maven webapp Servket project?

Angular2 with maven project

Adding angular as maven module in maven project

"Unable to add module to the current project as it is not of packaging type 'pom'" - How to load a given Maven project into Vscode/Vscodium?

What is "pom" packaging in maven?

Maven NumberFormatException when packaging

Maven packaging for websphere

StormCrawler maven packaging error

Modules packaging in maven

java.lang.NoClassDefFoundError: com/typesafe/config/ConfigFactory when packaging Scala project with Maven

Start Spring maven project with Angular 2+

Configure angular 2 project with maven and spring REST

Maven WebApp with Intellij - procedure

Maven HeuristicMixedException with Wildfly webapp

JSP Out.Println() Cannot Resolved, Project Created With WebApp Archteype of Maven

Why I can't use New->Source Folder in a new created maven webapp project in Eclipse?

Base64 class missing from org.glassfish.jersey.internal.util eclipse Maven Webapp project

Maven - execute method before packaging