首页 > 解决方案 > 如何在 maven-resources-plugin 中生成 maven 属性并稍后使用它?

问题描述

在我的项目中,我想生成一个属性(本质上是用户名:密码字符串,base64 编码),然后在执行maven-resources-plugin时使用它。

该属性已正确生成并且在插件外部可见(我已经测试过了):

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>encode-user-pass-base64</id>
      <phase>initialize</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <exportAntProperties>true</exportAntProperties>
        <target>
          <script language="javascript">
            <![CDATA[
              ...<code here to generate base64data>...
              project.setProperty("MAVEN_NPM_AUTH", base64data);
            ]]>
          </script>
        </target>
      </configuration>
    </execution>
  </executions>
</plugin>

现在,执行maven-resources-plugin时出现问题:我的资源文件中的所有属性都被正确替换,除了 MAVEN_NPM_AUTH

知道为什么这个属性没有被替换吗?

标签: mavenmaven-antrun-pluginmaven-resources-plugin

解决方案


推荐阅读