【问题标题】:Exclude and include a file from a CRX Maven Plugin build从 CRX Maven 插件构建中排除和包含文件
【发布时间】:2012-12-20 17:59:05
【问题描述】:

在开发 Google Chrome 扩展程序时,我希望能够为环境构建不同的版本。

我正在使用The CRX Maven Plugin 来构建我的扩展。

默认情况下,我希望 src/main/chrome 下的文件成为我的开发文件,因为我使用 Chrome 的“加载解压扩展...”来进行本地测试。该扩展还进行远程调用,因此每个环境都有一个对应的远程服务器。我已将其外部化为 conf.js 文件。我正在考虑从 maven 构建中排除 src/main/chrome/conf.js 文件,并包含 /src/main/chrome 之外的另一个 conf.js,其配置如下:

...
<configuration>
...
    <packagingExcludes>js/conf.js</packagingExcludes>
...
</configuration>

我看不到临时构建目录,我可以在其中使用一些额外的脚本删除 conf.js。有什么建议吗?

【问题讨论】:

    标签: maven google-chrome-extension


    【解决方案1】:

    CRX Maven Plugin 现在支持文件过滤。

    您可以将环境特定设置的名称/值对放入名为 conf_XXX.properties 的 Java .properties 文件中,而不是为每个环境使用不同的 conf.js,其中 XXX 是您要用来识别的名称构建的目标环境。

    插件可以配置如下:

    <plugin>
        <groupId>com.btmatthews.maven.plugins</groupId>
        <artifactId>crx-maven-plugin</artifactId>
        <version>1.2.0</version>
        <configuration>
            ...
            <filtering>true</filtering>
            <filters>
                <filter>etc/conf_${targetEnv}.properties</filter>
            </filters>
            ...
       </configuration>
    

    您将使用 -D 选项在构建时设置目标环境。

    mvn -DtargetEnv=XXX
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-05
      • 2017-12-28
      • 2017-07-13
      • 2018-08-24
      • 1970-01-01
      • 2014-07-23
      • 2021-10-31
      相关资源
      最近更新 更多