File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Test for OPENJDK-1549
2
+
3
+ < https://issues.redhat.com/browse/OPENJDK-1549 >
4
+
5
+ This is a minimal Maven project for which the ` validate ` target will fail
6
+ if the environment variable ` MAVEN_ARGS ` is defined.
7
+
8
+ This is achieved using the Enforcer plugin. We could not use the
9
+ ` requireEnvironmentVariable ` built-in rule as it can only fail if a variable
10
+ is undefined, rather than if it is. Instead we use ` evaluateBeanshell ` and
11
+ a very short Beanshell expression.
12
+
13
+ Maven expands strings of the form ` ${env.foo} ` within the POM only if the
14
+ variable is defined. That is, when ` MAVEN_ARGS ` is not defined in the
15
+ environment, the string ` ${env.MAVEN_ARGS} ` is passed through unaltered.
16
+ If the variable is defined (including defined but empty), Maven will expand
17
+ it. Some string concatenation trickery is needed to match against the
18
+ un-expanded form.
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project >
3
+ <modelVersion >4.0.0</modelVersion >
4
+ <groupId >org.acme</groupId >
5
+ <artifactId >getting-started</artifactId >
6
+ <version >1.0.0-SNAPSHOT</version >
7
+ <build >
8
+ <plugins >
9
+ <plugin >
10
+ <groupId >org.apache.maven.plugins</groupId >
11
+ <artifactId >maven-enforcer-plugin</artifactId >
12
+ <version >3.3.0</version >
13
+ <executions >
14
+
15
+ <!-- ensure the environment variable MAVEN_ARGS is unset -->
16
+ <execution >
17
+ <id >enforce-beanshell</id >
18
+ <goals >
19
+ <goal >enforce</goal >
20
+ </goals >
21
+ <configuration >
22
+ <rules >
23
+ <evaluateBeanshell >
24
+ <condition >"${env.MAVEN_ARGS} ".equals("${env."+"MAVEN_ARGS} ")</condition >
25
+ </evaluateBeanshell >
26
+ </rules >
27
+ <fail >true</fail >
28
+ </configuration >
29
+ </execution >
30
+
31
+ </executions >
32
+ </plugin >
33
+ </plugins >
34
+ </build >
35
+ </project >
You can’t perform that action at this time.
0 commit comments