我想知道在Maven中是否有办法计算MD5校验和和文件大小,将它们放入属性然后使用这些属性来过滤(文本替换)另一个文件中的参数。我正在尝试在运行之前为Advanced Installer生成一个配置文件。
答案 0 :(得分:2)
在花了一段时间谷歌搜索与Maven的方法,我决定考虑使用antrun插件。我搜索了这两个功能,并且两者的第一个链接解决了这个问题。看起来像antrun是编写Maven中大多数内容的好方法。
我的惊悚配置:
<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.