/*
 * 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 build;

import de.sormuras.bach.Bach;
import de.sormuras.bach.project.Base;
import de.sormuras.bach.project.JavaRelease;
import de.sormuras.bach.project.MainSources;
import de.sormuras.bach.project.ModuleSource;
import de.sormuras.bach.project.Project;
import de.sormuras.bach.tool.Jar;
import de.sormuras.bach.tool.Javac;
import java.nio.file.Path;

/** Bach's own build program. */
class Build {

  public static void main(String... args) {
    var base = Base.of();
    var version = Bach.VERSION;
    var release = 11;
    var project =
        Project.of("bach", version.toString())
            .with(base)
            .with(JavaRelease.of(release))
            // .title("\uD83C\uDFBC Bach.java")
            // .requires("org.junit.platform.console")
            .with(
                MainSources.of()
                    .with(
                        Javac.of()
                            .with("-d", base.classes("", release))
                            .with("--module", "de.sormuras.bach")
                            .with("--module-source-path", "src/*/main/java")
                            .with("--module-version", version)
                            .withCompileForJavaRelease(release)
                            .with("-encoding", "UTF-8")
                            .withRecommendedWarnings()
                            .withWarnings("all", "-preview")
                            .withTerminateCompilationIfWarningsOccur())
                    .with(
                        ModuleSource.of(Path.of("src/de.sormuras.bach/main/java"))
                            .with(
                                Jar.of(
                                        base.modules("")
                                            .resolve("de.sormuras.bach@" + version + ".jar"))
                                    .with("--verbose")
                                    .with("--main-class", "de.sormuras.bach.Main")
                                    .withChangeDirectoryAndIncludeFiles(
                                        base.classes("", release, "de.sormuras.bach"), "."))));

    Bach.of(project).build();
  }
}

@@ -958,16 +958,54 @@
 .Javac;%0A
+import de.sormuras.bach.tool.Javadoc;%0A
 import j
@@ -1023,16 +1023,16 @@
 e.Path;%0A
-
 %0A/** Bac
@@ -1348,13 +1348,29 @@
 // .
-title
+with(Documentation.of
 (%22%5Cu
@@ -1387,24 +1387,25 @@
  Bach.java%22)
+)
 %0A           
@@ -2071,16 +2071,16 @@
 eview%22)%0A
-
         
@@ -2162,32 +2162,638 @@
          .with(%0A
+                        Javadoc.of()%0A                            .with(%22-d%22, base.workspace(%22documentation%22, %22api%22))%0A                            .with(%22--module%22, %22de.sormuras.bach%22)%0A                            .with(%22--module-source-path%22, %22src/*/main/java%22)%0A                            .with(%22-encoding%22, %22UTF-8%22)%0A                            .with(%22-locale%22, %22en%22)%0A                            .with(%22-Xdoclint%22)%0A                            .with(%22--show-module-contents%22, %22all%22)%0A                            .with(%22-link%22, %22https://docs.oracle.com/en/java/javase/11/docs/api%22))%0A                    .with(%0A
                 

Update build program