I would like to ensure the file size of resulting zip file is not larger than 400 MB so I've created this rule:
<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>
However, the mvn enforcer is by default bound to the validate
phase and unfortunately the file does not exist by this time. The zip file is generated by ant task that is bound to generate-resources
mvn phase.
Question
Is there any way to make the mvn enforcer to run after generate-resources
? Or to put it another way, how can I verify a build post-condition instead pre-condition?
omg, adding <phase>verify</phase>
worked for me:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With