/* sbt -- Simple Build Tool
 * Copyright 2008, 2009  Mark Harrah
 */
package sbt

import java.io.File
import FileUtilities._

object object sbt.ResourcesResources
{
	def (String)sbt.Resourcesapply(StringbasePath: StringString) =
	{
		(Boolean)Unitrequire(StringbasePath.(java.lang.String)BooleanstartsWith(java.lang.String("/")"/"))
		val java.net.URLresource = ()java.lang.Class[_ <: java.lang.Object]getClass.(java.lang.String)java.net.URLgetResource(StringbasePath)
		sbt.Resourcesif(java.net.URLresource (AnyRef)Boolean== Null(null)null)
			Nothingthrow (java.lang.String)java.lang.Exceptionnew java.lang.ExceptionException(java.lang.String("Resource base directory '")"Resource base directory '" (Any)java.lang.String+ StringbasePath (Any)java.lang.String+ java.lang.String("' not on classpath.")"' not on classpath.")
		else
		{
			val java.io.Filefile = (java.net.URI)java.io.Filenew java.io.FileFile(java.net.URLresource.()java.net.URItoURI)
			sbt.Resourcesif(java.io.Filefile.()Booleanexists)
				sbt.Resourcesnew sbt.ResourcesResources(java.io.Filefile)
			else
				Nothingthrow (java.lang.String)java.lang.Exceptionnew java.lang.ExceptionException(java.lang.String("Resource base directory '")"Resource base directory '" (Any)java.lang.String+ StringbasePath (Any)java.lang.String+ java.lang.String("' does not exist.")"' does not exist.")
		}
	}
	private val java.lang.StringLoadErrorPrefix = java.lang.String("Error loading initial project: ")"Error loading initial project: "
}

class class Resources extends java.lang.Object with ScalaObjectResources(val java.io.FilebaseDirectory: java.io.FileFile)
{
	import Resources._
	// The returned directory is not actually read-only, but it should be treated that way
	def (String,String)Either[String,java.io.File]readOnlyResourceDirectory(Stringgroup: StringString, Stringname: StringString): Either[String,java.io.File]Either[String, File] =
	{
		val java.io.FilegroupDirectory = (java.io.File,java.lang.String)java.io.Filenew java.io.FileFile(=> java.io.FilebaseDirectory, Stringgroup)
		Either[String,java.io.File]if(java.io.FilegroupDirectory.()BooleanisDirectory)
		{
			val java.io.FileresourceDirectory = (java.io.File,java.lang.String)java.io.Filenew java.io.FileFile(java.io.FilegroupDirectory, Stringname)
			Either[String,java.io.File]if(java.io.FileresourceDirectory.()BooleanisDirectory)
				(java.io.File)Right[Nothing,java.io.File]Right(java.io.FileresourceDirectory)
			else
				(java.lang.String)Left[java.lang.String,Nothing]Left(java.lang.String("Resource directory '")"Resource directory '" (Any)java.lang.String+ Stringname (Any)java.lang.String+ java.lang.String("' in group '")"' in group '" (Any)java.lang.String+ Stringgroup (Any)java.lang.String+ java.lang.String("' not found.")"' not found.")
		}
		else
			(java.lang.String)Left[java.lang.String,Nothing]Left(java.lang.String("Group '")"Group '" (Any)java.lang.String+ Stringgroup (Any)java.lang.String+ java.lang.String("' not found.")"' not found.")
	}
	def [T](String,String,sbt.Logger)((java.io.File) => Either[String,T])Either[String,T]readWriteResourceDirectory[>: Nothing <: AnyT](Stringgroup: StringString, Stringname: StringString, sbt.Loggerlog: sbt.LoggerLogger)
		((java.io.File) => Either[String,T]withDirectory: File => Either[String, T]): Either[String,T]Either[String, T] =
			(String,String)Either[String,java.io.File]readOnlyResourceDirectory(Stringgroup, Stringname).=> Either.RightProjection[String,java.io.File]right ((java.io.File) => Either[String,T])Either[String,T]flatMap(java.io.Filefile => (java.io.File,sbt.Logger)((java.io.File) => Either[String,T])Either[String,T]readWriteResourceDirectory(java.io.Filefile, sbt.Loggerlog)((java.io.File) => Either[String,T]withDirectory))
	def [T](java.io.File,sbt.Logger)((java.io.File) => Either[String,T])Either[String,T]readWriteResourceDirectory[>: Nothing <: AnyT](java.io.FilereadOnly: java.io.FileFile, sbt.Loggerlog: sbt.LoggerLogger)
		((java.io.File) => Either[String,T]withDirectory: File => Either[String, T]): Either[String,T]Either[String, T] =
	{
		(Boolean)Unitrequire(java.io.FilereadOnly.()BooleanisDirectory)
		def (java.io.File)(java.io.File)Either[String,T]readWrite(java.io.FilereadOnly: java.io.FileFile)(java.io.Filetemporary: java.io.FileFile): Either[String,T]Either[String, T] =
		{
			val java.io.FilereadWriteDirectory = (java.io.File,java.lang.String)java.io.Filenew java.io.FileFile(java.io.Filetemporary, java.io.FilereadOnly.()java.lang.StringgetName)
			object sbt.FileUtilitiesFileUtilities.(java.io.File,java.io.File,sbt.Logger)Option[String]copyDirectory(java.io.FilereadOnly, java.io.FilereadWriteDirectory, sbt.Loggerlog).(=> Unit)Either[String,Unit] with ProducttoLeft(Unit()).=> Either.RightProjection[String,Unit]right ((Unit) => Either[String,T])Either[String,T]flatMap { Unitx =>
				(java.io.File)Either[String,T]withDirectory(java.io.FilereadWriteDirectory)
			}
		}
		(sbt.Logger)((java.io.File) => Either[String,T])Either[String,T]doInTemporaryDirectory(sbt.Loggerlog)((java.io.File)(java.io.File)Either[String,T]readWrite(java.io.FilereadOnly))
	}
	
	def [T](java.io.File,sbt.Logger)((sbt.Project) => sbt.WithProjectResult[T])Either[String,T]withProject[>: Nothing <: AnyT](java.io.FileprojectDirectory: java.io.FileFile, sbt.Loggerlog: sbt.LoggerLogger)((sbt.Project) => sbt.WithProjectResult[T]f: Project => WithProjectResult[T]): Either[String,T]Either[String, T] =
		(java.io.File,sbt.Logger)((java.io.File) => Either[String,T])Either[String,T]readWriteResourceDirectory(java.io.FileprojectDirectory, sbt.Loggerlog)((sbt.Logger)((sbt.Project) => sbt.WithProjectResult[T])(java.io.File)Either[String,T]withProject(sbt.Loggerlog)((sbt.Project) => sbt.WithProjectResult[T]f))
	def [T](String,String,sbt.Logger)((sbt.Project) => sbt.WithProjectResult[T])Either[String,T]withProject[>: Nothing <: AnyT](Stringgroup: StringString, Stringname: StringString, sbt.Loggerlog: sbt.LoggerLogger)((sbt.Project) => sbt.WithProjectResult[T]f: Project => WithProjectResult[T]): Either[String,T]Either[String, T] =
		(String,String,sbt.Logger)((java.io.File) => Either[String,T])Either[String,T]readWriteResourceDirectory(Stringgroup, Stringname, sbt.Loggerlog)((sbt.Logger)((sbt.Project) => sbt.WithProjectResult[T])(java.io.File)Either[String,T]withProject(sbt.Loggerlog)((sbt.Project) => sbt.WithProjectResult[T]f))
	def [T](sbt.Logger)((sbt.Project) => sbt.WithProjectResult[T])(java.io.File)Either[String,T]withProject[>: Nothing <: AnyT](sbt.Loggerlog: sbt.LoggerLogger)((sbt.Project) => sbt.WithProjectResult[T]f: Project => WithProjectResult[T])(java.io.Filedir: java.io.FileFile): Either[String,T]Either[String, T] =
		(sbt.Logger,Option[sbt.Project],sbt.ReloadProject,java.io.File)((sbt.Project) => sbt.WithProjectResult[T])Either[String,T]withProject(sbt.Loggerlog, object NoneNone, sbt.ReloadSuccessExpectednew sbt.ReloadSuccessExpectedReloadSuccessExpected(=> java.lang.StringLoadErrorPrefix), java.io.Filedir )((sbt.Project) => sbt.WithProjectResult[T]f)
	private def [T](sbt.Logger,Option[sbt.Project],sbt.ReloadProject,java.io.File)((sbt.Project) => sbt.WithProjectResult[T])Either[String,T]withProject[>: Nothing <: AnyT](sbt.Loggerlog: sbt.LoggerLogger, Option[sbt.Project]previousProject: Option[sbt.Project]Option[Project], sbt.ReloadProjectreload: sbt.ReloadProjectReloadProject, java.io.Filedir: java.io.FileFile)
		((sbt.Project) => sbt.WithProjectResult[T]f: Project => WithProjectResult[T]): Either[String,T]Either[String, T] =
	{
		(Boolean,=> Any)Unitrequire(Option[sbt.Project]previousProject.=> BooleanisDefined (Boolean)Boolean|| sbt.ReloadProjectreload (AnyRef)Boolean!= object sbt.NoReloadNoReload, java.lang.String("Previous project undefined and reload not requested.")"Previous project undefined and reload not requested.")
		val <refinement> extends Either[java.lang.String,sbt.Project] with ProductloadResult =
			<refinement> extends Either[java.lang.String,sbt.Project] with Productif(sbt.ReloadProjectreload (AnyRef)Boolean== object sbt.NoReloadNoReload (Boolean)Boolean&& Option[sbt.Project]previousProject.=> BooleanisDefined)
				(sbt.Project)Right[Nothing,sbt.Project]Right(Option[sbt.Project]previousProject.=> sbt.Projectget)
			else
			{
				val sbt.BufferedLoggerbuffered = sbt.BufferedLoggernew sbt.BufferedLoggerBufferedLogger(sbt.Loggerlog)
				def (String)Left[String,Nothing]error(Stringmsg: StringString) =
				{
					sbt.BufferedLoggerbuffered.()UnitplayAll()
					sbt.BufferedLoggerbuffered.()Unitstop()
					(String)Left[String,Nothing]Left(Stringmsg)
				}
				
				sbt.BufferedLoggerbuffered.()UnitstartRecording()
				(sbt.LoadResult)Either[String,sbt.Project]resultToEither(object sbt.ProjectProject.(java.io.File,Iterable[sbt.Project],Option[sbt.Project],sbt.Logger)sbt.LoadResultloadProject(java.io.Filedir, object NilNil, object NoneNone, sbt.BufferedLoggerbuffered)) <refinement> extends Either[java.lang.String,sbt.Project] with Productmatch
				{
					<refinement> extends Either[java.lang.String,sbt.Project] with Productcase Left(Stringmsg) =>
						sbt.ReloadProjectreload <refinement> extends Either[java.lang.String,sbt.Project] with Productmatch
						{
							<refinement> extends Either[java.lang.String,sbt.Project] with Productcase object sbt.ReloadErrorExpectedReloadErrorExpected =>
								sbt.BufferedLoggerbuffered.()Unitstop()
								Option[sbt.Project]previousProject.(=> java.lang.String)Either[java.lang.String,sbt.Project] with ProducttoRight(java.lang.String("Initial project load failed.")"Initial project load failed.")
							Left[String,Nothing]case sbt.ReloadSuccessExpecteds: sbt.ReloadSuccessExpectedReloadSuccessExpected => (String)Left[String,Nothing]error(sbt.ReloadSuccessExpecteds.=> StringprefixIfError (Any)java.lang.String+ Stringmsg)
							Left[String,Nothing]case object sbt.NoReloadNoReload /* shouldn't happen */=> (String)Left[String,Nothing]error(Stringmsg)
						}
					<refinement> extends Either[String,sbt.Project] with Productcase Right(sbt.Projectp) =>
						sbt.ReloadProjectreload <refinement> extends Either[String,sbt.Project] with Productmatch
						{
							Left[String,Nothing]case object sbt.ReloadErrorExpectedReloadErrorExpected => (String)Left[String,Nothing]error(java.lang.String("Expected project load failure, but it succeeded.")"Expected project load failure, but it succeeded.")
							Right[Nothing,sbt.Project]case _ =>
								sbt.BufferedLoggerbuffered.()Unitstop()
								(sbt.Project)Right[Nothing,sbt.Project]Right(sbt.Projectp)
						}
				}
			}
		<refinement> extends Either[java.lang.String,sbt.Project] with ProductloadResult Either[String,T]match
		{
			Either[String,T]case Right(sbt.Projectproject) =>
				(sbt.Project)sbt.WithProjectResult[T]f(sbt.Projectproject) Either[String,T]match
				{
					Either[String,T]case ContinueResult((sbt.Project) => sbt.WithProjectResult[T]newF, sbt.ReloadProjectnewReload) => (sbt.Logger,Option[sbt.Project],sbt.ReloadProject,java.io.File)((sbt.Project) => sbt.WithProjectResult[T])Either[String,T]withProject(sbt.Loggerlog, (sbt.Project)Some[sbt.Project]Some(sbt.Projectproject), sbt.ReloadProjectnewReload, java.io.Filedir)((sbt.Project) => sbt.WithProjectResult[T]newF)
					Right[Nothing,T]case ValueResult(Tvalue) => (T)Right[Nothing,T]Right(Tvalue)
					Left[String,Nothing]case sbt.ErrorResulterr: sbt.ErrorResultErrorResult => (String)Left[String,Nothing]Left(sbt.ErrorResulterr.=> Stringmessage)
				}
			Left[java.lang.String,Nothing]case Left(java.lang.Stringmessage) => (java.lang.String)Left[java.lang.String,Nothing]Left(java.lang.Stringmessage)
		}
	}

	def (sbt.LoadResult)Either[String,sbt.Project]resultToEither(sbt.LoadResultresult: sbt.LoadResultLoadResult): Either[String,sbt.Project]Either[String, Project] =
		sbt.LoadResultresult Either[String,sbt.Project]match
		{
			Right[Nothing,sbt.Project]case sbt.LoadSuccesssuccess: sbt.LoadSuccessLoadSuccess => (sbt.Project)Right[Nothing,sbt.Project]Right(sbt.LoadSuccesssuccess.=> sbt.Projectproject)
			Left[String,Nothing]case sbt.LoadErrorerr: sbt.LoadErrorLoadError => (String)Left[String,Nothing]Left(sbt.LoadErrorerr.=> Stringmessage)
			Left[String,Nothing]case sbt.LoadSetupErrorerr: sbt.LoadSetupErrorLoadSetupError => (String)Left[String,Nothing]Left(sbt.LoadSetupErrorerr.=> Stringmessage)
			Left[java.lang.String,Nothing]case object sbt.LoadSetupDeclinedLoadSetupDeclined => (java.lang.String)Left[java.lang.String,Nothing]Left(java.lang.String("Setup declined")"Setup declined")
		}
}
sealed trait trait ReloadProject extends java.lang.Object with NotNullReloadProject extends NotNullNotNull
final object object sbt.ReloadErrorExpectedReloadErrorExpected extends sbt.ReloadProjectReloadProject
final class class ReloadSuccessExpected extends java.lang.Object with sbt.ReloadProject with ScalaObjectReloadSuccessExpected(val StringprefixIfError: StringString) extends sbt.ReloadProjectReloadProject
final object object sbt.NoReloadNoReload extends sbt.ReloadProjectReloadProject

sealed trait trait WithProjectResult[+T] extends java.lang.Object with NotNullWithProjectResult[+>: Nothing <: AnyT] extends NotNullNotNull
final case class class ContinueResult[T] extends java.lang.Object with sbt.WithProjectResult[T] with ScalaObject with ProductContinueResult[>: Nothing <: AnyT]((sbt.Project) => sbt.WithProjectResult[T]f: Project => WithProjectResult[T], sbt.ReloadProjectreload: sbt.ReloadProjectReloadProject) extends sbt.WithProjectResult[T]WithProjectResult[T]
final case class class ValueResult[T] extends java.lang.Object with sbt.WithProjectResult[T] with ScalaObject with ProductValueResult[>: Nothing <: AnyT](Tvalue: TT) extends sbt.WithProjectResult[T]WithProjectResult[T]
final class class ErrorResult extends java.lang.Object with sbt.WithProjectResult[Nothing] with ScalaObjectErrorResult(val Stringmessage: StringString) extends sbt.WithProjectResult[Nothing]WithProjectResult[Nothing]
object object sbt.ContinueResultContinueResult
{
	def [T]((sbt.Project) => sbt.WithProjectResult[T],Option[String])sbt.ContinueResult[T]apply[>: Nothing <: AnyT]((sbt.Project) => sbt.WithProjectResult[T]f: Project => WithProjectResult[T], Option[String]prefixIfError: Option[String]Option[String]) =
	{
		val <refinement> extends sbt.ReloadProject with ScalaObjectreload = Option[String]prefixIfError <refinement> extends sbt.ReloadProject with ScalaObjectmatch { sbt.NoReload.typecase object NoneNone => object sbt.NoReloadNoReload; sbt.ReloadSuccessExpectedcase Some(Stringp) => sbt.ReloadSuccessExpectednew sbt.ReloadSuccessExpectedReloadSuccessExpected(Stringp) }
		sbt.ContinueResult[T]new sbt.ContinueResult[T]ContinueResult[T]((sbt.Project) => sbt.WithProjectResult[T]f, <refinement> extends sbt.ReloadProject with ScalaObjectreload)
	}
}