Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041781

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:20:15+00:00 2026-06-05T04:20:15+00:00

I am using Maven to build an HTML webapp. I have one profile for

  • 0

I am using Maven to build an HTML webapp. I have one profile for debug and another profile for release. In the debug profile I’d like to have un-compressed Javascript used in the HTML page but in the release profile I concatenate all of the Javascript files and then compress them using Googles Closure compiler.

So basically I have 2 lists of Javascript files that I need to write out as <script> tags into the HTML page based on which profile is selected.

Is there a Maven plugin that I could configure with different lists for different profiles that could generate the HTML file as necessary?

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:20:17+00:00Added an answer on June 5, 2026 at 4:20 am

    After much investigation I determined the best options was to write my own maven plugin. I have a simple .html template which contains directives on where to insert CSS and JS tags into the HTML:

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Fifa Social - Hello World</title>
      <meta name="description" content="Hello World app for Fifa Social">
    
      <meta name="viewport" content="width=device-width">
    
      $cssIncludes$
      $jsIncludes$
    
    </head>
    <body>
        <p>Page content</p>
    </body>
    </html>
    

    I then have a Maven plugin that runs in the “generate-sources” phase of the Maven lifecycle which takes the template and replaces the $cssIncludes$ and $jsIncludes$ with the appropriate list of <script> and <link> tags. (Note: I am using the antlr stringtemplate Java library as a dependency for my plugin).

    I can’t post the actual plugin since it is a proprietary project but it is a single Java class that extends from AbstractMojo

    • it has @parameter properties to read the <configuratioon> from the POM
      • location of html template
      • location of output file
      • the list of JS files
      • the list of CSS files
    • during execute it
      • reads the html template from a file and stores is as a string
      • creates an org.antlr.stringtemplate.StringTemplate from the html template
      • using the default org.antlr.stringtemplate.language.DefaultTemplateLexer.
      • loops through the JS and CS files from the configuration creating the <script> and <link> tags as strings
      • uses template.setAttribute to bind the built string to $cssIncludes$ and $jsIncludes$
      • writes the template to the files system

    It works quite nicely. I simply send a different list of JS and CSS files to the plugin based on the current Maven profile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using Maven for several months to build using Artifactory for the
I'm using Maven in the context of another build-tool (leiningen for Clojure, but this
We have our project build using maven. We try to run our unit test
I'm currently using Maven to build my Rhino JavaScript project, download dependent libraries, and
I have a web project. I build it using maven(complete all stages in every
I am trying to build a Java EE application using Maven. I have the
We have a headless selenium running as part of a maven build script using
I'm using the build-helper-maven-plugin to add it to my build, but I'd like to
Im using maven to build a multi module project. But some projects are in
I am using Maven as the build file , this is my below settings

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.