Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ CBT can help you with that. Execute:
$ cbt tools createBuild
```

Now there should be a file `build/build.scala` with a sample `Build` class.
Now there should be a file `cbt-build/Build.scala` with a sample `Build` class.

Btw., a build file can have it's own build and so on recursively like in SBT.
When you create a file `build/build/build.scala` and change `Build` class in there
to extend `BuildBuild`, it will be used to build your `build/build.scala`. You can
When you create a file `cbt-build/cbt-build/Build.scala` and change `Build` class in there
to extend `BuildBuild`, it will be used to build your `cbt-build/Build.scala`. You can
add built-time dependencies like plugins this way.

### Adding dependencies

In the generated `build/build.scala` there are
In the generated `cbt-build/Build.scala` there are
several examples for dependencies. We recommend using the constructor syntax
`ScalaDependency` (for automatically adding the scala version to the artifact id)
or `MavenDependency` (for leaving the artifact id as is). The SBT-Style `%`-DSL
Expand Down Expand Up @@ -247,7 +247,7 @@ we would have two classes with the same name on the classpath which can be very
Now that we have a Main file in our test project, we can add some assertions to it.
In order for them to see the main projects code, we still need to do one more thing -
add a `DirectoryDependency` to your test project's build file. There is a similar example
in the generated build.scala. What you need is this:
in the generated `Build.scala`. What you need is this:

```
override def dependencies = super.dependencies ++ Seq(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/dotty-example/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Dotty example project compiling hello world with the next version of Scala.

All you need to do to enable Dotty is `extends Dotty` in your build.scala .
All you need to do to enable Dotty is `extends Dotty` in your `Build.scala`.
8 changes: 4 additions & 4 deletions stage2/BuildBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait BuildBuild extends BaseBuild{
def managedBuildDirectory: java.io.File = lib.realpath( projectDirectory.parent )
private object managedBuildCache extends Cache[BuildInterface]
def managedBuild = managedBuildCache{
val managedBuildFile = projectDirectory++"/build.scala"
val managedBuildFile = projectDirectory++"/Build.scala"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing the below change, could we simple change this one val instead and show the warning if we are using build.scala here? Maybe easier than the nested if below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'll make it that way.

logger.composition("Loading build at "++managedContext.projectDirectory.toString)
val build = (
if(managedBuildFile.exists){
Expand Down Expand Up @@ -56,14 +56,14 @@ trait BuildBuild extends BaseBuild{
.newInstance(managedContext)
} catch {
case e: ClassNotFoundException if e.getMessage == lib.buildClassName =>
throw new Exception("You need to define a class Build in build.scala in: "+context.projectDirectory)
throw new Exception("You need to define a class Build in Build.scala in: "+context.projectDirectory)
}
}
} else if( projectDirectory.listFiles.exists( _.getName.endsWith(".scala") ) ){
throw new Exception(
"No file build.scala (lower case) found in " ++ projectDirectory.getPath
"No file Build.scala (upper case) found in " ++ projectDirectory.getPath
)
} else if( projectDirectory.getParentFile.getName == "build" ){
} else if( projectDirectory.getParentFile.getName == "cbt-build" ){
new BasicBuild( managedContext ) with BuildBuild
} else {
new BasicBuild( managedContext )
Expand Down
2 changes: 1 addition & 1 deletion stage2/Lib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{
def loadRoot(context: Context, default: Context => BuildInterface = new BasicBuild(_)): BuildInterface = {
context.logger.composition( context.logger.showInvocation("Build.loadRoot",context.projectDirectory) )
def findStartDir(projectDirectory: File): File = {
val buildDir = realpath( projectDirectory ++ "/build" )
val buildDir = realpath( projectDirectory ++ "/cbt-build" )
if(buildDir.exists) findStartDir(buildDir) else projectDirectory
}

Expand Down
3 changes: 1 addition & 2 deletions stage2/Scaffold.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cbt
import java.io._
import java.nio.file._
import java.net._
trait Scaffold{
def logger: Logger

Expand All @@ -27,7 +26,7 @@ trait Scaffold{
def createBuild(
projectDirectory: File
): Unit = {
createFile(projectDirectory, "build/build.scala", s"""import cbt._
createFile(projectDirectory, "cbt-build/Build.scala", s"""import cbt._
class Build(val context: Context) extends BaseBuild{
override def dependencies =
super.dependencies ++ // don't forget super.dependencies here for scala-library, etc.
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ object Main{
{
val res = runCbt("no-build-file", Seq("run"))
assert(!res.exit0)
assert(res.err contains "No file build.scala (lower case) found in", res.err)
assert(res.err contains "No file Build.scala (upper case) found in", res.err)
}

{
val res = runCbt("empty-build-file", Seq("run"))
assert(!res.exit0)
assert(res.err contains "You need to define a class Build in build.scala in", res.err)
assert(res.err contains "You need to define a class Build in Build.scala in", res.err)
}

{
Expand Down