docs: private void runBuild(final ClassLoader coreLoader, Map<String, Object> definedProps) throws BuildException {
          final Project project = new Project();
          project.setCoreLoader(coreLoader);
  
          Throwable error = null;
  
          try {
              addBuildListeners(project);
              addInputHandler(project);
  
              final PrintStream savedErr = System.err;
              final PrintStream savedOut = System.out;
              final InputStream savedIn = System.in;
  
              // use a system manager that prevents from System.exit()
              final SecurityManager oldsm = System.getSecurityManager();
  
              // SecurityManager can not be installed here for backwards
              // compatibility reasons (PD). Needs to be loaded prior to
              // ant class if we are going to implement it.
              // System.setSecurityManager(new NoExitSecurityManager());
              try {
                  if (args.allowInput) {
                      project.setDefaultInputStream(System.in);
                  }
                  System.setIn(new DemuxInputStream(project));
                  System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
                  System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
  
                  project.fireBuildStarted();
  
                  // set the thread priorities
                  if (args.threadPriority != null) {
                      try {
                          project.log("Setting Ant's thread priority to " + args.threadPriority, Project.MSG_VERBOSE);
                          Thread.currentThread().setPriority(args.threadPriority);
                      } catch (final SecurityException swallowed) {
                          // we cannot set the priority here.
                          project.log("A security manager refused to set the -nice value");
                      }
                  }
  
                  project.init();
  
                  // resolve properties
                  final PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project);
                  final HashMap<String, Object> props = new HashMap<>(definedProps);
                  new ResolvePropertyMap(project, propertyHelper, propertyHelper.getExpanders()).resolveAllProperties(
                          props, null, false);
  
                  // set user-define properties
                  for (final Map.Entry<String, Object> ent : props.entrySet()) {
                      final String arg = ent.getKey();
                      final Object value = ent.getValue();
                      project.setUserProperty(arg, String.valueOf(value));
                  }
  
                  project.setUserProperty(MagicNames.ANT_FILE, buildFile.getAbsolutePath());
                  project.setUserProperty(MagicNames.ANT_FILE_TYPE, MagicNames.ANT_FILE_TYPE_FILE);
  
                  project.setKeepGoingMode(args.keepGoingMode);
                  if (args.proxy) {
                      // proxy setup if enabled
                      final ProxySetup proxySetup = new ProxySetup(project);
                      proxySetup.enableProxies();
                  }
  
                  ProjectHelper.configureProject(project, buildFile);
  
                  // make sure that we have a target to execute
                  if (targets.size() == 0) {
                      if (project.getDefaultTarget() != null) {
                          targets.addElement(project.getDefaultTarget());
                      }
                  }
  
                  project.executeTargets(targets);
              } finally {
                  // put back the original security manager
                  // The following will never eval to true. (PD)
                  if (oldsm != null) {
                      System.setSecurityManager(oldsm);
                  }
  
                  System.setOut(savedOut);
                  System.setErr(savedErr);
                  System.setIn(savedIn);
              }
          } catch (final RuntimeException | Error exc) {
              error = exc;
              throw exc;
          } finally {
              try {
                  project.fireBuildFinished(error);
              } catch (final Throwable t) {
                  // yes, I know it is bad style to catch Throwable,
                  // but if we don't, we lose valuable information
                  printErrorMessage("Caught an exception while logging the" + " end of the build.  Exception was:");
                  t.printStackTrace();
                  if (error != null) {
                      printErrorMessage("There has been an error prior to" + " that:");
                      error.printStackTrace();
                  }
                  throw new BuildException(t);
              }
          }
      }