Skip to content

Commit 308f399

Browse files
authored
[MNG-8554] Fix UT suite for CLI (#2078)
The whole UT suite was written to rely on maven.properties of the "outer build", hence UTs were not even running when built with Maven 3. Latest changes made it simply fail. Fix the UT suite, as BasePasrser is depending on maven.properties being loaded, so provide one in a fake maven.home. Now the UT is always running, irrelevant of Maven being built with. --- https://issues.apache.org/jira/browse/MNG-8554
1 parent b2b0bbe commit 308f399

File tree

3 files changed

+68
-10
lines changed

3 files changed

+68
-10
lines changed

impl/maven-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ under the License.
169169
</properties>
170170
<promoteUserPropertiesToSystemProperties>false</promoteUserPropertiesToSystemProperties>
171171
<systemPropertyVariables>
172-
<maven.home>${maven.home}</maven.home>
172+
<maven.home>${basedir}/src/test/resources/mavenHome</maven.home>
173173
</systemPropertyVariables>
174174
</configuration>
175175
</plugin>

impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.nio.file.Files;
2222
import java.nio.file.Path;
23-
import java.nio.file.Paths;
2423
import java.util.ArrayList;
2524
import java.util.Collection;
2625
import java.util.HashMap;
@@ -31,7 +30,6 @@
3130
import org.apache.maven.api.cli.Parser;
3231
import org.apache.maven.api.cli.ParserRequest;
3332
import org.apache.maven.jline.JLineMessageBuilderFactory;
34-
import org.junit.jupiter.api.Assumptions;
3533

3634
import static org.junit.jupiter.api.Assertions.assertEquals;
3735

@@ -88,13 +86,6 @@ protected void invoke(Path cwd, Path userHome, Collection<String> goals) throws
8886

8987
protected Map<String, String> invoke(Path cwd, Path userHome, Collection<String> goals, Collection<String> args)
9088
throws Exception {
91-
// works only in recent Maven4
92-
Assumptions.assumeTrue(
93-
Files.isRegularFile(Paths.get(System.getProperty("maven.home"))
94-
.resolve("conf")
95-
.resolve("maven.properties")),
96-
"${maven.home}/conf/maven.properties must be a file");
97-
9889
Files.createDirectories(cwd.resolve(".mvn"));
9990
Path pom = cwd.resolve("pom.xml").toAbsolutePath();
10091
Files.writeString(pom, POM_STRING);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
#
21+
# Maven user properties
22+
#
23+
# The properties defined in this file will be made available through
24+
# user properties at the very beginning of Maven's boot process.
25+
#
26+
27+
maven.installation.conf = ${maven.home}/conf
28+
maven.user.conf = ${user.home}/.m2
29+
maven.project.conf = ${session.rootDirectory}/.mvn
30+
31+
# Comma-separated list of files to include.
32+
# Each item may be enclosed in quotes to gracefully include spaces. Items are trimmed before being loaded.
33+
# If the first character of an item is a question mark, the load will silently fail if the file does not exist.
34+
${includes} = ?"${maven.user.conf}/maven.properties", \
35+
?"${maven.project.conf}/maven.properties"
36+
37+
#
38+
# Settings
39+
#
40+
# Define the default three levels for settings.
41+
# The '-is' flag will override the 'maven.installation.settings' property.
42+
# The '-ps' flag will override the 'maven.project.settings' property.
43+
# The '-s' flag will override the 'maven.user.settings' property.
44+
maven.installation.settings = ${maven.installation.conf}/settings.xml
45+
maven.project.settings = ${maven.project.conf}/settings.xml
46+
maven.user.settings = ${maven.user.conf}/settings.xml
47+
48+
#
49+
# Toolchains
50+
#
51+
# Define the default three levels for toolchains.
52+
# The '-it' flag will override the 'maven.installation.toolchains' property.
53+
# The '-t' flag will override the 'maven.user.toolchains' property.
54+
maven.installation.toolchains = ${maven.installation.conf}/toolchains.xml
55+
maven.user.toolchains = ${maven.user.conf}/toolchains.xml
56+
57+
#
58+
# Extensions
59+
#
60+
maven.installation.extensions = ${maven.installation.conf}/extensions.xml
61+
maven.project.extensions = ${maven.project.conf}/extensions.xml
62+
maven.user.extensions = ${maven.user.conf}/extensions.xml
63+
64+
#
65+
# Maven central repository URL.
66+
#
67+
maven.repo.central = ${env.MAVEN_REPO_CENTRAL:-https://repo.maven.apache.org/maven2}

0 commit comments

Comments
 (0)