【发布时间】:2016-03-23 09:51:01
【问题描述】:
我想知道 Maven 中是否有办法计算文件的 MD5 校验和和大小,将它们放入属性中,然后使用这些属性过滤(文本替换)另一个文件中的参数。我正在尝试在运行 Advanced Installer 之前为其生成一个配置文件。
【问题讨论】:
标签: maven properties maven-plugin advanced-installer
我想知道 Maven 中是否有办法计算文件的 MD5 校验和和大小,将它们放入属性中,然后使用这些属性过滤(文本替换)另一个文件中的参数。我正在尝试在运行 Advanced Installer 之前为其生成一个配置文件。
【问题讨论】:
标签: maven properties maven-plugin advanced-installer
在谷歌上搜索了使用 Maven 的方法后,我决定研究使用 antrun 插件。我搜索了这两个功能,两者的第一个链接都解决了这个问题。似乎 antrun 是在 Maven 中编写大部分内容的好方法。
我的antrun配置:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<configuration>
<exportAntProperties>true</exportAntProperties>
</configuration>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="my_path" value="some path"/>
<length file="${my_path}" property="file.size"/>
<checksum file="${my_path}" property="file.md5"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
Maven 资源插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>file1</include>
<include>file2</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
这在命令行中效果很好,但由于某种原因,这些属性在 Intellij 中没有解析。 I've posted another question for that.
【讨论】: