Пример #1
0
    private void init() throws Exception {
      log.debug("Initializing");

      // Make sure maven.home is absolute to avoid confusion on windows
      String mavenHome = System.getProperty(MAVEN_HOME);
      if (mavenHome != null) {
        System.setProperty(MAVEN_HOME, new File(mavenHome).getAbsolutePath());
      }

      // Setup defaults
      if (config.getClassWorld() == null) {
        config.setClassWorld(plexus.getClassWorld());
      }

      if (config.getBaseDirectory() == null) {
        config.setBaseDirectory(new File(System.getProperty("user.dir")));
      }

      StreamSet streams = config.getStreams();
      if (streams == null) {
        streams = StreamSet.system();
      }
      config.setStreams(streams);

      // Configure logging
      this.logger = config.getLogger();
      if (logger == null) {
        logger = new PrintStreamLogger(streams.out);
      } else {
        logger.setStream(streams.out);
      }
      config.setLogger(logger);

      int level = MavenExecutionRequest.LOGGING_LEVEL_INFO;
      if (config.isDebug()) {
        level = MavenExecutionRequest.LOGGING_LEVEL_DEBUG;
      } else if (config.isQuiet()) {
        level = MavenExecutionRequest.LOGGING_LEVEL_ERROR;
      }
      logger.setThreshold(level);

      File logFile = config.getLogFile();
      if (logFile != null) {
        logFile = resolveFile(logFile, config.getBaseDirectory());

        try {
          logStream = new PrintStream(logFile);
          logger.setStream(logStream);
        } catch (FileNotFoundException e) {
          log.warn("Failed to open logging stream for file: " + logFile, e);
          logger.setStream(streams.out);
        }
      }

      // Setup the container
      this.container = createContainer();
      log.debug("Using container: {}", container);
    }
Пример #2
0
    protected void configureContainer(final DefaultPlexusContainer c) throws Exception {
      assert c != null;

      c.setLoggerManager(new MavenLoggerManager(config.getLogger()));
      c.getLoggerManager().setThresholds(logger.getThreshold());

      // If there is a configuration delegate then call it
      if (config.getDelegate() != null) {
        config.getDelegate().configure(c);
      }
    }