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:[email protected]";>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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to