You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "slachiewicz (via GitHub)" <gi...@apache.org> on 2026/09/21 10:46:17 UTC

[PR] Migrate core ITs from maven-verifier to maven-executor (3.10.x) [maven-integration-testing]

slachiewicz opened a new pull request, #446:
URL: https://github.com/apache/maven-integration-testing/pull/446

   Forward-port of #445 to maven-3.10.x: maven-verifier is deprecated (apache/maven-verifier#186); the Verifier used by the core ITs is now the in-repo `org.apache.maven.it.Verifier`, built on maven-executor, the same way apache/maven's own `core-it-support/maven-it-helper` does on master. Artifact and local-repository paths are computed locally rather than through a plugin execution, so running the suite does not require downloading a third-party plugin (apache/maven-executor#44).
   
   `core-it-support/maven-it-sample` and `maven-it-sample-archetype` still reference `maven-verifier` in their POMs; both are template/fixture projects outside the reactor, so they were left as-is.
   
   Full-suite verification against a real distribution is in progress; this description will be updated with the `Verified:` line once it completes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Migrate core ITs from maven-verifier to maven-executor (3.10.x) [maven-integration-testing]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #446:
URL: https://github.com/apache/maven-integration-testing/pull/446#discussion_r4160924144


##########
core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java:
##########
@@ -0,0 +1,1039 @@
+/*
+ * 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.
+ */
+package org.apache.maven.it;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.apache.maven.executor.ExecutorException;
+import org.apache.maven.executor.ExecutorHelper;
+import org.apache.maven.executor.ExecutorRequest;
+import org.apache.maven.executor.ExecutorResult;
+import org.apache.maven.executor.embedded.EmbeddedMavenExecutor;
+import org.apache.maven.executor.forked.ForkedMavenExecutor;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.io.FileUtils;
+
+/**
+ * Maven test harness for integration tests.
+ *
+ * <p>This is the in-repo successor of {@code org.apache.maven.shared.verifier.Verifier}
+ * (maven-verifier), which is deprecated (see
+ * <a href="https://github.com/apache/maven-verifier/issues/186">apache/maven-verifier#186</a>).
+ * It keeps the API surface the 3.x core ITs actually use, but drives Maven through
+ * {@code org.apache.maven.executor:maven-executor} instead of the bespoke launchers
+ * maven-verifier used, the same way {@code apache/maven}'s {@code core-it-support/maven-it-helper}
+ * does on master.</p>
+ *
+ * <p>Unlike the master copy, this class does not rely on a plugin execution to resolve local-repository
+ * or artifact/metadata paths: it computes them locally (default repository layout only), the way
+ * maven-verifier did it, so running the ITs does not require downloading a third-party plugin
+ * (see <a href="https://github.com/apache/maven-executor/issues/44">apache/maven-executor#44</a>).</p>
+ *
+ * @author Jason van Zyl
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class Verifier {
+    private static final String LOG_FILENAME = "log.txt";
+
+    private static final List<String> DEFAULT_CLI_ARGUMENTS = Collections.unmodifiableList(newDefaultCliArguments());
+
+    /**
+     * Command used to clean the project before execution. Neither test lifecycle binding nor prefix
+     * resolution here, the goal is called directly.
+     */
+    private static final String CLEAN_CLI_ARGUMENT = "org.apache.maven.plugins:maven-clean-plugin:clean";
+
+    /**
+     * The Maven home/installation directory we are testing/executing with, honoring the same
+     * {@code maven.home} system property the core-it-suite (and run-its.sh) has always set.
+     */
+    private static final java.nio.file.Path MAVEN_HOME = Paths.get(requireMavenHome());
+
+    /**
+     * Keep the executors alive as long as this class is loaded: the embedded executor keeps the
+     * classworld of the Maven under test alive instead of re-creating it per invocation, which
+     * makes embedded execution (the "embedded" profile) fast(er).
+     */
+    private static final EmbeddedMavenExecutor EMBEDDED_MAVEN_EXECUTOR = new EmbeddedMavenExecutor(MAVEN_HOME);
+
+    private static final ForkedMavenExecutor FORKED_MAVEN_EXECUTOR = new ForkedMavenExecutor(MAVEN_HOME);
+
+    /**
+     * The preferred fork mode. Honors the same {@code verifier.forkMode} system property the
+     * "embedded" profile has always set (to "auto"); absent that property (the default, non-embedded
+     * run) executions are forked, matching maven-verifier's historical default of forking whenever
+     * a real {@code maven.home} is configured.
+     *
+     * @see ExecutorHelper.Mode
+     */
+    private static final ExecutorHelper.Mode VERIFIER_FORK_MODE = resolveForkMode();
+
+    public static final String USER_HOME = System.getProperty("user.home");
+
+    public static final File USER_MAVEN_CONFIGURATION_HOME = new File(USER_HOME, ".m2");
+
+    private final ExecutorHelper executorHelper;
+
+    private final String basedir;
+
+    private String localRepoOverride;
+
+    private String resolvedLocalRepo;
+
+    private List<String> defaultCliArguments;
+
+    private List<String> cliArguments = new ArrayList<>();
+
+    private Properties systemProperties = new Properties();
+
+    private Map<String, String> environmentVariables = new HashMap<>();
+
+    private boolean autoclean = true;
+
+    private boolean forkJvm = false;
+
+    private String logFileName = LOG_FILENAME;
+
+    private String executable = ExecutorRequest.MVN;
+
+    public Verifier(String basedir) throws VerificationException {
+        this.basedir = basedir;
+        this.executorHelper =
+                ExecutorHelper.forExecutors(VERIFIER_FORK_MODE, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
+        this.defaultCliArguments = newDefaultCliArguments();
+    }
+
+    /**
+     * @deprecated the {@code debug} flag has not had any effect since maven-verifier 2.0; kept only
+     *             for source compatibility with call sites written against maven-verifier.
+     */
+    @Deprecated
+    public Verifier(String basedir, boolean debug) throws VerificationException {
+        this(basedir);
+    }

Review Comment:
   Why we add deprecated code in new class?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Migrate core ITs from maven-verifier to maven-executor (3.10.x) [maven-integration-testing]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #446:
URL: https://github.com/apache/maven-integration-testing/pull/446#issuecomment-5952199267

   Yes, this is maybe too early, but cool work!
   @slawekjaranowski when I started maven-executor standalone project, I immediately started with 1.x and 2.x branches, where 1.x was "just a drop in replacement" for Maven 4 build (to pull that module out of Maven 4+ build; reuse it instead), while 2.x branch was "create a full suite of m-invoker-p (and more) replacement". This is where I envisioned classes you mention and more, but it was voted down as "too complicated", so we went with 1.x only... 
   
   So IMO we need to empower maven-executor first, but this PR is very good work and can serve as example "what we need more in executor".
   
   Related:
   * https://github.com/apache/maven-executor/issues/1
   * https://github.com/apache/maven-executor/issues/19


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Migrate core ITs from maven-verifier to maven-executor (3.10.x) [maven-integration-testing]

Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on PR #446:
URL: https://github.com/apache/maven-integration-testing/pull/446#issuecomment-5999082722

   Fair point, and it is the plan in apache/maven-executor#49: T1 is a test-support module in maven-executor, and the in-repo copies (here, in apache/maven's `maven-it-helper` and in build-cache) go away once it exists. I'll move this PR to draft and use its `Verifier`/`ResourceExtractor` as the starting point for that module, aligned with the API of the `Verifier` on apache/maven master. When the module is released, this becomes a dependency change plus call sites.
   
   @cstamas agreed on "executor first"; apache/maven-executor#49 collects what this migration needed from it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Migrate core ITs from maven-verifier to maven-executor (3.10.x) [maven-integration-testing]

Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz closed pull request #446: Migrate core ITs from maven-verifier to maven-executor (3.10.x)
URL: https://github.com/apache/maven-integration-testing/pull/446


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Migrate core ITs from maven-verifier to maven-executor (3.10.x) [maven-integration-testing]

Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on code in PR #446:
URL: https://github.com/apache/maven-integration-testing/pull/446#discussion_r4186552461


##########
core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java:
##########
@@ -0,0 +1,1039 @@
+/*
+ * 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.
+ */
+package org.apache.maven.it;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.apache.maven.executor.ExecutorException;
+import org.apache.maven.executor.ExecutorHelper;
+import org.apache.maven.executor.ExecutorRequest;
+import org.apache.maven.executor.ExecutorResult;
+import org.apache.maven.executor.embedded.EmbeddedMavenExecutor;
+import org.apache.maven.executor.forked.ForkedMavenExecutor;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.io.FileUtils;
+
+/**
+ * Maven test harness for integration tests.
+ *
+ * <p>This is the in-repo successor of {@code org.apache.maven.shared.verifier.Verifier}
+ * (maven-verifier), which is deprecated (see
+ * <a href="https://github.com/apache/maven-verifier/issues/186">apache/maven-verifier#186</a>).
+ * It keeps the API surface the 3.x core ITs actually use, but drives Maven through
+ * {@code org.apache.maven.executor:maven-executor} instead of the bespoke launchers
+ * maven-verifier used, the same way {@code apache/maven}'s {@code core-it-support/maven-it-helper}
+ * does on master.</p>
+ *
+ * <p>Unlike the master copy, this class does not rely on a plugin execution to resolve local-repository
+ * or artifact/metadata paths: it computes them locally (default repository layout only), the way
+ * maven-verifier did it, so running the ITs does not require downloading a third-party plugin
+ * (see <a href="https://github.com/apache/maven-executor/issues/44">apache/maven-executor#44</a>).</p>
+ *
+ * @author Jason van Zyl
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class Verifier {
+    private static final String LOG_FILENAME = "log.txt";
+
+    private static final List<String> DEFAULT_CLI_ARGUMENTS = Collections.unmodifiableList(newDefaultCliArguments());
+
+    /**
+     * Command used to clean the project before execution. Neither test lifecycle binding nor prefix
+     * resolution here, the goal is called directly.
+     */
+    private static final String CLEAN_CLI_ARGUMENT = "org.apache.maven.plugins:maven-clean-plugin:clean";
+
+    /**
+     * The Maven home/installation directory we are testing/executing with, honoring the same
+     * {@code maven.home} system property the core-it-suite (and run-its.sh) has always set.
+     */
+    private static final java.nio.file.Path MAVEN_HOME = Paths.get(requireMavenHome());
+
+    /**
+     * Keep the executors alive as long as this class is loaded: the embedded executor keeps the
+     * classworld of the Maven under test alive instead of re-creating it per invocation, which
+     * makes embedded execution (the "embedded" profile) fast(er).
+     */
+    private static final EmbeddedMavenExecutor EMBEDDED_MAVEN_EXECUTOR = new EmbeddedMavenExecutor(MAVEN_HOME);
+
+    private static final ForkedMavenExecutor FORKED_MAVEN_EXECUTOR = new ForkedMavenExecutor(MAVEN_HOME);
+
+    /**
+     * The preferred fork mode. Honors the same {@code verifier.forkMode} system property the
+     * "embedded" profile has always set (to "auto"); absent that property (the default, non-embedded
+     * run) executions are forked, matching maven-verifier's historical default of forking whenever
+     * a real {@code maven.home} is configured.
+     *
+     * @see ExecutorHelper.Mode
+     */
+    private static final ExecutorHelper.Mode VERIFIER_FORK_MODE = resolveForkMode();
+
+    public static final String USER_HOME = System.getProperty("user.home");
+
+    public static final File USER_MAVEN_CONFIGURATION_HOME = new File(USER_HOME, ".m2");
+
+    private final ExecutorHelper executorHelper;
+
+    private final String basedir;
+
+    private String localRepoOverride;
+
+    private String resolvedLocalRepo;
+
+    private List<String> defaultCliArguments;
+
+    private List<String> cliArguments = new ArrayList<>();
+
+    private Properties systemProperties = new Properties();
+
+    private Map<String, String> environmentVariables = new HashMap<>();
+
+    private boolean autoclean = true;
+
+    private boolean forkJvm = false;
+
+    private String logFileName = LOG_FILENAME;
+
+    private String executable = ExecutorRequest.MVN;
+
+    public Verifier(String basedir) throws VerificationException {
+        this.basedir = basedir;
+        this.executorHelper =
+                ExecutorHelper.forExecutors(VERIFIER_FORK_MODE, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
+        this.defaultCliArguments = newDefaultCliArguments();
+    }
+
+    /**
+     * @deprecated the {@code debug} flag has not had any effect since maven-verifier 2.0; kept only
+     *             for source compatibility with call sites written against maven-verifier.
+     */
+    @Deprecated
+    public Verifier(String basedir, boolean debug) throws VerificationException {
+        this(basedir);
+    }

Review Comment:
   Agreed, it shouldn't be there. It only kept the old maven-verifier signatures compiling. I'll migrate the call sites and drop the deprecated members instead, here and in the shared module.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org