// Path: java-runtime-builder-app/src/main/java/com/google/cloud/runtimes/builder/util/StringLineAppender.java
// public class StringLineAppender {
// 
//   private List<String> lines;
// 
//   public StringLineAppender(String... initalLines) {
//     lines = new LinkedList<>();
//     Arrays.stream(initalLines).forEach(this::appendLine);
//   }
// 
//   public StringLineAppender() {
//     lines = new LinkedList<>();
//   }
// 
//   /**
//    * Appends a line to the internal buffer. Newline characters are not required.
//    */
//   public StringLineAppender appendLine(String line) {
//     lines.add(line);
//     return this;
//   }
// 
//   /**
//    * Appends an empty line to the internal buffer. Newline characters are not required.
//    */
//   public StringLineAppender appendLine() {
//     lines.add("");
//     return this;
//   }
// 
//   /**
//    * Prepends an empty line to the internal buffer. Newline characters are not required.
//    */
//   public StringLineAppender prependLine() {
//     lines.add(0, "");
//     return this;
//   }
// 
//   public List<String> getLines() {
//     return lines;
//   }
// 
//   public void setLines(List<String> lines) {
//     this.lines = lines;
//   }
// 
//   @Override
//   public String toString() {
//     StringBuilder builder = new StringBuilder();
//     for (String line : lines) {
//       builder.append(line + System.lineSeparator());
//     }
//     return builder.toString();
//   }
// 
// }


import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.WRITE;
import com.google.cloud.runtimes.builder.injection.DisableSourceBuild;
import com.google.cloud.runtimes.builder.util.StringLineAppender;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
/*
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * 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
 *
 *       http://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 com.google.cloud.runtimes.builder.config.domain;





/**
 * Encapsulates information about the build's state. Mediates interactions with the build directory
 * and stores build configuration.
 */
public class BuildContext {

  private static final String DOCKERFILE_NAME = "Dockerfile";
  private static final List<String> EXISITING_DOCKER_PATHS =
      ImmutableList.of(DOCKERFILE_NAME, "src/main/docker/" + DOCKERFILE_NAME);
  private static final String DOCKERIGNORE_NAME = ".dockerignore";

  private final Logger logger = LoggerFactory.getLogger(BuildContext.class);

  private final AppYaml appYaml;
  private final Path workspaceDir;
// Path: java-runtime-builder-app/src/main/java/com/google/cloud/runtimes/builder/util/StringLineAppender.java
// public class StringLineAppender {
// 
//   private List<String> lines;
// 
//   public StringLineAppender(String... initalLines) {
//     lines = new LinkedList<>();
//     Arrays.stream(initalLines).forEach(this::appendLine);
//   }
// 
//   public StringLineAppender() {
//     lines = new LinkedList<>();
//   }
// 
//   /**
//    * Appends a line to the internal buffer. Newline characters are not required.
//    */
//   public StringLineAppender appendLine(String line) {
//     lines.add(line);
//     return this;
//   }
// 
//   /**
//    * Appends an empty line to the internal buffer. Newline characters are not required.
//    */
//   public StringLineAppender appendLine() {
//     lines.add("");
//     return this;
//   }
// 
//   /**
//    * Prepends an empty line to the internal buffer. Newline characters are not required.
//    */
//   public StringLineAppender prependLine() {
//     lines.add(0, "");
//     return this;
//   }
// 
//   public List<String> getLines() {
//     return lines;
//   }
// 
//   public void setLines(List<String> lines) {
//     this.lines = lines;
//   }
// 
//   @Override
//   public String toString() {
//     StringBuilder builder = new StringBuilder();
//     for (String line : lines) {
//       builder.append(line + System.lineSeparator());
//     }
//     return builder.toString();
//   }
// 
// }


// Path: java-runtime-builder-app/src/main/java/com/google/cloud/runtimes/builder/config/domain/BuildContext.java
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.WRITE;
import com.google.cloud.runtimes.builder.injection.DisableSourceBuild;
import com.google.cloud.runtimes.builder.util.StringLineAppender;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

/*
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * 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
 *
 *       http://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 com.google.cloud.runtimes.builder.config.domain;





/**
 * Encapsulates information about the build's state. Mediates interactions with the build directory
 * and stores build configuration.
 */
public class BuildContext {

  private static final String DOCKERFILE_NAME = "Dockerfile";
  private static final List<String> EXISITING_DOCKER_PATHS =
      ImmutableList.of(DOCKERFILE_NAME, "src/main/docker/" + DOCKERFILE_NAME);
  private static final String DOCKERIGNORE_NAME = ".dockerignore";

  private final Logger logger = LoggerFactory.getLogger(BuildContext.class);

  private final AppYaml appYaml;
  private final Path workspaceDir;
  private final StringLineAppender dockerfile;