我想确保生成的zip文件的文件大小不大于400 MB,所以我创建了以下规则:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-file-size</id>
<goals>
<goal>enforce-once</goal>
</goals>
<configuration>
<rules>
<requireFilesSize>
<maxsize>419430400</maxsize> <!-- the final zip should not exceed 400 MB -->
<files>
<file>${project.build.outputDirectory}.zip</file>
</files>
</requireFilesSize>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
但是,mvn强制程序默认情况下绑定(bind)到
validate
阶段,不幸的是,该文件此时不存在。该zip文件是由与generate-resources
mvn阶段绑定(bind)的ant任务生成的。问题
有什么方法可以使mvn强制程序在
generate-resources
之后运行?或换一种说法,我该如何验证生成后置条件而不是前置条件? 最佳答案
天哪,添加<phase>verify</phase>
对我有用:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-file-size</id>
<phase>verify</phase>
<goals>
<goal>enforce-once</goal>
</goals>
<configuration>
<rules>
<requireFilesSize>
<maxsize>419430400</maxsize> <!-- the final zip should not exceed 400 MB -->
<files>
<file>${project.build.outputDirectory}.zip</file>
</files>
</requireFilesSize>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
关于maven - 如何使Maven强制执行器插件在指定阶段运行?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19162509/