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

/** The project definition used to build project definitions. */
private final class BuilderProject(val info: ProjectInfo, override protected val logImpl: Logger) extends SimpleScalaProject
{
	import BasicProjectPaths._
	
	def compilePath = outputPath / DefaultMainCompileDirectoryName
	def sourcePath = path(DefaultSourceDirectoryName)
	def mainResourcesPath = path(DefaultResourcesDirectoryName)
	def dependencyPath = path(DefaultDependencyDirectoryName)
	
	def libraries = descendents(dependencyPath, "*.jar")
	
	def compileOptions = Deprecation :: Unchecked :: Nil
	def javaCompileOptions = Nil
	override def tasks = Map.empty
	override def methods = Map.empty
	def dependencies = Nil
	
	override protected def disableCrossPaths = false
	
	def projectClasspath = compilePath +++ libraries +++
		Path.lazyPathFinder { Path.fromFile(FileUtilities.sbtJar) :: Nil }

	val compileConditional = new BuilderCompileConditional
	final class BuilderCompileConditional extends AbstractCompileConditional(compileConfiguration)
	{
		type AnalysisType = BuilderCompileAnalysis
		override protected def constructAnalysis(analysisPath: Path, projectPath: Path, log: Logger) =
			new BuilderCompileAnalysis(analysisPath, projectPath, log)
		override protected def execute(cAnalysis: ConditionalAnalysis): Option[String] =
		{
			if(cAnalysis.dirtySources.isEmpty)
				None
			else
			{
				val oldLevel = log.getLevel
				log.setLevel(Level.Info)
				log.info("Recompiling project definition...")
				log.info("\t" + cAnalysis.toString)
				log.setLevel(oldLevel)
				super.execute(cAnalysis)
			}
		}
		protected def analysisCallback: AnalysisCallback =
			new BasicAnalysisCallback(info.projectPath, List(Project.ProjectClassName), analysis)
			{
				def foundApplication(sourcePath: Path, className: String)  {}
				def foundSubclass(sourcePath: Path, subclassName: String, superclassName: String, isModule: Boolean)
				{
					if(superclassName == Project.ProjectClassName && !isModule)
					{
						log.debug("Found project definition " + subclassName)
						analysis.addProjectDefinition(sourcePath, subclassName)
					}
				}
			}
	}
	
	lazy val compile = task { compileConditional.run }
	lazy val clean = cleanTask(outputPath, ClearAnalysis(compileConditional.analysis))
	
	def compileConfiguration =
		new AbstractCompileConfiguration
		{
			def label = "builder"
			def sources = sourcePath.descendentsExcept("*.scala", defaultExcludes)
			def outputDirectory = compilePath
			def classpath = projectClasspath
			def analysisPath = outputPath / DefaultMainAnalysisDirectoryName
			def projectPath = info.projectPath
			def log = BuilderProject.this.log
			def options = compileOptions.map(_.asString)
			def javaOptions = javaCompileOptions
			def maxErrors = ScalaProject.DefaultMaximumCompileErrors
			def compileOrder = CompileOrder.Mixed
		}
		
	def projectDefinition: Either[String, Option[String]] =
	{
		compileConditional.analysis.allProjects.toList match
		{
			case Nil => 
				log.debug("No project definitions detected using default project.")
				Right(None)
			case singleDefinition :: Nil => Right(Some(singleDefinition))
			case multipleDefinitions =>Left(multipleDefinitions.mkString("Multiple project definitions detected: \n\t","\n\t","\n"))
		}
	}
}<commit_msg>Additional flattening for project definitions: sources can go either in project/build/src (recursively) or project/build (flat)<commit_after>/* sbt -- Simple Build Tool
 * Copyright 2008 <NAME>, <NAME>
 */
package sbt

/** The project definition used to build project definitions. */
private final class BuilderProject(val info: ProjectInfo, override protected val logImpl: Logger) extends SimpleScalaProject
{
	import BasicProjectPaths._
	
	def compilePath = outputPath / DefaultMainCompileDirectoryName
	def mainSources = (info.projectPath * "*.scala") +++ path(DefaultSourceDirectoryName).descendentsExcept("*.scala", defaultExcludes)
	def mainResourcesPath = path(DefaultResourcesDirectoryName)
	def dependencyPath = path(DefaultDependencyDirectoryName)
	
	def libraries = descendents(dependencyPath, "*.jar")
	
	def compileOptions = Deprecation :: Unchecked :: Nil
	def javaCompileOptions = Nil
	override def tasks = Map.empty
	override def methods = Map.empty
	def dependencies = Nil
	
	override protected def disableCrossPaths = false
	
	def projectClasspath = compilePath +++ libraries +++
		Path.lazyPathFinder { Path.fromFile(FileUtilities.sbtJar) :: Nil }

	val compileConditional = new BuilderCompileConditional
	final class BuilderCompileConditional extends AbstractCompileConditional(compileConfiguration)
	{
		type AnalysisType = BuilderCompileAnalysis
		override protected def constructAnalysis(analysisPath: Path, projectPath: Path, log: Logger) =
			new BuilderCompileAnalysis(analysisPath, projectPath, log)
		override protected def execute(cAnalysis: ConditionalAnalysis): Option[String] =
		{
			if(cAnalysis.dirtySources.isEmpty)
				None
			else
			{
				val oldLevel = log.getLevel
				log.setLevel(Level.Info)
				log.info("Recompiling project definition...")
				log.info("\t" + cAnalysis.toString)
				log.setLevel(oldLevel)
				super.execute(cAnalysis)
			}
		}
		protected def analysisCallback: AnalysisCallback =
			new BasicAnalysisCallback(info.projectPath, List(Project.ProjectClassName), analysis)
			{
				def foundApplication(sourcePath: Path, className: String)  {}
				def foundSubclass(sourcePath: Path, subclassName: String, superclassName: String, isModule: Boolean)
				{
					if(superclassName == Project.ProjectClassName && !isModule)
					{
						log.debug("Found project definition " + subclassName)
						analysis.addProjectDefinition(sourcePath, subclassName)
					}
				}
			}
	}
	
	lazy val compile = task { compileConditional.run }
	lazy val clean = cleanTask(outputPath, ClearAnalysis(compileConditional.analysis))
	
	def compileConfiguration =
		new AbstractCompileConfiguration
		{
			def label = "builder"
			def sources = mainSources
			def outputDirectory = compilePath
			def classpath = projectClasspath
			def analysisPath = outputPath / DefaultMainAnalysisDirectoryName
			def projectPath = info.projectPath
			def log = BuilderProject.this.log
			def options = compileOptions.map(_.asString)
			def javaOptions = javaCompileOptions
			def maxErrors = ScalaProject.DefaultMaximumCompileErrors
			def compileOrder = CompileOrder.Mixed
		}
		
	def projectDefinition: Either[String, Option[String]] =
	{
		compileConditional.analysis.allProjects.toList match
		{
			case Nil => 
				log.debug("No project definitions detected using default project.")
				Right(None)
			case singleDefinition :: Nil => Right(Some(singleDefinition))
			case multipleDefinitions =>Left(multipleDefinitions.mkString("Multiple project definitions detected: \n\t","\n\t","\n"))
		}
	}
}
{'fraction_non_alphanumeric': 0.08544900623821268, 'fraction_numerical': 0.0011605977078195271, 'mean_word_length': 4.773869346733668, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '2543690', 'n_tokens_mistral': 2127, 'n_tokens_neox': 1800, 'n_words': 484}