Пример #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
    private DefaultPlexusContainer createContainer() throws Exception {
      ContainerConfiguration cc =
          new DefaultContainerConfiguration()
              .setClassWorld(config.getClassWorld())
              .setName("maven");

      DefaultPlexusContainer c = new DefaultPlexusContainer(cc);
      configureContainer(c);

      return c;
    }