Skip to content Skip to sidebar Skip to footer

Override Javascript File Maven

I'm using a Maven dependency support auto generate HTML dashboard. I found a .js file in folder static in Maven Dependencies. Now I want to customize one function there. How can I

Solution 1:

Depends how much you want to customize the js function. The simplest case is replacing a marker with a known property. In this caseyou can take advantage of maven as follow.

Let assume that you have a text file (say src/main/resources/conf.properties, I use a property file just for simplicity but you can trivially change this case to your JS) like this

spring.config.name = @spring.config.name@

adding in your pom a filter (filter is an element of the build tag)

<build><filters><filter>src/main/resources/app.properties</filter></filters><resources><resource><directory>src/main/resources</directory><filtering>true</filtering></resource></resources></build>

Now you have two options. 1) add a property into the POM with the value you want.

<properties><spring.config.name>MY_CUSTOM_VALUE</spring.config.name></properties>

2) add a parameter to your mvn commad as

-Dspring.config.name="MY_CUSTOM_VALUE"

Running maven, your artifact will contain the text file updated as

spring.config.name = MY_CUSTOM_VALUE

Obviously if your requirements are wider this solution may look limited for you.

Regards.

Post a Comment for "Override Javascript File Maven"