@@ -0,0 +1,2525 @@
+/*%0A * Bach - Java Shell Builder%0A * Copyright (C) 2020 Christian Stein%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     https://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage de.sormuras.bach.project;%0A%0Aimport de.sormuras.bach.internal.Modules;%0Aimport de.sormuras.bach.internal.Paths;%0Aimport java.lang.module.ModuleDescriptor;%0Aimport java.nio.file.Path;%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0A/**%0A * A module source connects a module compilation unit with source directories and resource paths.%0A *%0A * @see ModuleDescriptor%0A */%0Apublic final class ModuleSource %7B%0A%0A  public static ModuleSource of(Path path) %7B%0A    var info = Paths.isModuleInfoJavaFile(path) ? path : path.resolve(%22module-info.java%22);%0A    var moduleDescriptor = Modules.describe(info);%0A    var sourceDirectory = SourceDirectory.of(info.getParent());%0A    return new ModuleSource(moduleDescriptor, List.of(sourceDirectory), List.of());%0A  %7D%0A%0A  private final ModuleDescriptor module;%0A  private final List%3CSourceDirectory%3E sources;%0A  private final List%3CPath%3E resources;%0A%0A  public ModuleSource(%0A      ModuleDescriptor module, List%3CSourceDirectory%3E sources, List%3CPath%3E resources) %7B%0A    this.module = module;%0A    this.sources = List.copyOf(sources);%0A    this.resources = List.copyOf(resources);%0A  %7D%0A%0A  public ModuleDescriptor module() %7B%0A    return module;%0A  %7D%0A%0A  public List%3CSourceDirectory%3E sources() %7B%0A    return sources;%0A  %7D%0A%0A  public List%3CPath%3E resources() %7B%0A    return resources;%0A  %7D%0A%0A  public String name() %7B%0A    return module().name();%0A  %7D%0A%0A  public ModuleSource with(ModuleDescriptor module) %7B%0A    return new ModuleSource(module, sources, resources);%0A  %7D%0A%0A  public ModuleSource with(SourceDirectory additionalDirectory, SourceDirectory... more) %7B%0A    var list = new ArrayList%3C%3E(sources);%0A    list.add(additionalDirectory);%0A    if (more.length %3E 0) Collections.addAll(list, more);%0A    return new ModuleSource(module, list, resources);%0A  %7D%0A%0A  public ModuleSource with(List%3CPath%3E resources) %7B%0A    return new ModuleSource(module, sources, resources);%0A  %7D%0A%7D%0A

Introduce module source