diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-02-15 01:37:53 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-02-15 03:47:49 -0500 |
commit | 7ee113962134e3c9c4659d6de9de3c7015174d3f (patch) | |
tree | 55f6158be8a53d3ad640f3cd038baeaf1a8f1f30 /stage2/Lib.scala | |
parent | 2c8257b0c119b38102aa0c3efecffc7fefc9d766 (diff) | |
download | cbt-7ee113962134e3c9c4659d6de9de3c7015174d3f.tar.gz cbt-7ee113962134e3c9c4659d6de9de3c7015174d3f.tar.bz2 cbt-7ee113962134e3c9c4659d6de9de3c7015174d3f.zip |
add package to generated Main.scala to avoid classpath weirdnesses
caused by multiple root package Main classes from different subproject
or test projects ending up on the same classpath
Diffstat (limited to 'stage2/Lib.scala')
-rw-r--r-- | stage2/Lib.scala | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 0d382f2..fc53c4f 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -15,7 +15,7 @@ import scala.util._ case class Developer(id: String, name: String, timezone: String, url: URL) /** Don't extend. Create your own libs :). */ -final class Lib(val logger: Logger) extends Stage1Lib(logger) with Scaffold{ +final class Lib(val logger: Logger) extends Stage1Lib(logger){ lib => val buildFileName = "build.scala" @@ -28,16 +28,11 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger) with Scaffold{ This can either the Build itself, of if exists a BuildBuild or a BuildBuild for a BuildBuild and so on. */ def loadRoot(context: Context): BuildInterface = { - def findStartDir(directory: File): File = { - val buildDir = realpath( directory ++ "/build" ) - if(buildDir.exists) findStartDir(buildDir) else directory - } - val directory = context.workingDirectory context.logger.composition( context.logger.showInvocation("Build.loadRoot",directory) ) - val start = findStartDir(directory) + val start = lib.findInnerMostModuleDirectory(directory) val useBasicBuild = directory == start && start.getName != buildDirectoryName @@ -534,4 +529,15 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger) with Scaffold{ } } } + + def findInnerMostModuleDirectory(directory: File): File = { + val buildDir = realpath( directory ++ ("/" ++ lib.buildDirectoryName) ) + // do not appent buildFileName here, so that we detect empty build folders + if(buildDir.exists) findInnerMostModuleDirectory(buildDir) else directory + } + def findOuterMostModuleDirectory(directory: File): File = { + if( + ( directory.getParentFile ++ ("/" ++ lib.buildDirectoryName) ).exists + ) findOuterMostModuleDirectory(directory.getParentFile) else directory + } } |