public int run()

in src/main/java/org/apache/maven/shared/verifier/Embedded3xLauncher.java [164:201]


    public int run(String[] cliArgs, Properties systemProperties, String workingDirectory, File logFile)
            throws IOException, LauncherException {
        PrintStream out = (logFile != null) ? new PrintStream(Files.newOutputStream(logFile.toPath())) : System.out;
        try {
            File workingDirectoryPath = new File(workingDirectory);
            Properties originalProperties = System.getProperties();
            System.setProperties(null);
            System.setProperty("maven.home", originalProperties.getProperty("maven.home", ""));
            System.setProperty("user.dir", workingDirectoryPath.getAbsolutePath());
            System.setProperty(
                    "maven.multiModuleProjectDirectory",
                    findProjectBaseDirectory(workingDirectoryPath).getAbsolutePath());

            for (Object o : systemProperties.keySet()) {
                String key = (String) o;
                String value = systemProperties.getProperty(key);
                System.setProperty(key, value);
            }

            ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(mavenCli.getClass().getClassLoader());
            try {
                Object result = doMain.invoke(mavenCli, new Object[] {cliArgs, workingDirectory, out, out});

                return ((Number) result).intValue();
            } finally {
                Thread.currentThread().setContextClassLoader(originalClassLoader);

                System.setProperties(originalProperties);
            }
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new LauncherException("Failed to run Maven", e);
        } finally {
            if (logFile != null) {
                out.close();
            }
        }
    }