/*
 * 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.MainSources;
import de.sormuras.bach.project.ModuleSource;
import de.sormuras.bach.project.Project;
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 release = 11;
    var project =
        Project.of("bach", Bach.VERSION.toString())
            .with(base)
            // .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")
                            .withCompileForJavaRelease(release)
                            .withRecommendedWarnings()
                            .withWarnings("all", "-preview")
                            .withTerminateCompilationIfWarningsOccur()
                            .with("--module-version", Bach.VERSION)
                            .with("-encoding", "UTF-8"))
                    .with(ModuleSource.of(Path.of("src/de.sormuras.bach/main/java"))));

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

@@ -711,16 +711,61 @@
 t.Base;%0A
+import de.sormuras.bach.project.JavaRelease;%0A
 import d
@@ -801,16 +801,16 @@
 ources;%0A
-
 import d
@@ -888,16 +888,50 @@
 roject;%0A
+import de.sormuras.bach.tool.Jar;%0A
 import d
@@ -1216,24 +1216,67 @@
 .with(base)%0A
+            .with(JavaRelease.of(release))%0A
             
@@ -2092,16 +2092,41 @@
   .with(
+%0A                        
 ModuleSo
@@ -2175,16 +2175,468 @@
 /java%22))
+%0A                            .with(%0A                                Jar.of(%0A                                        base.modules(%22%22)%0A                                            .resolve(%22de.sormuras.bach@%22 + Bach.VERSION + %22.jar%22))%0A                                    .with(%22--verbose%22)%0A                                    .withChangeDirectoryAndIncludeFiles(%0A                                        base.classes(%22%22, release, %22de.sormuras.bach%22), %22.%22))
 ));%0A%0A   

Update build program