This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 308f39905b [MNG-8554] Fix UT suite for CLI (#2078)
308f39905b is described below

commit 308f39905bb72a00e2f4fe1ea23c32f2cec76309
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Sat Feb 1 12:38:34 2025 +0100

    [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
---
 impl/maven-cli/pom.xml                             |  2 +-
 .../cling/invoker/mvn/MavenInvokerTestSupport.java |  9 ---
 .../test/resources/mavenHome/conf/maven.properties | 67 ++++++++++++++++++++++
 3 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/impl/maven-cli/pom.xml b/impl/maven-cli/pom.xml
index 40fbac2ada..ecffd52480 100644
--- a/impl/maven-cli/pom.xml
+++ b/impl/maven-cli/pom.xml
@@ -169,7 +169,7 @@ under the License.
           </properties>
           
<promoteUserPropertiesToSystemProperties>false</promoteUserPropertiesToSystemProperties>
           <systemPropertyVariables>
-            <maven.home>${maven.home}</maven.home>
+            <maven.home>${basedir}/src/test/resources/mavenHome</maven.home>
           </systemPropertyVariables>
         </configuration>
       </plugin>
diff --git 
a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java
 
b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java
index 9e77d09db5..73bdc841ef 100644
--- 
a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java
+++ 
b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java
@@ -20,7 +20,6 @@
 
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -31,7 +30,6 @@
 import org.apache.maven.api.cli.Parser;
 import org.apache.maven.api.cli.ParserRequest;
 import org.apache.maven.jline.JLineMessageBuilderFactory;
-import org.junit.jupiter.api.Assumptions;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
@@ -88,13 +86,6 @@ protected void invoke(Path cwd, Path userHome, 
Collection<String> goals) throws
 
     protected Map<String, String> invoke(Path cwd, Path userHome, 
Collection<String> goals, Collection<String> args)
             throws Exception {
-        // works only in recent Maven4
-        Assumptions.assumeTrue(
-                Files.isRegularFile(Paths.get(System.getProperty("maven.home"))
-                        .resolve("conf")
-                        .resolve("maven.properties")),
-                "${maven.home}/conf/maven.properties must be a file");
-
         Files.createDirectories(cwd.resolve(".mvn"));
         Path pom = cwd.resolve("pom.xml").toAbsolutePath();
         Files.writeString(pom, POM_STRING);
diff --git a/impl/maven-cli/src/test/resources/mavenHome/conf/maven.properties 
b/impl/maven-cli/src/test/resources/mavenHome/conf/maven.properties
new file mode 100644
index 0000000000..1e53fa5df3
--- /dev/null
+++ b/impl/maven-cli/src/test/resources/mavenHome/conf/maven.properties
@@ -0,0 +1,67 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+#
+# Maven user properties
+#
+# The properties defined in this file will be made available through
+# user properties at the very beginning of Maven's boot process.
+#
+
+maven.installation.conf = ${maven.home}/conf
+maven.user.conf         = ${user.home}/.m2
+maven.project.conf      = ${session.rootDirectory}/.mvn
+
+# Comma-separated list of files to include.
+# Each item may be enclosed in quotes to gracefully include spaces. Items are 
trimmed before being loaded.
+# If the first character of an item is a question mark, the load will silently 
fail if the file does not exist.
+${includes} = ?"${maven.user.conf}/maven.properties", \
+              ?"${maven.project.conf}/maven.properties"
+
+#
+# Settings
+#
+# Define the default three levels for settings.
+# The '-is' flag will override the 'maven.installation.settings' property.
+# The '-ps' flag will override the 'maven.project.settings' property.
+# The '-s' flag will override the 'maven.user.settings' property.
+maven.installation.settings = ${maven.installation.conf}/settings.xml
+maven.project.settings      = ${maven.project.conf}/settings.xml
+maven.user.settings         = ${maven.user.conf}/settings.xml
+
+#
+# Toolchains
+#
+# Define the default three levels for toolchains.
+# The '-it' flag will override the 'maven.installation.toolchains' property.
+# The '-t' flag will override the 'maven.user.toolchains' property.
+maven.installation.toolchains = ${maven.installation.conf}/toolchains.xml
+maven.user.toolchains         = ${maven.user.conf}/toolchains.xml
+
+#
+# Extensions
+#
+maven.installation.extensions = ${maven.installation.conf}/extensions.xml
+maven.project.extensions      = ${maven.project.conf}/extensions.xml
+maven.user.extensions         = ${maven.user.conf}/extensions.xml
+
+#
+# Maven central repository URL.
+#
+maven.repo.central = 
${env.MAVEN_REPO_CENTRAL:-https://repo.maven.apache.org/maven2}

Reply via email to