<commit_before>/* sbt -- Simple Build Tool
 * Copyright 2008, 2009  <NAME>, <NAME>
 */
package sbt

/** The default project when no project is explicitly configured and the common base class for
* configuring a project.*/
class DefaultProject(val info: ProjectInfo) extends BasicScalaProject with MavenStyleScalaPaths
class DefaultWebProject(val info: ProjectInfo) extends BasicWebScalaProject with MavenStyleWebScalaPaths


import BasicScalaProject._
import ScalaProject.{optionsAsString, javaOptionsAsString}
import java.io.File
import java.net.URLClassLoader
import java.util.jar.Attributes

/** This class defines concrete instances of actions from ScalaProject using overridable paths,
* options, and configuration. */
abstract class BasicScalaProject extends ScalaProject with BasicDependencyProject with ScalaPaths
{
	/** The explicitly specified class to be run by the 'run' action.
	* See http://code.google.com/p/simple-build-tool/wiki/RunningProjectCode for details.*/
	def mainClass: Option[String] = None
	/** Gets the main class to use.  This is used by package and run to determine which main
	* class to run or include as the Main-Class attribute.
	* If `mainClass` is explicitly specified, it is used.  Otherwise, the main class is selected from
	* the classes with a main method as automatically detected by the analyzer plugin.
	* `promptIfMultipleChoices` controls the behavior when multiple main classes are detected.
	* If true, it prompts the user to select which main class to use.  If false, it prints a warning
	* and returns no main class.*/
	def getMainClass(promptIfMultipleChoices: Boolean) =
		mainClass orElse
		{
			val applications = mainCompileConditional.analysis.allApplications.toList
			impl.SelectMainClass(promptIfMultipleChoices, applications) orElse
			{
				if(!promptIfMultipleChoices && !applications.isEmpty)
					warnMultipleMainClasses(log)
				None
			}
		}
	/** Specifies the value of the `Class-Path` attribute in the manifest of the main jar. */
	def manifestClassPath: Option[String] = None
	def dependencies = info.dependencies ++ subProjects.values.toList

	val mainCompileConditional = new CompileConditional(mainCompileConfiguration, buildCompiler)
	val testCompileConditional = new CompileConditional(testCompileConfiguration, buildCompiler)

	def compileOrder = CompileOrder.Mixed

	/** The main artifact produced by this project. To redefine the main artifact, override `defaultMainArtifact`
	* Additional artifacts are defined by `val`s of type `Artifact`.*/
	lazy val mainArtifact = defaultMainArtifact
	/** Defines the default main Artifact assigned to `mainArtifact`.  By default, this is a jar file with name given
	* by `artifactID`.*/
	protected def defaultMainArtifact = Artifact(artifactID, "jar", "jar")

	import Project._

	/** The options provided to the 'compile' action to pass to the Scala compiler.*/
	def compileOptions: Seq[CompileOption] = Deprecation :: Nil
	/** The options provided to the 'compile' action to pass to the Java compiler. */
	def javaCompileOptions: Seq[JavaCompileOption] = Nil
	/** The options provided to the 'test-compile' action, defaulting to those for the 'compile' action.*/
	def testCompileOptions: Seq[CompileOption] = compileOptions
	/** The options provided to the 'test-compile' action to pass to the Java compiler. */
	def testJavaCompileOptions: Seq[JavaCompileOption] = javaCompileOptions

	/** The options provided to the 'doc' and 'docTest' actions.*/
	def documentOptions: Seq[ScaladocOption] =
		LinkSource ::
		documentTitle(name + " " + version + " API") ::
		windowTitle(name + " " + version + " API") ::
		Nil
	/** The options provided to the 'test' action..*/
	def testOptions: Seq[TestOption] =
		TestListeners(testListeners) ::
		TestFilter(includeTest) ::
		Nil
	/** The options provided to the clean action.  You can add files to be removed and files to be preserved here.*/
	def cleanOptions: Seq[CleanOption] =
		ClearAnalysis(mainCompileConditional.analysis) ::
		ClearAnalysis(testCompileConditional.analysis) ::
		historyPath.map(history => Preserve(history)).toList

	def packageOptions: Seq[PackageOption] =
		manifestClassPath.map(cp => ManifestAttributes( (Attributes.Name.CLASS_PATH, cp) )).toList :::
		getMainClass(false).map(MainClass(_)).toList

	private def succeededTestPath = testAnalysisPath / "succeeded-tests"
	private def quickOptions(failedOnly: Boolean) =
	{
		val path = succeededTestPath
		val analysis = testCompileConditional.analysis
		TestFilter(new impl.TestQuickFilter(analysis, failedOnly, path, log))  :: TestListeners(new impl.TestStatusReporter(path, log) :: Nil) :: Nil
	}

	def consoleInit = ""

	protected def includeTest(test: String): Boolean = true

	/** This is called to create the initial directories when a user makes a new project from
	* sbt.*/
	override final def initializeDirectories()
	{
		FileUtilities.createDirectories(directoriesToCreate.map(_.asFile), log) match
		{
			case Some(errorMessage) => log.error("Could not initialize directory structure: " + errorMessage)
			case None => log.success("Successfully initialized directory structure.")
		}
	}
	import Configurations._
	/** The managed configuration to use when determining the classpath for a Scala interpreter session.*/
	def consoleConfiguration = Test

	/** A PathFinder that provides the classpath to pass to scaladoc.  It is the same as the compile classpath
	* by default. */
	def docClasspath = compileClasspath
	/** A PathFinder that provides the classpath to pass to the compiler.*/
	def compileClasspath = fullClasspath(Compile) +++ optionalClasspath
	/** A PathFinder that provides the classpath to use when unit testing.*/
	def testClasspath = fullClasspath(Test) +++ optionalClasspath
	/** A PathFinder that provides the classpath to use when running the class specified by 'getMainClass'.*/
	def runClasspath = fullClasspath(Runtime) +++ optionalClasspath
	/** A PathFinder that provides the classpath to use for a Scala interpreter session.*/
	def consoleClasspath = fullClasspath(consoleConfiguration) +++ optionalClasspath
	/** A PathFinder that corresponds to Maven's optional scope.  It includes any managed libraries in the
	* 'optional' configuration for this project only.*/
	def optionalClasspath = managedClasspath(Optional)
	/** A PathFinder that contains the jars that should be included in a comprehensive package.  This is
	* by default the 'runtime' classpath excluding the 'provided' classpath.*/
	def publicClasspath = runClasspath --- fullClasspath(Provided)

	/** This returns the unmanaged classpath for only this project for the given configuration.  It by
	* default includes the main compiled classes for this project and the libraries in this project's
	* unmanaged library directory (lib) and the managed directory for the specified configuration.  It
	* also adds the resource directories appropriate to the configuration.
	* The Provided and Optional configurations are treated specially; they are empty
	* by default.*/
	def fullUnmanagedClasspath(config: Configuration) =
	{
		config match
		{
			case CompilerPlugin => unmanagedClasspath
			case Runtime => runUnmanagedClasspath
			case Test => testUnmanagedClasspath
			case Provided | Optional => Path.emptyPathFinder
			case _ => mainUnmanagedClasspath
		}
	}
	/** The unmanaged base classpath.  By default, the unmanaged classpaths for test and run include this classpath. */
	protected def mainUnmanagedClasspath = mainCompilePath +++ mainResourcesOutputPath +++ unmanagedClasspath
	/** The unmanaged classpath for the run configuration. By default, it includes the base classpath returned by
	* `mainUnmanagedClasspath`.*/
	protected def runUnmanagedClasspath = mainUnmanagedClasspath +++ mainDependencies.scalaCompiler
	/** The unmanaged classpath for the test configuration.  By default, it includes the run classpath, which includes the base
	* classpath returned by `mainUnmanagedClasspath`.*/
	protected def testUnmanagedClasspath = testCompilePath +++ testResourcesOutputPath  +++ testDependencies.scalaCompiler +++ runUnmanagedClasspath

	/** @deprecated Use `mainDependencies.scalaJars`*/
	@deprecated protected final def scalaJars: Iterable[File] = mainDependencies.scalaJars.get.map(_.asFile)
	/** An analysis of the jar dependencies of the main Scala sources.  It is only valid after main source compilation.
	* See the LibraryDependencies class for details. */
	final def mainDependencies = new LibraryDependencies(this, mainCompileConditional)
	/** An analysis of the jar dependencies of the test Scala sources.  It is only valid after test source compilation.
	* See the LibraryDependencies class for details. */
	final def testDependencies = new LibraryDependencies(this, testCompileConditional)

	/** The list of test frameworks to use for testing.  Note that adding frameworks to this list
	* for an active project currently requires an explicit 'clean' to properly update the set of tests to
	* run*/
	def testFrameworks: Seq[TestFramework] = 
	{
		import TestFrameworks.{ScalaCheck, ScalaTest, Specs}
		/*ScalaCheckFramework :: SpecsFramework ::*/ ScalaTest :: Nil
	}
	/** The list of listeners for testing. */
	def testListeners: Seq[TestReportListener] = TestLogger(log) :: Nil

	def mainLabel = "main"
	def testLabel = "test"

	def mainCompileConfiguration: CompileConfiguration = new MainCompileConfig
	def testCompileConfiguration: CompileConfiguration = new TestCompileConfig
	abstract class BaseCompileConfig extends CompileConfiguration
	{
		def log = BasicScalaProject.this.log
		def projectPath = info.projectPath
		def baseCompileOptions: Seq[CompileOption]
		def options = optionsAsString(baseCompileOptions.filter(!_.isInstanceOf[MaxCompileErrors]))
		def maxErrors = maximumErrors(baseCompileOptions)
		def compileOrder = BasicScalaProject.this.compileOrder
		protected def testClassNames(frameworks: Seq[TestFramework]) = 
		{
			val loader = TestFramework.createTestLoader(classpath.get, buildScalaInstance.loader)
			def getTestNames(framework: TestFramework): Seq[String] =
				framework.create(loader, log).toList.flatMap(_.tests.map(_.superClassName))
			frameworks.flatMap(getTestNames)<commit_msg>Fix from Josh to enable ScalaCheck support<commit_after>/* sbt -- Simple Build Tool
 * Copyright 2008, 2009  <NAME>, <NAME>
 */
package sbt

/** The default project when no project is explicitly configured and the common base class for
* configuring a project.*/
class DefaultProject(val info: ProjectInfo) extends BasicScalaProject with MavenStyleScalaPaths
class DefaultWebProject(val info: ProjectInfo) extends BasicWebScalaProject with MavenStyleWebScalaPaths


import BasicScalaProject._
import ScalaProject.{optionsAsString, javaOptionsAsString}
import java.io.File
import java.net.URLClassLoader
import java.util.jar.Attributes

/** This class defines concrete instances of actions from ScalaProject using overridable paths,
* options, and configuration. */
abstract class BasicScalaProject extends ScalaProject with BasicDependencyProject with ScalaPaths
{
	/** The explicitly specified class to be run by the 'run' action.
	* See http://code.google.com/p/simple-build-tool/wiki/RunningProjectCode for details.*/
	def mainClass: Option[String] = None
	/** Gets the main class to use.  This is used by package and run to determine which main
	* class to run or include as the Main-Class attribute.
	* If `mainClass` is explicitly specified, it is used.  Otherwise, the main class is selected from
	* the classes with a main method as automatically detected by the analyzer plugin.
	* `promptIfMultipleChoices` controls the behavior when multiple main classes are detected.
	* If true, it prompts the user to select which main class to use.  If false, it prints a warning
	* and returns no main class.*/
	def getMainClass(promptIfMultipleChoices: Boolean) =
		mainClass orElse
		{
			val applications = mainCompileConditional.analysis.allApplications.toList
			impl.SelectMainClass(promptIfMultipleChoices, applications) orElse
			{
				if(!promptIfMultipleChoices && !applications.isEmpty)
					warnMultipleMainClasses(log)
				None
			}
		}
	/** Specifies the value of the `Class-Path` attribute in the manifest of the main jar. */
	def manifestClassPath: Option[String] = None
	def dependencies = info.dependencies ++ subProjects.values.toList

	val mainCompileConditional = new CompileConditional(mainCompileConfiguration, buildCompiler)
	val testCompileConditional = new CompileConditional(testCompileConfiguration, buildCompiler)

	def compileOrder = CompileOrder.Mixed

	/** The main artifact produced by this project. To redefine the main artifact, override `defaultMainArtifact`
	* Additional artifacts are defined by `val`s of type `Artifact`.*/
	lazy val mainArtifact = defaultMainArtifact
	/** Defines the default main Artifact assigned to `mainArtifact`.  By default, this is a jar file with name given
	* by `artifactID`.*/
	protected def defaultMainArtifact = Artifact(artifactID, "jar", "jar")

	import Project._

	/** The options provided to the 'compile' action to pass to the Scala compiler.*/
	def compileOptions: Seq[CompileOption] = Deprecation :: Nil
	/** The options provided to the 'compile' action to pass to the Java compiler. */
	def javaCompileOptions: Seq[JavaCompileOption] = Nil
	/** The options provided to the 'test-compile' action, defaulting to those for the 'compile' action.*/
	def testCompileOptions: Seq[CompileOption] = compileOptions
	/** The options provided to the 'test-compile' action to pass to the Java compiler. */
	def testJavaCompileOptions: Seq[JavaCompileOption] = javaCompileOptions

	/** The options provided to the 'doc' and 'docTest' actions.*/
	def documentOptions: Seq[ScaladocOption] =
		LinkSource ::
		documentTitle(name + " " + version + " API") ::
		windowTitle(name + " " + version + " API") ::
		Nil
	/** The options provided to the 'test' action..*/
	def testOptions: Seq[TestOption] =
		TestListeners(testListeners) ::
		TestFilter(includeTest) ::
		Nil
	/** The options provided to the clean action.  You can add files to be removed and files to be preserved here.*/
	def cleanOptions: Seq[CleanOption] =
		ClearAnalysis(mainCompileConditional.analysis) ::
		ClearAnalysis(testCompileConditional.analysis) ::
		historyPath.map(history => Preserve(history)).toList

	def packageOptions: Seq[PackageOption] =
		manifestClassPath.map(cp => ManifestAttributes( (Attributes.Name.CLASS_PATH, cp) )).toList :::
		getMainClass(false).map(MainClass(_)).toList

	private def succeededTestPath = testAnalysisPath / "succeeded-tests"
	private def quickOptions(failedOnly: Boolean) =
	{
		val path = succeededTestPath
		val analysis = testCompileConditional.analysis
		TestFilter(new impl.TestQuickFilter(analysis, failedOnly, path, log))  :: TestListeners(new impl.TestStatusReporter(path, log) :: Nil) :: Nil
	}

	def consoleInit = ""

	protected def includeTest(test: String): Boolean = true

	/** This is called to create the initial directories when a user makes a new project from
	* sbt.*/
	override final def initializeDirectories()
	{
		FileUtilities.createDirectories(directoriesToCreate.map(_.asFile), log) match
		{
			case Some(errorMessage) => log.error("Could not initialize directory structure: " + errorMessage)
			case None => log.success("Successfully initialized directory structure.")
		}
	}
	import Configurations._
	/** The managed configuration to use when determining the classpath for a Scala interpreter session.*/
	def consoleConfiguration = Test

	/** A PathFinder that provides the classpath to pass to scaladoc.  It is the same as the compile classpath
	* by default. */
	def docClasspath = compileClasspath
	/** A PathFinder that provides the classpath to pass to the compiler.*/
	def compileClasspath = fullClasspath(Compile) +++ optionalClasspath
	/** A PathFinder that provides the classpath to use when unit testing.*/
	def testClasspath = fullClasspath(Test) +++ optionalClasspath
	/** A PathFinder that provides the classpath to use when running the class specified by 'getMainClass'.*/
	def runClasspath = fullClasspath(Runtime) +++ optionalClasspath
	/** A PathFinder that provides the classpath to use for a Scala interpreter session.*/
	def consoleClasspath = fullClasspath(consoleConfiguration) +++ optionalClasspath
	/** A PathFinder that corresponds to Maven's optional scope.  It includes any managed libraries in the
	* 'optional' configuration for this project only.*/
	def optionalClasspath = managedClasspath(Optional)
	/** A PathFinder that contains the jars that should be included in a comprehensive package.  This is
	* by default the 'runtime' classpath excluding the 'provided' classpath.*/
	def publicClasspath = runClasspath --- fullClasspath(Provided)

	/** This returns the unmanaged classpath for only this project for the given configuration.  It by
	* default includes the main compiled classes for this project and the libraries in this project's
	* unmanaged library directory (lib) and the managed directory for the specified configuration.  It
	* also adds the resource directories appropriate to the configuration.
	* The Provided and Optional configurations are treated specially; they are empty
	* by default.*/
	def fullUnmanagedClasspath(config: Configuration) =
	{
		config match
		{
			case CompilerPlugin => unmanagedClasspath
			case Runtime => runUnmanagedClasspath
			case Test => testUnmanagedClasspath
			case Provided | Optional => Path.emptyPathFinder
			case _ => mainUnmanagedClasspath
		}
	}
	/** The unmanaged base classpath.  By default, the unmanaged classpaths for test and run include this classpath. */
	protected def mainUnmanagedClasspath = mainCompilePath +++ mainResourcesOutputPath +++ unmanagedClasspath
	/** The unmanaged classpath for the run configuration. By default, it includes the base classpath returned by
	* `mainUnmanagedClasspath`.*/
	protected def runUnmanagedClasspath = mainUnmanagedClasspath +++ mainDependencies.scalaCompiler
	/** The unmanaged classpath for the test configuration.  By default, it includes the run classpath, which includes the base
	* classpath returned by `mainUnmanagedClasspath`.*/
	protected def testUnmanagedClasspath = testCompilePath +++ testResourcesOutputPath  +++ testDependencies.scalaCompiler +++ runUnmanagedClasspath

	/** @deprecated Use `mainDependencies.scalaJars`*/
	@deprecated protected final def scalaJars: Iterable[File] = mainDependencies.scalaJars.get.map(_.asFile)
	/** An analysis of the jar dependencies of the main Scala sources.  It is only valid after main source compilation.
	* See the LibraryDependencies class for details. */
	final def mainDependencies = new LibraryDependencies(this, mainCompileConditional)
	/** An analysis of the jar dependencies of the test Scala sources.  It is only valid after test source compilation.
	* See the LibraryDependencies class for details. */
	final def testDependencies = new LibraryDependencies(this, testCompileConditional)

	/** The list of test frameworks to use for testing.  Note that adding frameworks to this list
	* for an active project currently requires an explicit 'clean' to properly update the set of tests to
	* run*/
	def testFrameworks: Seq[TestFramework] = 
	{
		import TestFrameworks.{ScalaCheck, ScalaTest, Specs}
		ScalaCheckFramework :: 	/*SpecsFramework ::*/ ScalaTest :: Nil
	}
	/** The list of listeners for testing. */
	def testListeners: Seq[TestReportListener] = TestLogger(log) :: Nil

	def mainLabel = "main"
	def testLabel = "test"

	def mainCompileConfiguration: CompileConfiguration = new MainCompileConfig
	def testCompileConfiguration: CompileConfiguration = new TestCompileConfig
	abstract class BaseCompileConfig extends CompileConfiguration
	{
		def log = BasicScalaProject.this.log
		def projectPath = info.projectPath
		def baseCompileOptions: Seq[CompileOption]
		def options = optionsAsString(baseCompileOptions.filter(!_.isInstanceOf[MaxCompileErrors]))
		def maxErrors = maximumErrors(baseCompileOptions)
		def compileOrder = BasicScalaProject.this.compileOrder
		protected def testClassNames(frameworks: Seq[TestFramework]) = 
		{
			val loader = TestFramework.createTestLoader(classpath.get, buildScalaInstance.loader)
			def getTestNames(framework: TestFramework): Seq[String] =
				framework.create(loader, log).toList.flatMap(_.tests.map(_.superClassName))
			frameworks.flatMap(getTestNames)
{'fraction_non_alphanumeric': 0.07877182656464587, 'fraction_numerical': 0.0007847753580537571, 'mean_word_length': 5.02155936207915, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6526704', 'n_tokens_mistral': 5663, 'n_tokens_neox': 5321, 'n_words': 2013}