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

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new eb22540  Simplify usage of toolchains
eb22540 is described below

commit eb22540be533eb505f5d94b30709a9a994ecaa5d
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Sun Mar 22 22:47:15 2026 +0100

    Simplify usage of toolchains
    
    - use ToolchainManager instead of ToolchainManagerPrivate
    - add ITs for toolchain
    - cleanup unused scripts in ITs
---
 src/it/selector-conditions/invoker.properties      | 18 +++++++++
 src/it/selector-conditions/pom.xml                 |  2 -
 .../postbuild.bsh => setup.groovy}                 | 32 ++++++++++++----
 .../src/it/jre-version-match/postbuild.bsh         | 26 -------------
 .../src/it/jre-version-mismatch/postbuild.bsh      | 26 -------------
 .../src/it/maven-version-match/postbuild.bsh       | 26 -------------
 .../src/it/os-family-match/postbuild.bsh           | 26 -------------
 .../src/it/os-family-mismatch/postbuild.bsh        | 26 -------------
 .../src/it/toolchain-match/invoker.properties      | 19 ++++++++++
 .../{ => src/it/toolchain-match}/pom.xml           | 43 ++--------------------
 .../src/it/toolchain-mismatch/postbuild.bsh        | 26 -------------
 src/it/selector-conditions/verify.groovy           |  4 +-
 .../maven/plugins/invoker/AbstractInvokerMojo.java | 23 +++++-------
 .../maven/plugins/invoker/IntegrationTestMojo.java |  4 +-
 .../apache/maven/plugins/invoker/InvokerMojo.java  |  6 +--
 .../maven/plugins/invoker/SelectorUtils.java       | 21 +----------
 .../maven/plugins/invoker/SelectorUtilsTest.java   | 35 +++---------------
 17 files changed, 89 insertions(+), 274 deletions(-)

diff --git a/src/it/selector-conditions/invoker.properties 
b/src/it/selector-conditions/invoker.properties
new file mode 100644
index 0000000..b69aebf
--- /dev/null
+++ b/src/it/selector-conditions/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals=initialize --toolchains toolchains.xml
diff --git a/src/it/selector-conditions/pom.xml 
b/src/it/selector-conditions/pom.xml
index c30863f..b0f3e02 100644
--- a/src/it/selector-conditions/pom.xml
+++ b/src/it/selector-conditions/pom.xml
@@ -40,8 +40,6 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@project.version@</version>
         <configuration>
-          <debug>true</debug>
-
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
           </pomIncludes>
diff --git 
a/src/it/selector-conditions/src/it/maven-version-mismatch/postbuild.bsh 
b/src/it/selector-conditions/setup.groovy
similarity index 50%
rename from 
src/it/selector-conditions/src/it/maven-version-mismatch/postbuild.bsh
rename to src/it/selector-conditions/setup.groovy
index d2e394e..8a71061 100644
--- a/src/it/selector-conditions/src/it/maven-version-mismatch/postbuild.bsh
+++ b/src/it/selector-conditions/setup.groovy
@@ -6,9 +6,9 @@
  * 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
@@ -17,10 +17,26 @@
  * under the License.
  */
 
-import java.io.*;
+def javaHome = System.getProperty('java.home')
+def javaVersion = System.getProperty('java.version')
+def toolchains = """
+<toolchains xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 
https://maven.apache.org/xsd/toolchains-1.1.0.xsd"; 
+    xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+  <toolchain>
+    <type>jdk</type>
+    <provides>
+      <vendor>myTestJdk</vendor>
+      <version>${javaVersion}</version>
+    </provides>
+    <configuration>
+      <jdkHome>${javaHome}</jdkHome>
+    </configuration>
+  </toolchain>
+</toolchains>
+"""
 
-// create touch file so that the parent build can verify whether this build 
was executed
-File touchFile = new File( basedir, "target/touch.txt" );
-System.out.println( "Creating touch file: " + touchFile );
-touchFile.getParentFile().mkdirs();
-touchFile.createNewFile();
+// generate toolchains.xml with the current JDK for the test of toolchain 
selector conditions
+new File(basedir, 'toolchains.xml').text = toolchains
+
+return true
diff --git a/src/it/selector-conditions/src/it/jre-version-match/postbuild.bsh 
b/src/it/selector-conditions/src/it/jre-version-match/postbuild.bsh
deleted file mode 100644
index d2e394e..0000000
--- a/src/it/selector-conditions/src/it/jre-version-match/postbuild.bsh
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.*;
-
-// create touch file so that the parent build can verify whether this build 
was executed
-File touchFile = new File( basedir, "target/touch.txt" );
-System.out.println( "Creating touch file: " + touchFile );
-touchFile.getParentFile().mkdirs();
-touchFile.createNewFile();
diff --git 
a/src/it/selector-conditions/src/it/jre-version-mismatch/postbuild.bsh 
b/src/it/selector-conditions/src/it/jre-version-mismatch/postbuild.bsh
deleted file mode 100644
index d2e394e..0000000
--- a/src/it/selector-conditions/src/it/jre-version-mismatch/postbuild.bsh
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.*;
-
-// create touch file so that the parent build can verify whether this build 
was executed
-File touchFile = new File( basedir, "target/touch.txt" );
-System.out.println( "Creating touch file: " + touchFile );
-touchFile.getParentFile().mkdirs();
-touchFile.createNewFile();
diff --git 
a/src/it/selector-conditions/src/it/maven-version-match/postbuild.bsh 
b/src/it/selector-conditions/src/it/maven-version-match/postbuild.bsh
deleted file mode 100644
index d2e394e..0000000
--- a/src/it/selector-conditions/src/it/maven-version-match/postbuild.bsh
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.*;
-
-// create touch file so that the parent build can verify whether this build 
was executed
-File touchFile = new File( basedir, "target/touch.txt" );
-System.out.println( "Creating touch file: " + touchFile );
-touchFile.getParentFile().mkdirs();
-touchFile.createNewFile();
diff --git a/src/it/selector-conditions/src/it/os-family-match/postbuild.bsh 
b/src/it/selector-conditions/src/it/os-family-match/postbuild.bsh
deleted file mode 100644
index d2e394e..0000000
--- a/src/it/selector-conditions/src/it/os-family-match/postbuild.bsh
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.*;
-
-// create touch file so that the parent build can verify whether this build 
was executed
-File touchFile = new File( basedir, "target/touch.txt" );
-System.out.println( "Creating touch file: " + touchFile );
-touchFile.getParentFile().mkdirs();
-touchFile.createNewFile();
diff --git a/src/it/selector-conditions/src/it/os-family-mismatch/postbuild.bsh 
b/src/it/selector-conditions/src/it/os-family-mismatch/postbuild.bsh
deleted file mode 100644
index d2e394e..0000000
--- a/src/it/selector-conditions/src/it/os-family-mismatch/postbuild.bsh
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.*;
-
-// create touch file so that the parent build can verify whether this build 
was executed
-File touchFile = new File( basedir, "target/touch.txt" );
-System.out.println( "Creating touch file: " + touchFile );
-touchFile.getParentFile().mkdirs();
-touchFile.createNewFile();
diff --git 
a/src/it/selector-conditions/src/it/toolchain-match/invoker.properties 
b/src/it/selector-conditions/src/it/toolchain-match/invoker.properties
new file mode 100644
index 0000000..ee8873e
--- /dev/null
+++ b/src/it/selector-conditions/src/it/toolchain-match/invoker.properties
@@ -0,0 +1,19 @@
+# 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.
+
+invoker.toolchain.jdk.vendor = myTestJdk
+invoker.toolchain.jdk.version = [0,)
diff --git a/src/it/selector-conditions/pom.xml 
b/src/it/selector-conditions/src/it/toolchain-match/pom.xml
similarity index 51%
copy from src/it/selector-conditions/pom.xml
copy to src/it/selector-conditions/src/it/toolchain-match/pom.xml
index c30863f..ea5c00f 100644
--- a/src/it/selector-conditions/pom.xml
+++ b/src/it/selector-conditions/src/it/toolchain-match/pom.xml
@@ -21,47 +21,12 @@ under the License.
 
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
   <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.maven.plugins.invoker</groupId>
-  <artifactId>selector-conditions</artifactId>
-  <version>1.0-SNAPSHOT</version>
-  <packaging>maven-plugin</packaging>
-
-  <description>Test to check for selection of builds based on OS and/or 
JRE.</description>
+  <groupId>test</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-invoker-plugin</artifactId>
-        <version>@project.version@</version>
-        <configuration>
-          <debug>true</debug>
-
-          <pomIncludes>
-            <pomInclude>*/pom.xml</pomInclude>
-          </pomIncludes>
-          <preBuildHookScript>prebuild</preBuildHookScript>
-          <postBuildHookScript>postbuild</postBuildHookScript>
-          <goals>
-            <goal>validate</goal>
-          </goals>
-        </configuration>
-        <executions>
-          <execution>
-            <id>integration-test</id>
-            <phase>initialize</phase>
-            <goals>
-              <goal>run</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>
diff --git a/src/it/selector-conditions/src/it/toolchain-mismatch/postbuild.bsh 
b/src/it/selector-conditions/src/it/toolchain-mismatch/postbuild.bsh
deleted file mode 100644
index d2e394e..0000000
--- a/src/it/selector-conditions/src/it/toolchain-mismatch/postbuild.bsh
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.*;
-
-// create touch file so that the parent build can verify whether this build 
was executed
-File touchFile = new File( basedir, "target/touch.txt" );
-System.out.println( "Creating touch file: " + touchFile );
-touchFile.getParentFile().mkdirs();
-touchFile.createNewFile();
diff --git a/src/it/selector-conditions/verify.groovy 
b/src/it/selector-conditions/verify.groovy
index 68eb51e..e4dd549 100644
--- a/src/it/selector-conditions/verify.groovy
+++ b/src/it/selector-conditions/verify.groovy
@@ -25,6 +25,7 @@ assert new File(basedir, 
'target/its/maven-version-match/build.log').exists()
 assert !(new File(basedir, 
'target/its/maven-version-mismatch/build.log').exists())
 assert new File(basedir, 'target/its/os-family-match/build.log').exists()
 assert !(new File(basedir, 'target/its/os-family-mismatch/build.log').exists())
+assert new File(basedir, 'target/its/toolchain-match/build.log').exists()
 assert !(new File(basedir, 'target/its/toolchain-mismatch/build.log').exists())
 
 def log = new File( basedir, 'build.log').text
@@ -35,4 +36,5 @@ assert log.contains("maven-version-match${FS}pom.xml 
...................... SUCC
 assert log.contains("maven-version-mismatch${FS}pom.xml ................... 
SKIPPED due to Maven version")
 assert log.contains("os-family-match${FS}pom.xml .......................... 
SUCCESS")
 assert log.contains("os-family-mismatch${FS}pom.xml ....................... 
SKIPPED due to OS")
-assert log.contains("toolchain-mismatch${FS}pom.xml ....................... 
SKIPPED due to Toolchain")
\ No newline at end of file
+assert log.contains("toolchain-match${FS}pom.xml .......................... 
SUCCESS")
+assert log.contains("toolchain-mismatch${FS}pom.xml ....................... 
SKIPPED due to Toolchain")
diff --git 
a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java 
b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
index f6a193b..1338e3e 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -80,9 +80,7 @@ import 
org.apache.maven.shared.scriptinterpreter.ScriptException;
 import org.apache.maven.shared.scriptinterpreter.ScriptReturnException;
 import org.apache.maven.shared.scriptinterpreter.ScriptRunner;
 import org.apache.maven.shared.utils.logging.MessageBuilder;
-import org.apache.maven.toolchain.MisconfiguredToolchainException;
-import org.apache.maven.toolchain.ToolchainManagerPrivate;
-import org.apache.maven.toolchain.ToolchainPrivate;
+import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.interpolation.InterpolationException;
 import org.codehaus.plexus.interpolation.Interpolator;
 import org.codehaus.plexus.interpolation.MapBasedValueSource;
@@ -762,18 +760,18 @@ public abstract class AbstractInvokerMojo extends 
AbstractMojo {
 
     private final SettingsBuilder settingsBuilder;
 
-    private final ToolchainManagerPrivate toolchainManagerPrivate;
+    private final ToolchainManager toolchainManager;
 
     private final InterpolatorUtils interpolatorUtils;
 
     public AbstractInvokerMojo(
             Invoker invoker,
             SettingsBuilder settingsBuilder,
-            ToolchainManagerPrivate toolchainManagerPrivate,
+            ToolchainManager toolchainManagerPrivate,
             InterpolatorUtils interpolatorUtils) {
         this.invoker = invoker;
         this.settingsBuilder = settingsBuilder;
-        this.toolchainManagerPrivate = toolchainManagerPrivate;
+        this.toolchainManager = toolchainManagerPrivate;
         this.interpolatorUtils = interpolatorUtils;
     }
 
@@ -1732,7 +1730,7 @@ public abstract class AbstractInvokerMojo extends 
AbstractMojo {
     }
 
     private ToolchainPrivateManager getToolchainPrivateManager() {
-        return new ToolchainPrivateManager(toolchainManagerPrivate, session);
+        return new ToolchainPrivateManager(toolchainManager, session);
     }
 
     /**
@@ -2426,17 +2424,16 @@ public abstract class AbstractInvokerMojo extends 
AbstractMojo {
     }
 
     static class ToolchainPrivateManager {
-        private ToolchainManagerPrivate manager;
+        private final ToolchainManager manager;
+        private final MavenSession session;
 
-        private MavenSession session;
-
-        ToolchainPrivateManager(ToolchainManagerPrivate manager, MavenSession 
session) {
+        ToolchainPrivateManager(ToolchainManager manager, MavenSession 
session) {
             this.manager = manager;
             this.session = session;
         }
 
-        ToolchainPrivate[] getToolchainPrivates(String type) throws 
MisconfiguredToolchainException {
-            return manager.getToolchainsForType(type, session);
+        boolean isToolchains(String type, Map<String, String> requirements) {
+            return !manager.getToolchains(session, type, 
requirements).isEmpty();
         }
     }
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/invoker/IntegrationTestMojo.java 
b/src/main/java/org/apache/maven/plugins/invoker/IntegrationTestMojo.java
index 58e3386..977c331 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/IntegrationTestMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/IntegrationTestMojo.java
@@ -26,7 +26,7 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.settings.building.SettingsBuilder;
 import org.apache.maven.shared.invoker.Invoker;
-import org.apache.maven.toolchain.ToolchainManagerPrivate;
+import org.apache.maven.toolchain.ToolchainManager;
 
 /**
  * Searches for integration test Maven projects, and executes each, collecting 
a log in the project directory, will
@@ -48,7 +48,7 @@ public class IntegrationTestMojo extends AbstractInvokerMojo {
     public IntegrationTestMojo(
             Invoker invoker,
             SettingsBuilder settingsBuilder,
-            ToolchainManagerPrivate toolchainManagerPrivate,
+            ToolchainManager toolchainManagerPrivate,
             InterpolatorUtils interpolatorUtils) {
         super(invoker, settingsBuilder, toolchainManagerPrivate, 
interpolatorUtils);
     }
diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerMojo.java 
b/src/main/java/org/apache/maven/plugins/invoker/InvokerMojo.java
index 1ff0de6..0a80e89 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/InvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerMojo.java
@@ -27,7 +27,7 @@ import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.settings.building.SettingsBuilder;
 import org.apache.maven.shared.invoker.Invoker;
-import org.apache.maven.toolchain.ToolchainManagerPrivate;
+import org.apache.maven.toolchain.ToolchainManager;
 
 /**
  * Searches for integration test Maven projects, and executes each, collecting 
a log in the project directory, and
@@ -75,9 +75,9 @@ public class InvokerMojo extends AbstractInvokerMojo {
     public InvokerMojo(
             Invoker invoker,
             SettingsBuilder settingsBuilder,
-            ToolchainManagerPrivate toolchainManagerPrivate,
+            ToolchainManager toolchainManager,
             InterpolatorUtils interpolaterUtils) {
-        super(invoker, settingsBuilder, toolchainManagerPrivate, 
interpolaterUtils);
+        super(invoker, settingsBuilder, toolchainManager, interpolaterUtils);
     }
 
     void processResults(InvokerSession invokerSession) throws 
MojoFailureException {
diff --git a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java 
b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java
index ded4fad..1f886d7 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java
@@ -35,8 +35,6 @@ import java.util.stream.Collectors;
 
 import 
org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.toolchain.MisconfiguredToolchainException;
-import org.apache.maven.toolchain.ToolchainPrivate;
 import org.codehaus.plexus.util.Os;
 
 /**
@@ -218,24 +216,7 @@ class SelectorUtils {
     static boolean isToolchain(
             ToolchainPrivateManager toolchainPrivateManager, 
Collection<InvokerToolchain> invokerToolchains) {
         for (InvokerToolchain invokerToolchain : invokerToolchains) {
-            boolean found = false;
-            try {
-                for (ToolchainPrivate tc : 
toolchainPrivateManager.getToolchainPrivates(invokerToolchain.getType())) {
-                    if (!invokerToolchain.getType().equals(tc.getType())) {
-                        // useful because of MNG-5716
-                        continue;
-                    }
-
-                    if 
(tc.matchesRequirements(invokerToolchain.getProvides())) {
-                        found = true;
-                        continue;
-                    }
-                }
-            } catch (MisconfiguredToolchainException e) {
-                return false;
-            }
-
-            if (!found) {
+            if 
(!toolchainPrivateManager.isToolchains(invokerToolchain.getType(), 
invokerToolchain.getProvides())) {
                 return false;
             }
         }
diff --git 
a/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java 
b/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java
index c2e6662..1c6f569 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java
@@ -25,12 +25,12 @@ import java.util.Collections;
 import java.util.List;
 
 import 
org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager;
-import org.apache.maven.toolchain.ToolchainPrivate;
 import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -101,43 +101,18 @@ class SelectorUtilsTest {
     }
 
     @Test
-    void isMatchingToolchain() throws Exception {
+    void isMatchingToolchain() {
         InvokerToolchain openJdk9 = new InvokerToolchain("jdk");
-        openJdk9.addProvides("version", "9");
-        openJdk9.addProvides("vendor", "openJDK");
-
-        InvokerToolchain maven360 = new InvokerToolchain("maven");
-        openJdk9.addProvides("version", "3.6.0");
 
         ToolchainPrivateManager toolchainPrivateManager = 
mock(ToolchainPrivateManager.class);
-        ToolchainPrivate jdkMatching = mock(ToolchainPrivate.class);
-        when(jdkMatching.matchesRequirements(anyMap())).thenReturn(true);
-        when(jdkMatching.getType()).thenReturn("jdk");
-
-        ToolchainPrivate jdkMismatch = mock(ToolchainPrivate.class);
-        when(jdkMismatch.getType()).thenReturn("jdk");
-
-        
when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new 
ToolchainPrivate[] {jdkMatching});
-        assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, 
Collections.singleton(openJdk9)))
-                .isTrue();
 
-        
when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new 
ToolchainPrivate[] {jdkMismatch});
-        assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, 
Collections.singleton(openJdk9)))
-                .isFalse();
-
-        when(toolchainPrivateManager.getToolchainPrivates("jdk"))
-                .thenReturn(new ToolchainPrivate[] {jdkMatching, jdkMismatch, 
jdkMatching});
+        when(toolchainPrivateManager.isToolchains(eq("jdk"), 
any())).thenReturn(true);
         assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, 
Collections.singleton(openJdk9)))
                 .isTrue();
 
-        
when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new 
ToolchainPrivate[0]);
+        when(toolchainPrivateManager.isToolchains(eq("jdk"), 
any())).thenReturn(false);
         assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, 
Collections.singleton(openJdk9)))
                 .isFalse();
-
-        
when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new 
ToolchainPrivate[] {jdkMatching});
-        
when(toolchainPrivateManager.getToolchainPrivates("maven")).thenReturn(new 
ToolchainPrivate[0]);
-        assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, 
Arrays.asList(openJdk9, maven360)))
-                .isFalse();
     }
 
     @Test

Reply via email to