Maven 在属性中存储文件和文件大小的 MD5 校验和,然后过滤另一个文件

Maven store MD5 checksum of file and file size in properties then filter another file

我想知道 Maven 中是否有一种方法可以计算文件的 MD5 校验和和大小,将它们放入属性中,然后使用这些属性过滤(文本替换)另一个文件中的参数。在我 运行 它之前,我试图为高级安装程序生成一个配置文件。

在谷歌上搜索了一段时间使用 Maven 的方法后,我决定研究使用 antrun 插件。我用谷歌搜索了这两个功能,第一个 link 解决了问题。似乎 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 中未解析。