/*
 * Bach - Java Shell Builder
 * Copyright (C) 2020 Christian Stein
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.sormuras.bach.tool;

import java.nio.file.Path;
import java.util.List;

/** A {@code javac} call configuration. */
public /*static*/ final class JavaCompiler extends Tool {

  JavaCompiler(List<? extends Option> options) {
    super("javac", options);
  }

  /** Sets the destination directory (or class output directory) for class files. */
  public static final class DestinationDirectory extends KeyValueOption<Path> {

    public DestinationDirectory(Path directory) {
      super("-d", directory);
    }
  }

  /** Compiles sources of the named modules that are newer than the corresponding class files. */
  public static final class CompileModulesCheckingTimestamps implements Option {
    private final List<String> modules;

    public CompileModulesCheckingTimestamps(List<String> modules) {
      this.modules = modules;
    }

    public List<String> modules() {
      return modules;
    }

    @Override
    public void visit(Arguments arguments) {
      arguments.add("--module", String.join(",", modules));
    }
  }
}

@@ -659,16 +659,75 @@
 .tool;%0A%0A
+import de.sormuras.bach.util.Strings;%0Aimport java.io.File;%0A
 import j
@@ -1224,17 +1224,496 @@
  Compile
-s
+ source code for the specified Java SE release. */%0A  public static final class CompileForJavaRelease extends KeyValueOption%3CInteger%3E %7B%0A%0A    public CompileForJavaRelease(Integer release) %7B%0A      super(%22--release%22, release);%0A    %7D%0A  %7D%0A%0A  /** Enable preview language features. */%0A  public static final class EnablePreviewLanguageFeatures implements Option %7B%0A%0A    @Override%0A    public void visit(Arguments arguments) %7B%0A      arguments.add(%22--enable-preview%22);%0A    %7D%0A  %7D%0A%0A  /** Compile
  sources
@@ -2208,11 +2208,1003 @@
    %7D%0A  %7D
+%0A%0A  /** Specify where to find input sources in a module-specific form. */%0A  public static final class ModuleSourcePathInModuleSpecificForm implements Option %7B%0A    private final String module;%0A    private final List%3CPath%3E paths;%0A%0A    public ModuleSourcePathInModuleSpecificForm(String module, List%3CPath%3E paths) %7B%0A      this.module = module;%0A      this.paths = paths;%0A    %7D%0A%0A    @Override%0A    public void visit(Arguments arguments) %7B%0A      arguments.add(%22--module-source-path%22, module + %22=%22 + Strings.toString(paths));%0A    %7D%0A  %7D%0A%0A  /** Specify where to find input sources in a module-pattern form. */%0A  public static final class ModuleSourcePathInModulePatternForm implements Option %7B%0A    private final List%3CString%3E patterns;%0A%0A    public ModuleSourcePathInModulePatternForm(List%3CString%3E patterns) %7B%0A      this.patterns = patterns;%0A    %7D%0A%0A    @Override%0A    public void visit(Arguments arguments) %7B%0A      arguments.add(%22--module-source-path%22, String.join(File.pathSeparator, patterns));%0A    %7D%0A  %7D
 %0A%7D%0A

Extend set of java compiler option types