Is there a way to fail if the flag "-N" (--non-recursive) isn't present? I'm trying to accomplish something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<rules>
<requireProperty>
<property>-N</property>
<message>Missing --non-recursive flag</message>
</requireProperty>
</rules>
</configuration>
</plugin>
This enforcement policy is in a profile. If there's a way to activate --non-recursive flag within a profile it would be ok.
You could write a custom enforcer rule that checks the MavenSession
and ensures that the reactor projects list contains one and only one project. That does not guarantee that you have been invoked with -N
but it is just as effective for what you want.
I've followed a simpler approach: evaluateBeanshell rule. Thanks to the Stephen Connolly answer, I've managed to find out where the "recursive" boolean was.
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>require non recursive flag</id>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<evaluateBeanshell>
<condition>false == ${session.request.recursive}</condition>
<message>Non-recursive flag is missing</message>
</evaluateBeanshell>
</rules>
</configuration>
</execution>
</executions>
</plugin>
I think it works in maven 3 only.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.