/*
 * sbt
 * Copyright 2023, Scala center
 * Copyright 2011 - 2022, Lightbend, Inc.
 * Copyright 2008 - 2010, Mark Harrah
 * Licensed under Apache License 2.0 (see LICENSE)
 */

package sbt

import java.io.File

final case class Exit(code: Int) extends xsbti.Exit {
  require(code >= 0)
}
final case class Reboot(
    scalaVersion: String,
    argsList: Seq[String],
    app: xsbti.ApplicationID,
    baseDirectory: File
) extends xsbti.Reboot {
  def arguments = argsList.toArray
}

final case class ApplicationID(
    groupID: String,
    name: String,
    version: String,
    mainClass: String,
    components: Seq[String],
    crossVersionedValue: xsbti.CrossValue,
    extra: Seq[File]
) extends xsbti.ApplicationID {
  def mainComponents = components.toArray
  def classpathExtra = extra.toArray
  def crossVersioned = crossVersionedValue != xsbti.CrossValue.Disabled
}
object ApplicationID {
  def apply(delegate: xsbti.ApplicationID, newVersion: String): ApplicationID =
    apply(delegate).copy(version = newVersion)
  def apply(delegate: xsbti.ApplicationID): ApplicationID =
    ApplicationID(
      delegate.groupID,
      delegate.name,
      delegate.version,
      delegate.mainClass,
      delegate.mainComponents.toSeq,
      delegate.crossVersionedValue,
      delegate.classpathExtra.toSeq
    )
}
