Skip to content

Commit 2627193

Browse files
authored
Merge pull request #372 from jmtd/OPENJDK-1549-maven-args-take-2
Openjdk 1549 maven args take 2
2 parents 7f4d2cc + 78e3bcf commit 2627193

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

modules/maven/default/artifacts/opt/jboss/container/maven/default/maven.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ function maven_build() {
7474
log_info "Using MAVEN_OPTS ${MAVEN_OPTS}"
7575
log_info "Using $(mvn $MAVEN_ARGS --version)"
7676
log_info "Running 'mvn $MAVEN_ARGS $goals'"
77-
# Execute the actual build
78-
mvn $MAVEN_ARGS $goals
77+
78+
# Execute the actual build (ensuring MAVEN_ARGS is unset, OPENJDK-1549)
79+
REAL_MAVEN_ARGS="$MAVEN_ARGS"
80+
unset MAVEN_ARGS
81+
mvn $REAL_MAVEN_ARGS $goals
7982

8083
popd &> /dev/null
8184

tests/OPENJDK-1549/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.

tests/OPENJDK-1549/pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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>

tests/features/java/java_s2i.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,8 @@ Feature: Openshift OpenJDK S2I tests
166166
| ns | http://maven.apache.org/SETTINGS/1.0.0 |
167167
Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:server[ns:id='myrepo']
168168
Then XML file /tmp/artifacts/configuration/settings.xml should have 1 elements on XPath //ns:profile[ns:id='myrepo-profile']/ns:repositories/ns:repository[ns:url='http://repo.example.com:8080/maven2/']
169+
170+
Scenario: Ensure the environment is cleaned when executing mvn (OPENJDK-1549)
171+
Given s2i build https://github.com/jmtd/openjdk from tests/OPENJDK-1549 with env using OPENJDK-1549-maven-args-take-2
172+
| variable | value |
173+
| MAVEN_ARGS | validate |

0 commit comments

Comments
 (0)