aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-02-13 22:54:12 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2017-02-13 23:58:43 -0500
commitb8e3edf032c60e8c9ae4f28d5c3ac2e2720308cc (patch)
tree859a6a25651a56ba92ec158fdb03f542d57202bd
parente0fb6ec75286c695b7e4c5ed9189714d40f9b672 (diff)
downloadcbt-b8e3edf032c60e8c9ae4f28d5c3ac2e2720308cc.tar.gz
cbt-b8e3edf032c60e8c9ae4f28d5c3ac2e2720308cc.tar.bz2
cbt-b8e3edf032c60e8c9ae4f28d5c3ac2e2720308cc.zip
easier setting of projectDirectory in sub-builds
by replacing context.projectDirectory by workingDirectory and using it as the default but allowing it to being overridden
-rw-r--r--compatibility/Context.java6
-rw-r--r--examples/multi-combined-example/build/build.scala8
-rw-r--r--libraries/eval/build/build.scala2
-rw-r--r--stage1/ContextImplementation.scala4
-rw-r--r--stage1/cbt.scala4
-rw-r--r--stage2/BasicBuild.scala4
-rw-r--r--stage2/BuildBuild.scala2
-rw-r--r--stage2/BuildDependency.scala4
-rw-r--r--stage2/GitDependency.scala4
-rw-r--r--stage2/Lib.scala8
10 files changed, 26 insertions, 20 deletions
diff --git a/compatibility/Context.java b/compatibility/Context.java
index afd0b15..389d401 100644
--- a/compatibility/Context.java
+++ b/compatibility/Context.java
@@ -18,9 +18,11 @@ public interface Context{
public default long start(){
throw new IncompatibleCbtVersionException("You need to define method start.");
};
+ public default File workingDirectory(){
+ return projectDirectory();
+ };
// methods that exist for longer which every CBT version in use should have by now, no default values needed
- public abstract File projectDirectory();
public abstract File cwd(); // REPLACE by something that allows to run cbt on some other directly
public abstract String[] argsArray(); // replace this by https://github.com/cvogt/cbt/issues/172 ?
public abstract String[] enabledLoggersArray();
@@ -40,4 +42,6 @@ public interface Context{
public abstract ConcurrentHashMap<String,Object> permanentKeys();
@java.lang.Deprecated
public abstract ConcurrentHashMap<Object,ClassLoader> permanentClassLoaders();
+ @java.lang.Deprecated
+ public abstract File projectDirectory();
}
diff --git a/examples/multi-combined-example/build/build.scala b/examples/multi-combined-example/build/build.scala
index 41c03d6..7d1ff9f 100644
--- a/examples/multi-combined-example/build/build.scala
+++ b/examples/multi-combined-example/build/build.scala
@@ -10,7 +10,7 @@ class Shared(val context: Context) extends SharedCbtBuild
class Sub(val context:Context) extends SharedCbtBuild{
override def dependencies = Seq(new Shared(
context.copy(
- projectDirectory = projectDirectory ++ "/../shared"
+ workingDirectory = projectDirectory ++ "/../shared"
)
))
}
@@ -24,19 +24,19 @@ class Build(val context: Context) extends BaseBuild{
*/
def sub1 = new Sub(
context.copy(
- projectDirectory = projectDirectory ++ "/sub1"
+ workingDirectory = projectDirectory ++ "/sub1"
)
)
def sub2 = new Sub(
context.copy(
- projectDirectory = projectDirectory ++ "/sub2"
+ workingDirectory = projectDirectory ++ "/sub2"
)
)
def sub3 = // DON'T DO THIS, anonymous classes are currently not supported here.
new SharedCbtBuild{
def context = Build.this.context.copy(
- projectDirectory = Build.this.projectDirectory ++ "/sub3"
+ workingDirectory = Build.this.projectDirectory ++ "/sub3"
)
}
diff --git a/libraries/eval/build/build.scala b/libraries/eval/build/build.scala
index 7135d3f..a869ace 100644
--- a/libraries/eval/build/build.scala
+++ b/libraries/eval/build/build.scala
@@ -5,7 +5,7 @@ class Build(val context: Context) extends BaseBuild{
new ScalaCompilerDependency( context.cbtLastModified, context.paths.mavenCache, scalaVersion )
override def test: Option[ExitCode] = Some{
- new BasicBuild(context.copy(projectDirectory = projectDirectory ++ "/test")) with ScalaTest{
+ new BasicBuild(context.copy(workingDirectory = projectDirectory ++ "/test")) with ScalaTest{
override def dependencies = super.dependencies ++ Seq(
DirectoryDependency(projectDirectory++"/..")
)
diff --git a/stage1/ContextImplementation.scala b/stage1/ContextImplementation.scala
index 69094b0..b263ef4 100644
--- a/stage1/ContextImplementation.scala
+++ b/stage1/ContextImplementation.scala
@@ -2,7 +2,7 @@ package cbt
import java.io._
class ContextImplementation(
- override val projectDirectory: File,
+ override val workingDirectory: File,
override val cwd: File,
override val argsArray: Array[String],
override val enabledLoggersArray: Array[String],
@@ -17,6 +17,8 @@ class ContextImplementation(
override val compatibilityTarget: File,
override val parentBuildOrNull: BuildInterface
) extends Context{
+ @deprecated("this method is replaced by workingDirectory","")
+ def projectDirectory = workingDirectory
@deprecated("this method is replaced by cbtLastModified","")
def cbtHasChangedCompat = true
@deprecated("this method is replaced by start","")
diff --git a/stage1/cbt.scala b/stage1/cbt.scala
index a1776b1..54f3159 100644
--- a/stage1/cbt.scala
+++ b/stage1/cbt.scala
@@ -77,7 +77,7 @@ object `package`{
def cbtLastModified: scala.Long = subject.cbtLastModified
def copy(
- projectDirectory: File = projectDirectory,
+ workingDirectory: File = workingDirectory,
args: Seq[String] = args,
//enabledLoggers: Set[String] = enabledLoggers,
cbtLastModified: Long = cbtLastModified,
@@ -85,7 +85,7 @@ object `package`{
cbtHome: File = cbtHome,
parentBuild: Option[BuildInterface] = None
): Context = new ContextImplementation(
- projectDirectory,
+ workingDirectory,
cwd,
args.to,
enabledLoggers.to,
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index b7b0854..a2c7238 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -21,7 +21,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
// ========== general stuff ==========
def enableConcurrency = false
- final def projectDirectory: File = lib.realpath(context.projectDirectory)
+ def projectDirectory: File = lib.realpath(context.workingDirectory)
assert( projectDirectory.exists, "projectDirectory does not exist: " ++ projectDirectory.string )
assert(
projectDirectory.getName =!= "build" ||
@@ -107,7 +107,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
) = lib.ScalaDependency( groupId, artifactId, version, classifier, scalaVersion )
final def DirectoryDependency(path: File) = cbt.DirectoryDependency(
- context.copy( projectDirectory = path, args = Seq() )
+ context.copy( workingDirectory = path, args = Seq() )
)
def triggerLoopFiles: Seq[File] = sources ++ transitiveDependencies.collect{ case b: TriggerLoop => b.triggerLoopFiles }.flatten
diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala
index 1b05214..994ac2e 100644
--- a/stage2/BuildBuild.scala
+++ b/stage2/BuildBuild.scala
@@ -12,7 +12,7 @@ trait BuildBuildWithoutEssentials extends BaseBuild{
)
protected final val managedContext = context.copy(
- projectDirectory = managedBuildDirectory,
+ workingDirectory = managedBuildDirectory,
parentBuild=Some(this)
)
diff --git a/stage2/BuildDependency.scala b/stage2/BuildDependency.scala
index 236f958..ed6c2bd 100644
--- a/stage2/BuildDependency.scala
+++ b/stage2/BuildDependency.scala
@@ -17,8 +17,8 @@ trait TriggerLoop extends DependencyImplementation{
/** You likely want to use the factory method in the BasicBuild class instead of this. */
final case class DirectoryDependency(context: Context) extends TriggerLoop{
override def toString = show
- override def show = this.getClass.getSimpleName ++ "(" ++ context.projectDirectory.string ++ ")"
- def moduleKey = this.getClass.getName ++ "("+context.projectDirectory.string+")"
+ override def show = this.getClass.getSimpleName ++ "(" ++ context.workingDirectory.string ++ ")"
+ def moduleKey = this.getClass.getName ++ "("+context.workingDirectory.string+")"
lazy val logger = context.logger
override lazy val lib: Lib = new Lib(logger)
def transientCache = context.transientCache
diff --git a/stage2/GitDependency.scala b/stage2/GitDependency.scala
index 059d650..754e41a 100644
--- a/stage2/GitDependency.scala
+++ b/stage2/GitDependency.scala
@@ -21,7 +21,7 @@ case class GitDependency(
// See http://www.codeaffine.com/2014/12/09/jgit-authentication/
private val GitUrl( _, domain, path ) = url
- private val credentialsFile = context.projectDirectory ++ "/git.login"
+ private val credentialsFile = context.workingDirectory ++ "/git.login"
private def authenticate(_git: CloneCommand) =
if(!credentialsFile.exists){
@@ -67,7 +67,7 @@ case class GitDependency(
def dependency = taskCache[GitDependency]("dependency").memoize{
DirectoryDependency(
context.copy(
- projectDirectory = checkout ++ subDirectory.map("/" ++ _).getOrElse("")
+ workingDirectory = checkout ++ subDirectory.map("/" ++ _).getOrElse("")
)
)
}
diff --git a/stage2/Lib.scala b/stage2/Lib.scala
index fcf2642..d5119a7 100644
--- a/stage2/Lib.scala
+++ b/stage2/Lib.scala
@@ -31,7 +31,7 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger) with Scaffold{
if(buildDir.exists) findStartDir(buildDir) else directory
}
- val directory = context.projectDirectory
+ val directory = context.workingDirectory
context.logger.composition( context.logger.showInvocation("Build.loadRoot",directory) )
@@ -41,7 +41,7 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger) with Scaffold{
try{
if(useBasicBuild) {
- new BasicBuild( context.copy( projectDirectory = directory) )
+ new BasicBuild( context.copy( workingDirectory = directory ) )
} else if(
// essentials depends on eval, which has a build that depends on scalatest
// this means in these we can't depend on essentials
@@ -50,9 +50,9 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger) with Scaffold{
|| directory == (context.cbtHome ++ "/libraries/eval")
|| directory == (context.cbtHome ++ "/plugins/scalatest")
)
- new cbt.BasicBuild( context.copy( projectDirectory = start ) ) with BuildBuildWithoutEssentials
+ new cbt.BasicBuild( context.copy( workingDirectory = start ) ) with BuildBuildWithoutEssentials
else
- new cbt.BasicBuild( context.copy( projectDirectory = start ) ) with BuildBuild
+ new cbt.BasicBuild( context.copy( workingDirectory = start ) ) with BuildBuild
} catch {
case e:ClassNotFoundException if e.getMessage == "Build" =>
throw new Exception(s"no class Build found in " ++ start.string)