Esempio n. 1
0
  @Override
  public boolean addModule(Module module) throws IOException {
    if (module.isDynamic()) {
      if (module.hasIniTemplate()) {
        // warn
        StartLog.warn("%-15s not adding [ini-template] from dynamic module", module.getName());
      }
      return false;
    }

    String mode = "";
    if (module.isTransitive()) {
      mode = "(transitively) ";
    }

    if (module.hasIniTemplate() || !module.isTransitive()) {
      // Create start.d/{name}.ini
      Path ini = startDir.resolve(module.getName() + ".ini");
      StartLog.info("%-15s initialised %sin %s", module.getName(), mode, baseHome.toShortForm(ini));

      try (BufferedWriter writer =
          Files.newBufferedWriter(
              ini,
              StandardCharsets.UTF_8,
              StandardOpenOption.CREATE,
              StandardOpenOption.TRUNCATE_EXISTING)) {
        writeModuleSection(writer, module);
      }
      return true;
    }

    return false;
  }