此规则可以执行 beanshell 脚本并评估结果。
此规则支持以下参数:
示例插件配置:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>enforce-beanshell</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<evaluateBeanshell>
<condition>${project.artifactId} == foo</condition>
</evaluateBeanshell>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
条件可以是复杂的脚本或简单的表达式。只要结果为 True,规则就会成功。这意味着只要最后一行结果为真,就可以执行代码。
<evaluateBeanshell>
<condition>for (int i = 0;i!=10;i++){print ("Hello World "+i);};1==1</condition>
</evaluateBeanshell>