Repository: GoogleContainerTools/jib
File: jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java (Java)

Code before:
   * @param tarImage the {@link TarImage} that defines the path to the base image
   * @return a new {@link JavaContainerBuilder}
   */
  public static JavaContainerBuilder from(TarImage tarImage) {
    return new JavaContainerBuilder(Jib.from(tarImage));
  }

  private final JibContainerBuilder jibContainerBuilder;
  private final List<String> jvmFlags = new ArrayList<>();
  private final LinkedHashSet<LayerType> classpathOrder = new LinkedHashSet<>(4);

  // Keeps track of files to add to the image, by system path
  private final List<PathPredicatePair> addedResources = new ArrayList<>();
  private final List<PathPredicatePair> addedClasses = new ArrayList<>();
  private final List<Path> addedDependencies = new ArrayList<>();
  private final List<Path> addedSnapshotDependencies = new ArrayList<>();
  private final List<Path> addedProjectDependencies = new ArrayList<>();
  private final List<Path> addedOthers = new ArrayList<>();

  private AbsoluteUnixPath appRoot = AbsoluteUnixPath.get("/app");
  private RelativeUnixPath classesDestination = RelativeUnixPath.get("classes");
  private RelativeUnixPath resourcesDestination = RelativeUnixPath.get("resources");
  private RelativeUnixPath dependenciesDestination = RelativeUnixPath.get("libs");
  private RelativeUnixPath othersDestination = RelativeUnixPath.get("classpath");
  @Nullable private String mainClass;
  private static ModificationTimeProvider modificationTimeProvider =
      FileEntriesLayer.DEFAULT_MODIFICATION_TIME_PROVIDER;

  private JavaContainerBuilder(JibContainerBuilder jibContainerBuilder) {
    this.jibContainerBuilder = jibContainerBuilder;
  }

  /**
   * Sets the app root of the container image (useful for building WAR containers).
   *
   * @param appRoot the absolute path of the app on the container ({@code /app} by default)
   * @return this
   */
  public JavaContainerBuilder setAppRoot(String appRoot) {
    return setAppRoot(AbsoluteUnixPath.get(appRoot));
  }

  /**
   * Sets the app root of the container image (useful for building WAR containers).
   *
   * @param appRoot the absolute path of the app on the container ({@code /app} by default)
   * @return this
   */
  public JavaContainerBuilder setAppRoot(AbsoluteUnixPath appRoot) {
    this.appRoot = appRoot;
    return this;

Review comment (suggestion):
This should remain an instance variable (non-`static`), scoped and limited only to each individual instance. `static` means a global variable shared by every instance of `JavaContainerBuilder`.

Code after:
   * @param tarImage the {@link TarImage} that defines the path to the base image
   * @return a new {@link JavaContainerBuilder}
   */
  public static JavaContainerBuilder from(TarImage tarImage) {
    return new JavaContainerBuilder(Jib.from(tarImage));
  }

  private final JibContainerBuilder jibContainerBuilder;
  private final List<String> jvmFlags = new ArrayList<>();
  private final LinkedHashSet<LayerType> classpathOrder = new LinkedHashSet<>(4);

  // Keeps track of files to add to the image, by system path
  private final List<PathPredicatePair> addedResources = new ArrayList<>();
  private final List<PathPredicatePair> addedClasses = new ArrayList<>();
  private final List<Path> addedDependencies = new ArrayList<>();
  private final List<Path> addedSnapshotDependencies = new ArrayList<>();
  private final List<Path> addedProjectDependencies = new ArrayList<>();
  private final List<Path> addedOthers = new ArrayList<>();

  private AbsoluteUnixPath appRoot = AbsoluteUnixPath.get("/app");
  private RelativeUnixPath classesDestination = RelativeUnixPath.get("classes");
  private RelativeUnixPath resourcesDestination = RelativeUnixPath.get("resources");
  private RelativeUnixPath dependenciesDestination = RelativeUnixPath.get("libs");
  private RelativeUnixPath othersDestination = RelativeUnixPath.get("classpath");
  @Nullable private String mainClass;
  private ModificationTimeProvider modificationTimeProvider =
      FileEntriesLayer.DEFAULT_MODIFICATION_TIME_PROVIDER;

  private JavaContainerBuilder(JibContainerBuilder jibContainerBuilder) {
    this.jibContainerBuilder = jibContainerBuilder;
  }

  /**
   * Sets the app root of the container image (useful for building WAR containers).
   *
   * @param appRoot the absolute path of the app on the container ({@code /app} by default)
   * @return this
   */
  public JavaContainerBuilder setAppRoot(String appRoot) {
    return setAppRoot(AbsoluteUnixPath.get(appRoot));
  }

  /**
   * Sets the app root of the container image (useful for building WAR containers).
   *
   * @param appRoot the absolute path of the app on the container ({@code /app} by default)
   * @return this
   */
  public JavaContainerBuilder setAppRoot(AbsoluteUnixPath appRoot) {
    this.appRoot = appRoot;
    return this;