覆盖Javascript文件Maven [英] Override Javascript file Maven

查看:93
本文介绍了覆盖Javascript文件Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven依赖关系支持自动生成HTML仪表板.我在 Maven Dependencies 的文件夹static中找到一个.js文件.现在,我想在那里自定义一个功能.我该如何像Java覆盖一样做到这一点?

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 do that like Java overriding?

推荐答案

取决于要定制js函数的数量. 最简单的情况是用已知属性替换标记.在这种情况下,您可以按照以下方式利用Maven.

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.

假设您有一个文本文件(例如src/main/resources/conf.properties,我只是为了简单起见使用属性文件,但是您可以将此情况改成JS)

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@

在pom中添加一个过滤器(过滤器是build标签的元素)

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>

现在您有两个选择. 1)将具有所需值的属性添加到POM中.

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)在您的mvn逗号中添加一个参数,

2) add a parameter to your mvn commad as

-Dspring.config.name="MY_CUSTOM_VALUE"

运行Maven,您的工件将包含更新为的文本文件

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.

致谢.

这篇关于覆盖Javascript文件Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆